modelcontextprotocol / modelcontextprotocol/typescript-sdk
[v2] Multiple connect per server
Open
Nobody has claimed this yet.
v1
v2
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Description
What happened?
It seems like when creating a McpServer one must create a new server for each connection. I have two issues with this design:
- first it is not properly documented that
connectmust be used only once, I understood this only by reading examples/github issues - second, it seems really innefficient, espetially on transports that are short-lived like http calls: in my understanding, each http query will recreate a new McpServer, i.e. re-register all tools/resources/… Espetially with resources, I can imagine that we can easily reach several hundreds/thousands of calls to tool/resource registration + it may adds heavy disk access if the server reads some files to determine the resources to add (templates may mitigate this + save resources in a global cache may help, but sometimes I may want to actually provide resources without templates). And all of this must be re-executed at each http query (v2 being stateless, new connection may occur even more often?), with an overhead that may be multiple orders of magnitude higher than answering the http call. I've not done any benchmark but I think it may be interesting to do some.
What did you expect?
Share connection.
Code to reproduce
SDK version
No response
Area
Server
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the v2 server lifecycle and the existing McpServer.connect usage described in the issue, including how short-lived HTTP requests create connections. Define what shared connections should mean and verify that tools, resources, and prompts are not re-registered for every request; a benchmark would help assess the performance impact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100