Skip to content

feat: agent access tokens that can drive threads - #118

Merged
adampeterhiggins merged 1 commit into
mainfrom
ah/mcp-write-5-operate-tokens
Oct 1, 2026
Merged

adampeterhiggins merged 1 commit into
mainfrom
ah/mcp-write-5-operate-tokens

Conversation

@adampeterhiggins

@adampeterhiggins adampeterhiggins commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Stack 5 of 8: agents operate T3 Code over MCP. Based on #117.

Agents outside T3 Code, such as a scheduled Claude Code run, could only read history through /mcp/query. This lets them start and drive threads as the user would.

  • Tokens get an access level.
    • POST /api/auth/agent-access-tokens takes access: "read" | "operate", defaulting to read.
    • Operate tokens get AuthAgentOperateScopes (orchestration:read + orchestration:operate).
    • mcpUrl points at the matching endpoint.
  • /mcp/operate is a new fresh MCP server in apps/server/src/mcp/query/QueryMcpServer.ts.
    • It lists the history toolkit plus the operate toolkit.
    • It requires both scopes and an explicit Authorization header (cookies are stripped, like /mcp/query).
    • It provides a token McpActor carrying the session label, so threads it starts record { kind: "agent-access", label }.
    • Token actors act as the user: no spawn limits or runtime-mode ceiling.
    • Both endpoints now share one middleware, and the path constants live in mcp/paths.ts to keep auth/http.ts off the MCP server module.
  • AuthenticatedSession.label carries the client label through bearer auth.
  • Web, desktop, CLI:
    • Settings → Connections → Agent access has an Access picker (Read history / Read and drive threads).
    • It lists both kinds of token with their level.
    • It generates claude mcp add … t3-code-control … for operate tokens.
    • From a terminal: t3 auth session issue --operate.
  • Docs: docs/user/agent-access.md and the fork-differences entry rewritten for both levels.

Testing:

  • QueryMcpServer.test.ts: a read token gets 403 on /mcp/operate; an operate token lists both toolkits; /mcp/query never lists create_thread.
  • http.test.ts: operate issuance returns both scopes and an /mcp/operate URL.
  • Passing: server src/mcp + src/auth + src/cli 319/319, web settings 462/462.
  • tsc is clean for server and web.

Done by Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

Agent access tokens gain an access level. A read token keeps reaching
/mcp/query; an operate token (orchestration:read + operate) reaches the
new /mcp/operate server, which lists the history tools and the thread
tools and acts as the user, recording the token's label on threads it
starts. Settings → Connections → Agent access picks the level and lists
both kinds; `t3 auth session issue --operate` does the same from a
terminal.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@adampeterhiggins
adampeterhiggins force-pushed the ah/mcp-write-5-operate-tokens branch from 5607d0d to c924550 Compare October 1, 2026 08:33
@adampeterhiggins
adampeterhiggins changed the base branch from ah/mcp-write-4-thread-control-setting to main October 1, 2026 08:33
@adampeterhiggins
adampeterhiggins merged commit 77d6801 into main Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant