MCP Server with Durable History

MCP Server with Durable History

An MCP server that provides a chat tool with stateless instances and external session state, enabling durable conversation history and concurrent client handling.

Category
Visit Server

README

MCP server — stateless instances, external session state, durable history

Run it

npm install
npm run dev          # starts the server on :3000
npm run simulate     # in another terminal: runs the traffic simulation

Files

  • src/session-store.ts — the "hot" tier. Stands in for Redis: active session state, TTL-expired. Swap the internals for ioredis later; the interface (get/create/update) doesn't change.
  • src/history-store.ts — the "durable" tier. Stands in for Postgres: append-only conversation log, idempotency-key guarded so client retries under load never duplicate a turn.
  • src/mcp-instance.ts — the actual MCP server: registers a chat tool that resolves session_id → cache-or-rebuild-from-history → append turn → reply → update session.
  • src/server.ts — Express + Streamable HTTP transport. Note the comment block distinguishing MCP protocol session (transport handshake, kept in an in-memory Map, dies with the process) from application conversation session (your data, lives in the stores above, survives a restart/rescale).
  • src/simulate-traffic.ts — a real MCP client (not curl) that (a) runs one user through several turns on the same session to prove continuity, and (b) fires 25 concurrent new conversations to prove the server handles concurrent load without cross-talk.

What's simulated vs. real here

Real: the MCP protocol handshake, tool registration/invocation, the client↔server wire format, concurrency handling.

Simulated (by design, so you can run this with zero external infra): SessionStore/HistoryStore are in-memory. To go to production:

  1. Replace Map in session-store.ts with an ioredis client — same method signatures.
  2. Replace the array in history-store.ts with pg (or Drizzle/Prisma) queries against a turns table — same method signatures.
  3. Run multiple instances of server.ts behind a load balancer. Because step 4 in the design notes still applies — the MCP protocol session (the Map in server.ts) is per-process — route by Mcp-Session-Id with sticky sessions, OR terminate the client connection per-request (stateless mode) if your client library supports it. The application conversation state (step 1–2) has no such constraint; it's already externalized and safe to hit from any instance.
  4. Add a queue in front for burst absorption once traffic exceeds what autoscaling can react to in time (see architecture diagram earlier in the conversation).

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured