modelcontextprotocol / modelcontextprotocol/typescript-sdk

MCP SDK Can not handle the MCP Servers with subpath

Open Beginner friendly
#471 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug fix proposed P2 ready for work
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

Issue:
Clients (Inspector/Cherry Studio) fail to connect when MCP Server uses a subpath (e.g., http://domain.com/subpath/sse). Root paths (http://domain.com/) work normally.

Reproduce:

  1. Start MCP Server at http://domain.com/subpath/sse
  2. Client connection fails with error:
    Error POSTing to endpoint (HTTP 503): no healthy upstream

Cause:
In sse.ts#L146, new URL() discards the subpath from the server URL. Example:
Request to /messages/ becomes http://domain.com/messages/ instead of http://domain.com/subpath/messages/.

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 by reading src/client/sse.ts around line 146 and trace how the server URL is used to construct the messages request. Reproduce the connection against a server mounted at a subpath, then verify that the request retains the subpath while root-path connections continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.