Implements an in-memory event store that logs all requests and responses, enabling a complete audit trail and message resumability for interrupted connections.
Used to build the HTTP server for the MCP calculator service, handling routes, request processing, and rate limiting through express-rate-limit middleware.
Utilized for generating explanations and educational content in features like explain-calculation and generate-problems.
Used for sequence diagram visualization in the documentation to illustrate the architecture and flow of the stateful HTTP transport.
Serves as the runtime environment for the MCP server, handling asynchronous operations and HTTP request processing.
Powers the implementation of the MCP calculator server, providing strong typing and enhanced development experience.
Implements rigorous validation of all incoming parameters to prevent malformed data and injection attacks.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@example-mcp-server-streamable-httpretrieve my current session data for project Alpha"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
example-mcp-stateful
learning-first boilerplate for stateful MCP servers over Streamable HTTP with TypeScript SDK v2.
part of a series: stdio · stateless · stateful (you are here) · sse
what it does
runs a stateful MCP server where sessions persist across requests with in-memory storage
implements the full Streamable HTTP lifecycle:
POST /mcp(JSON-RPC),GET /mcp(SSE stream),DELETE /mcp(session close)demonstrates SSE resumability via an in-memory event store with
Last-Event-Idreplayregisters example tools (
add_note,list_notes,simulate_work), resources (session://overview,session://notes/{index}), and a prompt (study-notes)includes a scaffold CLI to generate new projects from templates
vendors MCP TypeScript SDK v2 pre-release tarballs for reproducible installs
Related MCP server: Typefully MCP Server
quick start
server starts at http://127.0.0.1:1453. endpoints:
POST /mcp-- JSON-RPC requestsGET /mcp-- SSE streamDELETE /mcp-- close sessionGET /health-- health checkGET /sessions-- list active sessions
Docker alternative:
scaffold cli
generate a new project from the included templates:
options: --force, --dir <path>, --sdk vendored|registry. see scaffold CLI docs for details.
documentation
doc | description |
install, run, verify endpoints | |
module layout, session lifecycle, resumability | |
generate new projects from templates | |
v2 packages, vendoring, migration | |
smoke tests, primitive checks, release checklist |
sdk v2 context
this project targets MCP TypeScript SDK v2 pre-release (2.0.0-alpha.0). the v2 SDK splits the monolithic @modelcontextprotocol/sdk package into server, node, client, and core. this repo uses @modelcontextprotocol/server for McpServer and @modelcontextprotocol/node for NodeStreamableHTTPServerTransport. vendored tarballs under vendor/mcp-sdk-v2/ ensure reproducible installs until v2 reaches stable release.
license
MIT