https://github.com/anyproto/anytype-mcp
这是一个基于 Model Context Protocol (MCP) 的服务器,提供对 Anytype API 的访问,允许 AI 助手和其他 MCP 客户端与您的 Anytype 数据进行交互。
基于 Anytype API 定义 v0.46+ (2025-03-17)。 确保您的 Anytype 桌面应用程序版本兼容。
get_spaces)get_objects, search_space) 或全局搜索 (global_search)get_object_content,支持检索全文)create_space) 和对象 (create_object, delete_object)export_object)get_list_views, get_list_view_objects, add_objects_to_list, remove_object_from_list)get_space_members)get_types, get_type_details, get_templates, get_template_details)克隆此仓库:
git clone https://github.com/Qwinty/anytype-mcp.git
cd anytype-mcp
安装依赖项:
npm install
构建项目(将 TypeScript 编译为 JavaScript 并放置在 build/ 目录中):
npm run build
获取应用密钥: 在配置服务器之前,您需要从 Anytype 获取一个应用密钥。请参阅下面的“获取应用密钥”部分。
将 MCP 服务器添加到您的 MCP 配置文件中
在使用 MCP 服务器之前,您需要从 Anytype 桌面应用程序获取一个应用密钥:
确保 Anytype 桌面应用程序正在运行
运行辅助脚本:
npm run get-key
按照指示授权应用程序
记下应用密钥以供配置使用
将 Anytype MCP 服务器添加到您的 MCP 配置文件中:
claude_desktop_config.json示例配置:
{
"mcpServers": {
"anytype": {
"command": "node",
"args": ["{path/to/anytype-mcp}/build/index.js"],
"env": {
"ANYTYPE_APP_KEY": "YOUR_APP_KEY_HERE"
},
"disabled": false
}
}
}
将 {path/to/anytype-mcp} 替换为您实际的安装路径,并将 YOUR_APP_KEY_HERE 替换为您获得的应用密钥。
MCP 服务器通常由 MCP 客户端自动启动。不过,您也可以手动启动它来进行测试:
npm start
有关可用工具及其使用示例的详细列表,请参见 Tools.md。
此外,还提供了适用于使用此服务器的 AI 助手的系统提示样本,位于 docs/system-prompt.md。
为了优化与 AI 助手的令牌使用,此 MCP 服务器默认实现了响应过滤,针对返回对象数据的工具(如 get_objects, global_search, search_space)。
include_text: true: 若干工具(get_objects, get_object_content, global_search, search_space)支持可选的 include_text 参数。当设置为 true 时,服务器会提取并包含对象块中的完整格式化文本内容到 full_text 字段中。当您需要完整文本时使用此参数,但请注意这会显著增加响应大小和令牌数量。full_response: true: 工具 get_objects, global_search 和 search_space 也支持 full_response 参数。将其设置为 true 可绕过所有过滤并直接返回来自 Anytype API 的原始完整 JSON 响应。这提供了最详细的信息,但也使用最多的令牌。根据您是否只需要元数据、完整文本内容或完整的原始 API 响应,选择合适的参数。
确保您的计算机上正在运行 Anytype 桌面应用程序。MCP 服务器连接到本地 Anytype API 的 http://localhost:31009/v1。
如果您遇到认证错误:
npm run get-key 以获取新的应用密钥服务器默认连接到 Anytype API 的 http://localhost:31009/v1。如果您的 Anytype 安装使用了不同的端口,您目前需要修改 src/index.ts 中的 apiBaseUrl 变量并重新构建 (npm run build)。未来可能会通过环境变量来配置此选项。
MIT