Skip to content

Kai-Oesterling/erpnext-mcp-server-extended

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ERPNext MCP Server Extended

Extended MCP (Model Context Protocol) Server for ERPNext with:

  • πŸ”§ Improved Error Handling - Returns detailed ERPNext error messages instead of generic failures
  • πŸ“‹ Workflow Management - Create and manage approval workflows
  • πŸ”— Custom Fields - Add custom fields that survive ERPNext updates
  • πŸ“¦ DocType Creation - Create new DocTypes programmatically
  • πŸ”„ Document Lifecycle - Submit, cancel, and delete documents

πŸš€ Quick Start

Installation

git clone https://github.com/Kai-Oesterling/erpnext-mcp-server-extended.git
cd erpnext-mcp-server-extended
npm install
npm run build

Configuration

Set environment variables:

export ERPNEXT_URL="https://your-erpnext-instance.com"
export ERPNEXT_API_KEY="your-api-key"
export ERPNEXT_API_SECRET="your-api-secret"
export ERPNEXT_DEBUG="true"  # Optional: Enable debug logging

Claude Desktop Configuration

Add to claude_desktop_config.json:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

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

πŸ”§ Improved Error Handling

Before (Original)

Tool execution failed

or

Failed to create Fiscal Year: Request failed with status code 417

After (Extended)

Failed to create Fiscal Year (HTTP 417): ValidationError: Companies is required for Fiscal Year

The extended server extracts detailed error information from:

  • _server_messages - JSON-encoded array of server messages
  • exception - Python exception details
  • exc_type - Exception type (ValidationError, MandatoryError, etc.)
  • message - Human-readable error message

πŸ“š Available Tools

Core Operations

Tool Description
authenticate_erpnext Authenticate with username/password
get_documents List documents with filtering
get_document Get single document
create_document Create new document
update_document Update existing document
delete_document Delete a document

Document Lifecycle

Tool Description
submit_document Submit document (Draft β†’ Submitted)
cancel_document Cancel submitted document

DocType Operations

Tool Description
get_doctypes List all DocTypes
get_doctype_fields Get field definitions
get_doctype_meta Get complete metadata
create_doctype Create new DocType
add_doctype_field Add field to DocType

Workflow Management

Tool Description
get_workflow Get active workflow for DocType
create_workflow Create new workflow
update_workflow Modify existing workflow

Customization

Tool Description
create_custom_field Add custom field (survives updates)
create_property_setter Override DocType/field properties

Reports

Tool Description
run_report Execute ERPNext report

πŸ’‘ Usage Examples

Create a Document

Create a new Customer named "ACME Corp" with customer_group "Commercial"

Create a Workflow

Create an approval workflow for Purchase Order:
- Draft β†’ Pending Approval (Submit action, Purchase User)
- Pending Approval β†’ Approved (Approve action, Purchase Manager)  
- Pending Approval β†’ Rejected (Reject action, Purchase Manager)

Add Custom Field

Add a custom field "priority" (Select: Low/Medium/High) to the Customer DocType

Create DocType

Create a DocType called "Project Task" with fields:
- task_name (Data, required)
- status (Select: Open/In Progress/Completed)
- assigned_to (Link to User)
- due_date (Date)

πŸ› Debug Mode

Enable debug mode to see detailed API requests and responses:

export ERPNEXT_DEBUG=true

This will log:

  • All API requests with URLs and parameters
  • All API responses with status codes and data
  • Detailed error information

πŸ” Authentication

Option 1: API Key (Recommended)

Set ERPNEXT_API_KEY and ERPNEXT_API_SECRET environment variables.

Generate API keys in ERPNext:

  1. Go to User settings
  2. Click "API Access"
  3. Generate new keys

Option 2: Username/Password

Use the authenticate_erpnext tool at runtime:

Authenticate with ERPNext using username "admin" and password "..."

πŸ“¦ ERPNext API Key Setup

  1. Login to ERPNext as Administrator
  2. Go to Settings β†’ User
  3. Select your user
  4. Scroll to API Access section
  5. Click Generate Keys
  6. Copy the API Key and API Secret

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT License - see LICENSE file.

πŸ™ Credits

About

Extended MCP Server for ERPNext with workflow, custom fields and DocType creation support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors