Public: anyone can read this; the crew can change it.

MCP `sessions` lists the caller's sign-ins #5159

Parked opened this
Closed without merging

MCP now has a sessions tool, placed right after access. test/mcp-sessions.test.ts, test/mcp.test.ts and test/mcp-size.test.ts pass (42 tests). I didn't get a usable tsc run: it failed because the bun type definitions weren't found, so the type check is unverified here.

Notes

stopped parked by the crew deploy 8b78962

opened this

MCP now has a sessions tool, placed right after access. test/mcp-sessions.test.ts, test/mcp.test.ts and test/mcp-size.test.ts pass (42 tests). I didn't get a usable tsc run: it failed because the bun type definitions weren't found, so the type check is unverified here.

  • Tool: sessions takes { username? }, defaulting to the caller. It calls accountSignIns, the same function behind GET /api/v1/users/:username/signins.
  • Rules: a token below admin scope gets forbidden, as the route refuses it. A stranger naming another person, or anyone naming an admin or an agent, gets not_found. The forge's owner can look up any person.
  • Answer: { tokens, sessions, says }, with the same fields the route returns (ids, created, last seen, expires; no secrets). The description is one short sentence.
  • Docs and tests: docs/MCP.md has a sessions row. It sits beside prompts because the file has no access row. test/mcp.test.ts now lists sessions in the expected tool order. test/mcp-sessions.test.ts covers three cases:
    • A person with two sessions sees both, and no secret appears in the answer.
    • A stranger naming another person gets not_found, and the route returns 404 for the same request.
    • The owner sees a person's sign-ins, and an rw token is refused.

Left out:

  • The route returns no device or place, so the tool doesn't either; those fields don't exist yet.
  • current is always false over MCP, because there is no browser cookie to compare against.
  • Unlike the route, the tool doesn't accept a password or browser session. MCP is token-only, so an admin-scope token is the only way in.

I did not run the rest of the suite, so I haven't checked whether main is red anywhere.

🤖 Generated with Claude Code

Closes #5147

2 earlier comments · 1 event
commented

MCP now has a sessions tool, placed right after access. test/mcp-sessions.test.ts, test/mcp.test.ts and test/mcp-size.test.ts pass (42 tests). I didn't get a usable tsc run: it failed because the bun type definitions weren't found, so the type check is unverified here.

  • Tool: sessions takes { username? }, defaulting to the caller. It calls accountSignIns, the same function behind GET /api/v1/users/:username/signins.
  • Rules: a token below admin scope gets forbidden, as the route refuses it. A stranger naming another person, or anyone naming an admin or an agent, gets not_found. The forge's owner can look up any person.
  • Answer: { tokens, sessions, says }, with the same fields the route returns (ids, created, last seen, expires; no secrets). The description is one short sentence.
  • Docs and tests: docs/MCP.md has a sessions row. It sits beside prompts because the file has no access row. test/mcp.test.ts now lists sessions in the expected tool order. test/mcp-sessions.test.ts covers three cases:
    • A person with two sessions sees both, and no secret appears in the answer.
    • A stranger naming another person gets not_found, and the route returns 404 for the same request.
    • The owner sees a person's sign-ins, and an rw token is refused.

Left out:

  • The route returns no device or place, so the tool doesn't either; those fields don't exist yet.
  • current is always false over MCP, because there is no browser cookie to compare against.
  • Unlike the route, the tool doesn't accept a password or browser session. MCP is token-only, so an admin-scope token is the only way in.

I did not run the rest of the suite, so I haven't checked whether main is red anywhere.

🤖 Generated with Claude Code

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

I made no code change this turn. The failures look unrelated to this pull, so I didn't fix anything.

  • Failing tests: forge-degraded, restore-card, sizes-api, view-source, signin-timing, settings-repo-timing and telemetry-reads-timing all pass here, 43 tests with none failing.
  • Pull's own tests: mcp-sessions and mcp pass too, 41 tests. The pull only adds the sessions listing in src/http/mcp.ts, with its docs and tests.
  • What the log shows: shard 25 failed with a string of unnamed failures. Shards 22, 23 and 27 exited 143, meaning they were killed. That points to load or a shard-level problem on the check machine, not a defect in this pull.
  • Not checked: the type check didn't run. bun x tsc --noEmit stops because it can't find the bun type definitions, and I did not run bun install first.
  • Push: nothing new is committed, so a plain git push has nothing to send. The pull needs the check re-run on the same commit (8b789621).

Pull description: MCP sessions lists the caller's sign-ins and applies the same rules as the API. I documented it in docs/MCP.md and tested it in test/mcp-sessions.test.ts, with test/mcp.test.ts updated. I added no dependencies. Try it by calling the MCP sessions tool with a signed-in token.

commented

Closed by the crew: main moved under it 2 times and the branch could not be brought up to date. Conflicting files: docs/MCP.md, src/http/mcp.ts.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs