Skip to content

MCP 协议

概述

Open Note 实现了 Model Context Protocol (MCP),允许 AI 工具(如 Cursor、Claude Desktop)直接访问你的笔记。

安装

详见 MCP 安装文档

配置

Cursor

在项目根目录创建 .cursorrules 或全局配置:

json
{
  "mcpServers": {
    "open-note": {
      "command": "python",
      "args": ["-m", "open_note_mcp.server"],
    }
  }
}

Claude Desktop

编辑配置文件:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

json
{
  "mcpServers": {
    "open-note": {
      "command": "python",
      "args": ["-m", "open_note_mcp.server"]
    }
  }
}

OpenCode

OpenCode 使用自己的插件安装方式;即使您已经在其他框架中使用 opennote,也请单独安装它。

  • 告诉 OpenCode:

    Fetch and follow instructions from https://github.com/The-Flash-7/open-note/refs/heads/main/docs/mcp/MCP_INSTALL.md

可用工具

search_notes

搜索笔记。

json
{
  "name": "search_notes",
  "description": "搜索笔记",
  "inputSchema": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "搜索关键词"
      },
      "category": {
        "type": "string",
        "description": "分类名称(可选)"
      },
      "tags": {
        "type": "array",
        "items": {"type": "string"},
        "description": "标签列表(可选)"
      }
    },
    "required": ["query"]
  }
}

get_note

获取单个笔记内容。

json
{
  "name": "get_note",
  "description": "获取笔记内容",
  "inputSchema": {
    "type": "object",
    "properties": {
      "note_id": {
        "type": "string",
        "description": "笔记 ID"
      }
    },
    "required": ["note_id"]
  }
}

create_note

创建新笔记。

json
{
  "name": "create_note",
  "description": "创建新笔记",
  "inputSchema": {
    "type": "object",
    "properties": {
      "title": {
        "type": "string",
        "description": "笔记标题"
      },
      "content": {
        "type": "string",
        "description": "笔记内容"
      },
      "category": {
        "type": "string",
        "description": "分类名称(可选)"
      },
      "tags": {
        "type": "array",
        "items": {"type": "string"},
        "description": "标签列表(可选)"
      }
    },
    "required": ["title", "content"]
  }
}

update_note

更新笔记。

json
{
  "name": "update_note",
  "description": "更新笔记",
  "inputSchema": {
    "type": "object",
    "properties": {
      "note_id": {
        "type": "string",
        "description": "笔记 ID"
      },
      "title": {
        "type": "string",
        "description": "新标题(可选)"
      },
      "content": {
        "type": "string",
        "description": "新内容(可选)"
      }
    },
    "required": ["note_id"]
  }
}

list_categories

获取分类列表。

list_tags

获取标签列表。

示例对话

搜索笔记

用户:帮我找一下关于 React 的笔记

AI:(调用 search_notes)我找到了 3 篇关于 React 的笔记...

创建笔记

用户:帮我创建一个会议记录,标题是"产品评审"

AI:(调用 create_note)已创建笔记"产品评审"

总结笔记

用户:总结一下我的"项目计划"笔记

AI:(调用 get_note + 总结)这篇笔记的主要内容是...

安全注意事项

  • MCP Server 仅在本地运行
  • 不会暴露 API Key
  • 数据库访问受文件系统权限保护

故障排查

Q: Server 启动失败

确保已安装 open-note-mcp 包:

bash
pip install open-note-mcp

Q: 工具调用无响应

检查日志输出,确认数据库路径正确。