I built a tiny MCP notes server in Python — here's the whole thing, free
说明与用途
一个轻量级的 Python MCP 笔记服务器,使用本地 JSON 存储数据,提供创建、列出和搜索工具,并解决同秒时间戳排序和 SDK 版本问题。
问题
Provide a minimal, local notes server that an AI assistant can use without a database or cloud account.
结果
A minimal MCP notes server that stores notes in a local JSON file, supports create, list, and search, and handles timestamp sorting and SDK versioning bugs.
工作流
- Implement create_note, list_notes, search_notes tools.
- Store notes in notes.json with atomic writes.
- Add insertion index to resolve same‑second timestamp sorting.
- Pin mcp SDK version to <2 to avoid import errors.
- Package .mcpb bundles for Smithery and Anthropic registries.
- Publish code on GitHub and install via Smithery.
- Verify end‑to‑end functionality with the real SDK.
证据
Most MCP (Model Context Protocol) examples are either toy "hello world" servers or sprawling frameworks. I wanted the smallest useful thing: a notes server an AI assistant can actually use — create a note, list notes, search notes — backed by a plain local JSON file. No database, no cloud, no account.
Three tools, that's it: create_note(title, body, tags) — appends a note with an ISO timestamp; list_notes(limit) — newest first; search_notes(query) — case-insensitive substring search over title, body, and tags
Notes live in a local notes.json. Saves are atomic (write to temp file, then rename), so a crash mid-write can't corrupt your notes.
Same-second timestamps sort wrong. If two notes are created within the same second, sorting by timestamp alone gives you unstable order. Fix: keep a monotonically increasing insertion index and sort by (created_at, index).
Pin your SDK major version. mcp>=1.6.0 now resolves to the 2.x SDK, where FastMCP moved and 1.x-style code breaks at import time. My requirements now read mcp>=1.6.0,<2.
I verified the server end-to-end over stdio with the real SDK — tools list correctly, and create/search/list all round-trip.
- 记录日期: 2026-10-14T17:56:00.159Z