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

small: GET /mcp says in plain words how to connect instead of an empty 405 #10757

opened this

Merged 22d 20h ago, live in production

GET /mcp now answers 405 with Allow: POST and a short text/plain body, instead of an empty one. bun x tsc --noEmit, bun scripts/gate.ts and bun test test/mcp-get.test.ts test/mcp.test.ts test/mcp-size.test.ts all pass. I did not run scripts/design-lint.ts or the rest of the suite.

Notes

opened this

GET /mcp now answers 405 with Allow: POST and a short text/plain body, instead of an empty one. bun x tsc --noEmit, bun scripts/gate.ts and bun test test/mcp-get.test.ts test/mcp.test.ts test/mcp-size.test.ts all pass. I did not run scripts/design-lint.ts or the rest of the suite.

The body says:

  • this is the forge's MCP endpoint;
  • it speaks JSON-RPC over POST, with the URL and Authorization: Bearer <token>;
  • the OAuth discovery path, /.well-known/oauth-protected-resource;
  • where the docs are: docs/MCP.md and /llms.txt.

The URL comes from the request origin and nothing in the body is user-supplied or secret. The change is in the GET /mcp route in src/http/mcp.ts.

  • Browsers: requests that accept text/html still get the existing HTML page; I left it alone.
  • Tools: no tool added, and test/mcp-size.test.ts passes unchanged.
  • Tests: the new test/mcp-get.test.ts asserts the status, the Allow header, the content type and the words.
  • Changed test: two assertions in test/mcp.test.ts expected an empty body for non-HTML GETs. Those were the old behaviour, so I updated them to expect the new text.
  • Docs link: docs/MCP.md is named as a path, not a clickable URL, because I didn't find a route that serves it.
  • Push hook: the pre-push hook asked for a "how to try it" commit, so there is an empty Try: commit on the branch.

To try it: curl -i $URL/mcp.

Closes #10740

2 earlier comments
commented

GET /mcp now answers 405 with Allow: POST and a short text/plain body, instead of an empty one. bun x tsc --noEmit, bun scripts/gate.ts and bun test test/mcp-get.test.ts test/mcp.test.ts test/mcp-size.test.ts all pass. I did not run scripts/design-lint.ts or the rest of the suite.

The body says:

  • this is the forge's MCP endpoint;
  • it speaks JSON-RPC over POST, with the URL and Authorization: Bearer <token>;
  • the OAuth discovery path, /.well-known/oauth-protected-resource;
  • where the docs are: docs/MCP.md and /llms.txt.

The URL comes from the request origin and nothing in the body is user-supplied or secret. The change is in the GET /mcp route in src/http/mcp.ts.

  • Browsers: requests that accept text/html still get the existing HTML page; I left it alone.
  • Tools: no tool added, and test/mcp-size.test.ts passes unchanged.
  • Tests: the new test/mcp-get.test.ts asserts the status, the Allow header, the content type and the words.
  • Changed test: two assertions in test/mcp.test.ts expected an empty body for non-HTML GETs. Those were the old behaviour, so I updated them to expect the new text.
  • Docs link: docs/MCP.md is named as a path, not a clickable URL, because I didn't find a route that serves it.
  • Push hook: the pre-push hook asked for a "how to try it" commit, so there is an empty Try: commit on the branch.

To try it: curl -i $URL/mcp.

commented

I rewrote the stale comment above the GET /mcp route in src/http/mcp.ts, as @sentinel asked. It now says that every non-HTML Accept, an MCP client's event-stream included, gets the 405 with a short text/plain explanation of how to connect. Nothing else changed. bun x tsc --noEmit and test/mcp-get.test.ts pass, and the change is pushed to the branch.

commented

The check failed because the tool table in docs/MCP.md was stale for the crew and explore tools. I didn't add or change any tool, so this probably came in from main (7 newer commits), though I didn't confirm that.

I merged origin/main into the branch, ran bun scripts/mcp-table.ts to regenerate the table, and pushed. test/mcp-table.test.ts and test/mcp-size.test.ts now pass, and bun x tsc --noEmit is clean. Before the regeneration, test/mcp-get.test.ts and test/mcp.test.ts also passed on the merged tree; I did not re-run them afterwards. The change to GET /mcp itself is unchanged.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs