MCP Notes Server

MCP Notes Server

Enables AI agents to manage Markdown notes via the Model Context Protocol, supporting creation, editing, searching, and conflict detection.

Category
访问服务器

README

MCP Notes Server

基于 MCP (Model Context Protocol) 的个人笔记管理服务,让 AI Agent 通过标准协议远程读写、搜索和编辑 Markdown 笔记。

功能

工具 说明
create_note 创建新笔记
append_note 追加内容(支持自动时间戳)
read_note 读取笔记(支持按行范围,返回 mtime 用于冲突检测)
delete_note 删除笔记
search_notes 跨文件关键词搜索,返回上下文
replace_in_note 精确文本替换(支持 mtime 校验)
list_notes 列出目录内容(支持递归)
smart_edit 自然语言指令编辑(调用 LLM 两步定位+操作)

特性

  • Bearer Token 鉴权 — HTTP 模式下强制 Token 验证,stdio 模式自动跳过
  • 路径安全 — 防止目录穿越,排除敏感目录(password、config 等)和指定文件
  • 冲突检测 — 写操作支持 expected_mtime 校验,防止多 Agent 基于过期内容误操作;写操作返回新 mtime 供后续使用
  • LLM 智能编辑 — smart_edit 通过 Kimi 大模型理解自然语言指令,两步执行:先定位目标内容,再精确操作

快速开始

环境准备

# Python 3.11+
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

配置

cp config/.env.example config/.env
# 编辑 config/.env,填入你的 API Key 和 Token

各字段说明见 config/.env.example。

启动

# stdio 模式(本地 Agent 直连,无需鉴权)
python mcp_server.py

# HTTP 模式(远程访问)
python mcp_server.py --transport http --port 8765

客户端连接

stdio 模式(推荐本地使用):

Agent 客户端以子进程方式自动拉起 server,通过 stdin/stdout 管道通信,无需手动启动服务。

在 Claude Desktop、Cursor 等支持 MCP 的客户端中配置:

{
  "mcpServers": {
    "notes": {
      "command": "python",
      "args": ["/path/to/mcp_server.py"]
    }
  }
}

或在代码中使用 fastmcp Client:

from fastmcp import Client

async with Client("mcp_server.py") as client:
    result = await client.call_tool("list_notes", {"directory": ""})
    print(result[0].text)

更多示例见 tests/test_client_stdio.py。

HTTP 模式(远程访问):

需要先手动启动服务,Agent 通过网络调用:

curl -X POST http://127.0.0.1:8765/mcp \
  -H "Authorization: Bearer your-secret-token" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

安全机制

  • 目录隔离:.venv、config、__pycache__、.git、password 目录不可访问
  • 文件黑名单:work/账号密码相关数据.md 等敏感文件被明确排除
  • 路径穿越防护:所有路径操作经过 resolve() 校验,禁止 .. 逃逸
  • Token 鉴权:HTTP 模式必须携带 Authorization: Bearer <token>

冲突检测机制

Agent A: read_note("file.md")     → 返回 mtime: 1751529600.123
Agent A: replace_in_note(..., expected_mtime=1751529600.123) → ✅ 成功,返回新 mtime: 1751529605.456
Agent B: replace_in_note(..., expected_mtime=1751529600.123) → ⚠️ 被拦截,提示重新读取

依赖

内网穿透(可选)

如需从公网访问,可自行搭建内网穿透。以 frp 为例:

  1. 下载 frpc 放到项目目录
  2. 配置 frpc.toml:
serverAddr = "your-server-ip"
serverPort = 9000

[[proxies]]
name = "mcp-server"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8765
remotePort = 8765
  1. 启动时加 --frpc 自动拉起 frpc:
python mcp_server.py --transport http --port 8765 --frpc

也可手动单独启动 frpc,不依赖本服务管理。

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选