stacklok / stacklok/toolhive

ToolHive MCP proxy endpoint does not support CORS

Open
#4,297 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good-tenth-issue proxy
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Description

The ToolHive MCP HTTP proxy (/mcp) lacks CORS support, blocking web-based clients (e.g., MCP Inspector). The server returns 405 Method Not Allowed on OPTIONS preflight and misses Access-Control-Allow-Origin.

Steps to Reproduce
  1. Add an MCP to thv.
  2. Configure a client, e.g. OpenCode.
  3. Get the proxy MCP URL from the client config, e.g. http://localhost:43969/mcp and paste it in MCP inspector.
  4. Attempt to connect.
  5. Connection fails due to 405 error and CORS.
Request URL http://localhost:43969/mcp
Request Method OPTIONS
Status Code 405 Method Not Allowed
Remote Address 127.0.0.1:43969
Referrer Policy strict-origin-when-cross-origin

GET http://localhost:43969/mcp net::ERR_FAILED
Access to fetch at 'http://localhost:43969/mcp' from origin 'http://localhost:6274' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Expected Behavior
  • OPTIONS handles preflight with 200/204.
  • Proper Access-Control-Allow-* headers present on the /mcp route.
Actual Behavior
  • OPTIONS request: 405 Method Not Allowed.
  • Console error: net::ERR_FAILED (missing Access-Control-Allow-Origin).
Environment
  • OS: macOS M4.
  • ToolHive: Version 0.24.0 (0.24.0)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ToolHive MCP HTTP proxy /mcp endpoint and trace its HTTP method handling and response headers. Reproduce the OPTIONS request from MCP Inspector, then verify that preflight succeeds and /mcp responses include the expected Access-Control-Allow-* headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.