You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ A playground for Model Context Protocol (MCP) server built with TypeScript and S
7
7
- MCP Server implementation: HTTP-Based Streamable transport using `@modelcontextprotocol/sdk` with HTTP transport, session management, and tool execution.
8
8
- OAuth authentication/3rd party authorization: Implements an OAuth server for MCP clients to process 3rd party authorization servers like Auth0, providing Dynamic Application Registration for MCP server.
9
9
- Storage: Provide storage for MCP server to store data like OAuth sessions, tokens, etc.
10
-
- Session Management: MCP server can manage multiple sessions stateless.
10
+
- Session Management: Support stateful sessions by using replay of initial request.
11
11
- Tools: `echo`, `system-time`, `streaming`, `project` for demonstration.
## How to make stateful session with multiple MCP Server instances?
137
+
138
+
When the MCP server is deployed as a cluster, it is not possible to make it stateful with multiple MCP Server instances because the transport is not shared between instances by design.
139
+
140
+
To make it truly stateful, I used Valkey to store the session id with the initial request.
141
+
142
+
When the request comes in to alternative MCP server instance, it will check if the session id is in the Valkey. If it is, it will replay the initial request and connect the transport to the server.
143
+
144
+
Inspired from [https://github.com/modelcontextprotocol/modelcontextprotocol/discussions/102](https://github.com/modelcontextprotocol/modelcontextprotocol/discussions/102)
145
+
146
+
The below diagram shows the flow of the stateful session management.
0 commit comments