ERPNext集成的Model Context Protocol服务器
这是一个基于TypeScript的MCP服务器,提供与ERPNext/Frappe API的集成。它使AI助手能够通过Model Context Protocol与ERPNext的数据和功能进行交互。
erpnext://{doctype}/{name}URI访问ERPNext文档authenticate_erpnext - 使用用户名和密码对ERPNext进行身份验证get_documents - 获取特定文档类型的一系列文档create_document - 在ERPNext中创建新文档update_document - 更新ERPNext中的现有文档run_report - 运行ERPNext报告get_doctype_fields - 获取特定DocType的字段列表get_doctypes - 获取所有可用DocType的列表该服务器需要以下环境变量:
ERPNEXT_URL - 您的ERPNext实例的基本URLERPNEXT_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_m_备案设置.json
由于MCP服务器通过标准I/O通信,调试可能会很困难。我们推荐使用MCP Inspector,它作为一个包脚本提供:
npm run inspector
Inspector将提供一个URL,您可以在浏览器中访问调试工具。
<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>authenticate_erpnext</tool_name>
<arguments>
{
"username": "your-username",
"password": "your-password"
}
</arguments>
</use_mcp_tool>
<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": "测试项目",
"item_group": "产品",
"stock_uom": "个"
}
}
</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>