mcp-thread-persistence-demo
MCP 线程持久化演示
一个极简的 MCP(Model Context Protocol)服务器,将聊天线程笔记持久化到 SQLite,并附带一个真实客户端,通过实际的 stdio 传输来调用它(不仅仅是直接调用底层函数)。
作为学习练习构建,模仿真实的自由职业工作模式:"修复/实现 MCP 工具调用,将聊天线程状态持久化到数据库,采用 upsert 语义(新建则创建,已存在则更新,每个线程不产生重复行)。"
这里有什么
server.py— 暴露三个工具的 MCP 服务器:save_note(user_id, thread_id, content)— 以(user_id, thread_id)为键 upsert 到 SQLite。对同一线程的第二次调用会更新现有行,而不是创建重复行。get_note(user_id, thread_id)— 读回已保存的笔记。list_threads(user_id)— 列出某个用户的所有线程。
test_client.py— 一个真实的 MCP 客户端,通过 stdio 连接到server.py,调用list_tools,然后按顺序执行全部三个工具(包括对同一线程调用两次save_note,以验证 upsert 不会创建重复行)。
Related MCP server: Claw Memory Bridge
运行
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 为目标,因此本演示也以该版本为目标。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- TaprootOAuthcom.taproothq
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.
- HeirmosOAuthcom.heirmos
Persistent memory shared across Claude, ChatGPT, Grok and other MCP clients.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides persistent memory management with SQLite, enabling storage and retrieval of conversational context with metadata via MCP tools and REST API.-
- AlicenseNot gradedqualityCmaintenanceProvides a shared memory bridge for AI agents (QClaw, Claude Code, Codex) allowing them to store, search, and retrieve notes, decisions, and conclusions via MCP tools, using local SQLite with optional TencentDB integration.MIT
- AlicenseNot gradedqualityCmaintenanceA local notes app that enables AI tools to manage notes via MCP (list, get, create, update, delete) using the same SQLite database as the GUI.16MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP-capable agents to safely and persistently participate in technocore.chat rooms and notes with local did:key identity signing, an append-only activity ledger, duplicate post protection, and injection-hardened reads.MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/BenzyTAi/mcp-thread-persistence-demo'
If you have feedback or need assistance with the MCP directory API, please join our Discord server