ERPNext MCP 服务器是一个用于 ERPNext 整合的模型上下文协议(Model Context Protocol)服务器。它基于 TypeScript 构建,提供与 ERPNext/Frappe API 集成的功能,能让 AI 助手通过 Model Context Protocol 访问 ERPNext 的数据和功能。
erpnext://{doctype}/{name} URI 访问 ERPNext 文档。authenticate_erpnext:使用用户名和密码认证 ERPNext。get_documents:获取特定文档类型的文档列表。create_document:在 ERPNext 创建新文档。update_document:更新现有文档。run_report:运行 ERPNext 报表。get_doctype_fields:获取特定文档类型字段列表。get_doctypes:获取所有可用文档类型的列表。服务器需要以下环境变量:
ERPNEXT_URL:您的 ERPNext 实例基础 URL。ERPNEXT_API_KEY(可选):API 访问密钥。ERPNEXT_API_SECRET(可选):API 密码。安装依赖项:
npm install
构建服务器:
npm run build
带自动重建的开发:
npm run watch
在 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"
}
}
}
}
将服务器配置添加到:
在 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 服务器通过标准输入输出进行通信,调试可能具有挑战性。我们推荐使用 MCP Inspector,该工具可以通过包脚本运行:
npm run inspector
Inspector 将提供一个浏览器中访问调试工具的 URL。
<use_mcp_tool>
<server_name>erpnextserver_name>
<tool_name>authenticate_erpnexttool_name>
<arguments>
{
"username": "your-username",
"password": "your-password"
}
arguments>
use_mcp_tool>
<use_mcp_tool>
<server_name>erpnextserver_name>
<tool_name>get_documentstool_name>
<arguments>
{
"doctype": "Customer"
}
arguments>
use_mcp_tool>
<use_mcp_tool>
<server_name>erpnextserver_name>
<tool_name>create_documenttool_name>
<arguments>
{
"doctype": "Sales Invoice",
"data": {
"customer": "Test Customer",
"amount": 100
}
}
arguments>
use_mcp_tool>
<use_mcp_tool>
<server_name>erpnextserver_name>
<tool_name:update_document>
{
"doctype": "Sales Invoice",
"name": "INV-001",
"data": {
"amount": 200
}
}
arguments>
use_mcp_tool>
<use_mcp_tool>
<server_name>erpnextserver_name>
<tool_name>run_reporttool_name>
<arguments>
{
"report": "Sales Report",
"filters": {
"from_date": "2023-01-01",
"to_date": "2023-12-31"
}
}
arguments>
use_mcp_tool>
<use_mcp_tool>
<server_name>erpnextserver_name>
<tool_name>get_doctype_fieldstool_name>
<arguments>
{
"doctype": "Sales Invoice"
}
arguments>
use_mcp_tool>
<use_mcp_tool>
<server_name>erpnextserver_name>
<tool_name>get_doctypestool_name>
use_mcp_tool>