The ERPNext MCP Server is a TypeScript-based implementation of the Model Context Protocol that allows AI assistants to interact with ERPNext data and functionality. It provides a bridge between AI assistants and your ERPNext instance, enabling seamless access to documents, reports, and other ERPNext features.
The server requires the following environment variables:
ERPNEXT_URL
- The base URL of your ERPNext instanceERPNEXT_API_KEY
(optional) - API key for authenticationERPNEXT_API_SECRET
(optional) - API secret for authenticationTo use with Claude Desktop, add the server configuration to Claude's config file:
On MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
On Windows:
%APPDATA%/Claude/claude_desktop_config.json
Add the following configuration:
{
"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"
}
}
}
}
Add the server configuration to:
On MacOS:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
On Windows:
%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Authenticate with your ERPNext credentials:
<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>
Retrieve a list of documents for a specific DocType:
<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>get_documents</tool_name>
<arguments>
{
"doctype": "Customer"
}
</arguments>
</use_mcp_tool>
Access a specific document using its URI:
<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>update_document</tool_name>
<arguments>
{
"doctype": "Item",
"name": "ITEM001",
"data": {
"description": "Updated description"
}
}
</arguments>
</use_mcp_tool>
Retrieve the field definitions for a specific DocType:
<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>get_doctype_fields</tool_name>
<arguments>
{
"doctype": "Item"
}
</arguments>
</use_mcp_tool>
List all available DocTypes in the ERPNext instance:
<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>get_doctypes</tool_name>
<arguments>{}</arguments>
</use_mcp_tool>
Execute an ERPNext report:
<use_mcp_tool>
<server_name>erpnext</server_name>
<tool_name>run_report</tool_name>
<arguments>
{
"report_name": "Accounts Receivable",
"filters": {
"company": "Your Company"
}
}
</arguments>
</use_mcp_tool>
For troubleshooting, you can use the MCP Inspector:
npm run inspector
This will provide a URL to access debugging tools in your browser, which is helpful since MCP servers communicate over stdio making traditional debugging challenging.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.