Frappe MCP Server

Frappe MCP Server

site icon
2025.04.17 9
TypeScript文档管理数据库操作API 接口开发效率数据库
Frappe MCP Server 是一个为 Frappe 框架设计的模型上下文协议(MCP)服务器,通过官方 REST API 向 AI 助手暴露 Frappe 的功能,专注于文档的 CRUD 操作、模式处理以及详细的 API 指令。该服务器提供标准化的接口,使 AI 助手能够与 Frappe 应用程序进行交互,包括文档操作、模式和元数据处理、DocType 发现和探索等功能。
View on GitHub

Overview

基本能力

产品定位

Frappe MCP Server 是一个为 Frappe 框架设计的 MCP 服务器,旨在通过标准化接口向 AI 助手暴露 Frappe 的功能,特别关注文档操作和模式处理。

核心功能

  • 文档操作(创建、读取、更新、删除、列表)
  • 模式和元数据处理
  • DocType 发现和探索
  • 详细的 API 使用指令和示例

适用场景

  • AI 助手与 Frappe 应用程序的交互
  • 自动化文档管理
  • 数据库操作和模式查询

工具列表

文档操作工具

  • create_document: 在 Frappe 中创建新文档
  • get_document: 从 Frappe 检索文档
  • update_document: 更新 Frappe 中的现有文档
  • delete_document: 从 Frappe 删除文档
  • list_documents: 使用过滤器列出 Frappe 中的文档

模式操作工具

  • get_doctype_schema: 获取 DocType 的完整模式,包括字段定义、验证和链接的 DocTypes
  • get_field_options: 获取 Link 或 Select 字段的可用选项

辅助工具

  • find_doctypes: 在系统中查找匹配搜索词的 DocTypes
  • get_module_list: 获取系统中所有模块的列表
  • get_doctypes_in_module: 获取特定模块中的 DocTypes 列表
  • check_doctype_exists: 检查系统中是否存在 DocType
  • check_document_exists: 检查文档是否存在
  • get_document_count: 获取匹配过滤器的文档计数
  • get_naming_info: 获取 DocType 的命名系列信息
  • get_required_fields: 获取 DocType 的必填字段列表
  • get_api_instructions: 获取使用 Frappe API 的详细指令

常见问题解答

  • 错误处理: 服务器提供详细的错误消息,包括描述性消息、HTTP 状态代码、端点信息和来自 Frappe 服务器的其他详细信息。
  • 最佳实践: 建议在创建或更新文档前检查 DocType 模式,使用分页和指定字段以提高性能,并在更新或删除前检查文档是否存在。

使用教程

使用依赖

  • Node.js 18 或更高版本
  • 运行的 Frappe 实例(版本 15 或更高)
  • Frappe 的 API 密钥和密钥(可选但推荐)

安装教程

  1. 通过 npm 安装:
npm install -g frappe-mcp-server

或者直接使用 npx 运行:

npx frappe-mcp-server

配置

服务器可以通过环境变量配置: - FRAPPE_URL: Frappe 实例的 URL(默认:http://localhost:8000) - FRAPPE_API_KEY: Frappe API 密钥 - FRAPPE_API_SECRET: Frappe API 密钥

获取 API 凭证

  1. 转到 User > API Access > New API Key
  2. 选择要为其创建密钥的用户
  3. 点击“Generate Keys”
  4. 复制 API Key 和 API Secret

启动服务器

npx frappe-mcp-server

或使用环境变量:

FRAPPE_URL=https://your-frappe-instance.com FRAPPE_API_KEY=your_api_key FRAPPE_API_SECRET=your_api_secret npx frappe-mcp-server

调试方式

服务器启动后,可以通过日志和错误消息进行调试。确保所有环境变量正确设置,并且 Frappe 实例可访问。

许可证

该项目遵循 ISC 开源许可条款。