mcp-thread-persistence-demo
MCP Thread Persistence Demo
SQLite にチャットスレッドのメモを永続化する最小限の MCP (Model Context Protocol) サーバーで、実際の stdio トランスポート経由でそれを実行する本物のクライアントを備えています(基盤となる関数を直接呼び出すだけではありません)。
実際のフリーランス案件のパターンを反映した学習用の演習として構築されています。「チャットスレッドの状態をデータベースに永続化する MCP ツール呼び出しを修正・実装する。upsert セマンティクス(新規なら作成、既存なら更新、スレッドごとに重複行なし)を備える」
内容
server.py— 3つのツールを公開する MCP サーバー:save_note(user_id, thread_id, content)— SQLite に upsert し、(user_id, thread_id)をキーとします。同じスレッドへの2回目の呼び出しは、重複を作成せず既存の行を更新します。get_note(user_id, thread_id)— 保存されたメモを読み戻します。list_threads(user_id)— ユーザーのすべてのスレッドを一覧表示します。
test_client.py— stdio 経由でserver.pyに接続し、list_toolsを呼び出してから、3つのツールすべてを順番に実行する本物の MCP クライアントです(同じスレッドでsave_noteを2回呼び出して、upsert が重複行を作成しないことを検証する処理を含みます)。
Related MCP server: teamshare-server
実行方法
python3.12 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python test_client.py注記
意図的に mcp<2 に固定しています。mcp SDK の 2.x リリースでは FastMCP が MCPServer に改名され、他の API も変更されました。世の中の既存のチュートリアルやコードベースのほとんどは今でも 1.x の FastMCP API を対象としているため、これもそれを対象としています。
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent memory layer for AI tools. Save and recall notes across Claude and other MCP clients.
MCP-native notes and memory for ChatGPT, Claude, and other AI tools.
Google Keep-style notes app with an MCP server for AI agents to read/write notes.
Persistent memory shared across Claude, ChatGPT, Grok and other MCP clients.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables adding, getting, and listing notes through MCP, with state persisted to a JSON file in the home directory.MIT
- FlicenseNot gradedqualityBmaintenanceEnables coding agents on a team to publish short context notes that are automatically surfaced at the start of every teammate's next session, with read receipts and SQLite-backed persistent storage over MCP.-
- AlicenseAqualityBmaintenanceEnables MCP-compatible agents to remember, recall, link, and forget durable notes across devices, with local SQLite storage and optional libSQL/Turso sync.41MIT
- AlicenseNot gradedqualityCmaintenanceEnables creating, retrieving, updating, deleting, and listing notes through a simple MCP interface, with configurable note storage.MIT