mcp: fix /api/mcp routing (404 on real calls) + surface it in the UI with curls - #109
Merged
Merged
Conversation
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
The MCP endpoint 404'd on every real call: mcp-handler routes by pathname and
defaults its endpoint to "/mcp", but the route is mounted at /api/mcp — so auth
passed (withMcpAuth) then the handler 404'd. (The in-memory contract test didn't
catch it because it bypasses HTTP routing.) Fixed by passing config
{ basePath: "/api" } so mcp-handler derives /api/mcp; maxDuration 120 for a
multi-account promote_url.
Verified end-to-end against a real running server + prod Supabase/AI (throwaway
token, read-only tools): initialize, tools/list, list_accounts (6 accounts),
generate_promo_post (real pitch) all 200.
Also surfaced the server in the UI: the Social → API tokens page now has an "MCP
server" section — endpoint, agent config JSON, and copy-paste curls (with the
required Accept: application/json, text/event-stream header). docs/mcp.md gains
the same curls.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ralyodio
force-pushed
the
mcp/fix-basepath
branch
from
July 17, 2026 12:50
04f1761 to
a35b0d7
Compare
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.
Critical fix
The MCP endpoint (#108) 404'd on every real MCP call.
mcp-handlerroutes by URL pathname and defaults its endpoint to/mcp, but the route is mounted at/api/mcp— sowithMcpAuthpassed (auth worked) and then the handler returned404 Not found. The in-memory contract test didn't catch it because it drives the SDK server directly, bypassing HTTP routing.Fix: pass
{ basePath: "/api" }tocreateMcpHandlerso it derives/api/mcp(+maxDuration: 120for a multi-accountpromote_url).Verified end-to-end
Ran the built server locally with the real prod env and hit it with a throwaway token (read-only tools only, deleted after):
initialize→ 200tools/list→ 200, all 4 toolstools/call list_accounts→ 200, returned the 6 connected accountstools/call generate_promo_post→ 200, generated a real bluesky pitchNow surfaced in the UI
The Social → API tokens page gains an "MCP server" section:
/api/mcp)tools/listandpromote_url, including the requiredAccept: application/json, text/event-streamheaderdocs/mcp.mdgets the same curls.Deploy
Same instance, no migration.
tscclean,next buildcompiles both routes.🤖 Generated with Claude Code