ERPNext集成服务器

一个基于TypeScript的MCP服务器,提供与ERPNext/Frappe API的集成,使AI助手能够通过模型上下文协议与ERPNext数据和功能交互。

  • by rakeshgangwar
  • JavaScript
  • 本地部署
  • 126 星标
  • 更新于
在 GitHub 查看 rakeshgangwar/erpnext-server

使用说明

ERPNext MCP服务器

ERPNext集成的模型上下文协议服务器

这是一个基于类型脚本的MCP服务器,提供与ERPNext/Frappe API的集成。它使AI助手能够通过模型上下文协议与ERPNext数据和功能进行交互。

特性

资源

  • 通过以下方式访问ERPNext文档 erpnext://{doctype}/{name} 尤里斯
  • 用于结构化数据访问的JSON格式

工具

  • get_doctypes -获取所有可用DocType的列表
  • get_doctype_fields -获取特定DocType的字段列表
  • get_documents -获取特定doctype的文档列表
  • get_document -按名称获取单个文档,包括所有子表
  • create_document -在ERPNext中创建新文档
  • update_document -更新ERPNext中的现有文档
  • delete_document -永久删除文档
  • submit_document -提交文档(将docstatus设置为1)
  • cancel_document -取消已提交的文档(将docstatus设置为2)
  • call_method -调用ERPNext/Frappe白名单服务器端API方法
  • run_report -运行ERPNext报告

配置

服务器需要以下环境变量:

  • ERPNEXT_URL -ERPNext实例的基本URL
  • ERPNEXT_API_KEY (可选)-用于身份验证的API密钥
  • ERPNEXT_API_SECRET (可选)-用于身份验证的API机密

发展

安装依赖项:

npm install

构建服务器:

npm run build

对于自动重建的开发:

npm run watch

安装

要与Claude Desktop一起使用,请添加服务器配置:

在MacOS上: ~/Library/Application Support/Claude/claude_desktop_config.json 在Windows上: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "erpnext": {
      "command": "node",
      "args": ["/path/to/erpnext-server/build/index.js"],
      "env": {
        "ERPNEXT_URL": "http://your-erpnext-instance.com",
        "ERPNEXT_API_KEY": "your-api-key",
        "ERPNEXT_API_SECRET": "your-api-secret"
      }
    }
  }
}

要在VSCode中与Claude一起使用,请将服务器配置添加到:

在MacOS上: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json 在Windows上: %APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

调试

由于MCP服务器通过stdio进行通信,调试可能具有挑战性。我们建议使用 MCP检查员,可作为包脚本使用:

npm run inspector

检查器将提供一个URL,用于访问浏览器中的调试工具。

用法示例

获取客户列表

<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>get_documents</tool_name>
<arguments>
{
  "doctype": "Customer"
}
</arguments>
</use_mcp_tool>

获取客户详细信息

<access_mcp_resource>
<server_name>erpnext</server_name>
<uri>erpnext://Customer/CUSTOMER001</uri>
</access_mcp_resource>

创建新项目

<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>create_document</tool_name>
<arguments>
{
  "doctype": "Item",
  "data": {
    "item_code": "ITEM001",
    "item_name": "Test Item",
    "item_group": "Products",
    "stock_uom": "Nos"
  }
}
</arguments>
</use_mcp_tool>

获取项目字段

<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>get_doctype_fields</tool_name>
<arguments>
{
  "doctype": "Item"
}
</arguments>
</use_mcp_tool>