Repository navigation
CoderHelm as an MCP server: OAuth sign-in, run and review tools - #530
Merged
Merged
Conversation
People add CoderHelm to Claude, Cursor, VS Code or any MCP client at /mcp on the install's API address, sign in with OAuth 2.1 (dynamic client registration, PKCE S256, short-lived access tokens checked against their connection on every call, rotating refresh tokens, revocation), and use list_runs, get_run, start_run, retry_run, list_reviews, get_review and request_review as themselves. Each tool call goes through the API router and auth middleware as the person who connected the app, so it is authorized exactly like the same dashboard action, limited to the routes of the tool being called and the connection's scopes, and written to the team's log before it runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CoderHelm is now an MCP server. People add
https://api.coderhelm.com/mcp(orhttps://<install address>/mcpon a self-hosted install) to Claude, Cursor, VS Code or any MCP client, sign in with OAuth, and see runs, start and retry them, and read or ask for reviews, as themselves.Each tool is a dashboard action and runs as one: a tool call becomes a request to the same
/apiroute the dashboard calls, through the same router and auth middleware, as the person who connected the app. Their membership, current role (custom roles included), the team's two-factor rule, the route's capability and its own role check all apply, plus the connection's scopes. Every call is written to the team's log before it runs.Changes
MCP server (
mcp_server.rs)POST /mcp, Streamable HTTP, stateless JSON answers;GETandDELETEanswer 405. Protocol versions 2025-11-25, 2025-06-18 and 2025-03-26.readOnlyHint/destructiveHint/idempotentHint/openWorldHint:list_runs(status, repo, since),get_run(steps, pull requests, holds and open questions, error, latest notes),start_run(GitHub issue URL orowner/name#N, a Jira key CoderHelm has seen, or a task in words with its repo),retry_run,list_reviews,get_review(by id or PR URL, with findings),request_review(PR URL).McpCallerrequest extension, which only the gateway can set.middleware::auth::app_requestchecks it like a session:check_member_sessionagainst when the person connected the app (a removal, role change or two-factor reset ends the connection),check_sessionwith the sign-in proof kept from consent, thenmcp_server::decide: the route must be one the called tool uses, the connection must hold its scope, andpermissions::resolve_accessmust allow it.tools/callwrites anmcp_callentry to the team's audit log first; if the log can't be written, the call doesn't run.runs:writeanswers403withWWW-Authenticate: Bearer error="insufficient_scope"(step-up).OAuth 2.1 (
mcp_oauth.rs,routes/mcp_oauth.rs)/.well-known/oauth-protected-resource[/mcp](RFC 9728) and/.well-known/oauth-authorization-server(RFC 8414). The401on/mcpnames the resource metadata and asks forruns:read.POST /oauth/register(RFC 7591): public clients only, redirect addresses must be https, http on loopback (any port, RFC 8252) or an app's own scheme. Rate-limited per address.GET /oauth/authorize: checks client, redirect, PKCE S256 andresource, then sends the person to the dashboard consent page with the request signed into the link (10 minutes). A bad client or redirect is a page, never a redirect.POST /api/mcp/authorize/describe,POST /api/mcp/authorize); never from a support view or an API key. Writing is a separate choice on the page. The connection is logged (mcp_connected).POST /oauth/token: one-time codes (deleted on swap, 5 minutes, bound to client, redirect and PKCE verifier); access tokens are JWTs for audiencecoderhelm-mcp(1 hour), checked against their connection on every call; refresh tokens are opaque, stored as hashes, replaced on every use, 30 days from last use, and a replaced one used again ends the connection.POST /oauth/revoke(RFC 7009) for refresh or access tokens.GET /api/mcp/connectionsandDELETE /api/mcp/connections/:id: your own connections, or everyone's for people who manage API keys. Revoking is logged (mcp_revoked) and stops every token of the connection at once.Starting a run from a ticket (
routes/run_start.rs)POST /api/runs/start(capabilityruns, member and up): a GitHub issue is read with the team's app and queued as labeling it would queue it, with the person as requester; a known Jira key starts again from its latest run as Retry does. The token limit and the in-flight trigger gate apply.Edges
/mcp, the metadata and the token endpoints answer any origin without credentials (bearer tokens only), withAuthorizationand the MCP headers allowed andWWW-Authenticateexposed./mcp,/.well-known/{proxy+}and/oauth/{proxy+}; the self-hosted CloudFront sends/mcp,/.well-known/oauth-*and/oauth/*to the API. Both go through the normal stack template. No new IAM: the gateway uses the settings and users tables it already reads and writes, and the deploy role already manages the API's routes and the distribution.Verification
cargo fmt --check --all,cargo clippy --workspace --all-targets -- -D warnings: clean.cargo test --workspace: all pass (common 1569, gateway 793, worker 1410).mcp_,run_startandcorsmodules): PKCE (RFC 7636 vector, wrong verifier, malformed verifiers), authorization request checks (no PKCE, plain PKCE, wrong response type, foreign resource, unregistered redirect shown as a page), redirect address rules, registration, scopes, signed consent link expiry, code swap once only and by its own app, expired code, access token expiry, refresh rotation with reuse ending the connection, narrowing scopes on refresh and never widening, revocation from the dashboard and by the app, wrong team, person or app on a token, per-tool authorization for viewer, member, admin, owner and custom roles under each scope, a tool reaching only its own routes, routes no tool uses refused, the 401 and 403 challenges,/mcpover HTTP (no token, a session token, garbage, an expired token, GET and DELETE), CORS for browser MCP clients, ticket parsing.infra:npm test(155 pass), including a new test that the MCP routes reach the gateway hosted and self-hosted, and that/authorizestays with the dashboard.