-
Notifications
You must be signed in to change notification settings - Fork 3
bug: NewHTTPHandler shares single mcp.Server across all SSE connections #62
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingpriority: mediumShould fix - correctness or quality concernShould fix - correctness or quality concern
Description
Summary
NewHTTPHandler creates a single mcp.Server instance and returns it for every incoming HTTP request. The mcp.NewSSEHandler callback pattern (accepting *http.Request and returning *mcp.Server) suggests per-connection server instantiation was intended.
Location
server/server.go:764-769
func NewHTTPHandler(core *Core, opts ...ServerOptions) http.Handler {
srv := NewMCPServer(core, opts...)
return mcp.NewSSEHandler(func(_ *http.Request) *mcp.Server {
return srv
}, nil)
}Impact
If the MCP SDK maintains per-session state on the *mcp.Server instance (protocol negotiation, request IDs, etc.), sharing one instance across all SSE clients could cause cross-session state leakage or protocol errors.
Suggested Fix
Create a fresh server per connection:
return mcp.NewSSEHandler(func(_ *http.Request) *mcp.Server {
return NewMCPServer(core, opts...)
}, nil)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpriority: mediumShould fix - correctness or quality concernShould fix - correctness or quality concern