Skip to main content

ERPNext and Frappe REST/RPC MCP Server for Agentic AI!

Project description

Erpnext MCP

Status Version License

ERPNext and Frappe Framework enterprise resources planner. Built with the highest architectural standards, incorporating dynamic facades, custom API routing, and FastMCP tool decoration.

Table of Contents


Overview

Erpnext MCP provides a high-performance, model-optimized interface to Erpnext capabilities. It isolates the model from underlying API transport complexity, ensuring safe, idempotent, and highly traceable system interactions.


Features

  • Dynamic Facade Orchestration: Integrates multi-inheritance clients cleanly under a single facade.
  • Battle-Tested Resilience: Out-of-the-box credential authentication, connection polling, and request retry strategies.
  • FastMCP Declarative Tools: Fast, native schema registration with full inline validation.
  • Complete Test Intent Diversity: Deep, automated unit, integration, and mock tests ensuring high code coverage.

⚙️ Dynamic Tool Selection & Visibility

This MCP server supports dynamic toolset selection and visibility filtering at runtime. This allows you to restrict the set of exposed tools in order to prevent blowing up the LLM's context window.

You can configure tool filtering via multiple input channels:

  • CLI Arguments: Pass --tools or --toolsets (or their disabled counterparts --disabled-tools and --disabled-toolsets) during startup.
  • Environment Variables: Define standard environment variables:
    • MCP_ENABLED_TOOLS / MCP_DISABLED_TOOLS
    • MCP_ENABLED_TAGS / MCP_DISABLED_TAGS
  • HTTP SSE Request Headers: Pass custom headers during transport initialization:
    • x-mcp-enabled-tools / x-mcp-disabled-tools
    • x-mcp-enabled-tags / x-mcp-disabled-tags
  • HTTP SSE Request Query Parameters: Append query parameters directly to your transport connection URL:
    • ?tools=tool1,tool2
    • ?tags=tag1

When query strings or parameters are supplied, an LLM-free Knowledge Graph resolution layer (using DynamicToolOrchestrator) matches query intents against known tool tags, names, or descriptions, with safe fallback and automated 24-hour background cache refreshing.


Installation

Install in editable mode directly inside your active workspace:

pip install -e .[all]

Or via the uv tool:

uv pip install -e .

Usage

You can launch the FastMCP server in stdio mode via Python module execution:

import asyncio
from erpnext_agent.mcp_server import get_mcp_instance

async def main():
    mcp = get_mcp_instance()
    # Execute stdio loop or launch server
    print("MCP Server ready.")

if __name__ == "__main__":
    asyncio.run(main())

For direct shell launch, execute:

python -m erpnext_agent.mcp_server

Configuration

The package is fully configurable via the environment variables listed below:

Variable Description Default Required
ERPNEXT_URL ERPNext / Frappe server endpoint URL http://localhost:8000 Yes
ERPNEXT_TOKEN API authentication token (api_key:api_secret) your_api_key:your_api_secret Yes

A local template is supplied inside .env.example. Copy this file as .env and fill out your specific service endpoint parameters before starting execution.


MCP Tools

The following declarative FastMCP tools are registered and available to upstream AI agents:

Tool Name Description Parameters
get_document Get specific Frappe/ERPNext document by doctype and name doctype: str, name: str
create_document Create new Frappe/ERPNext document doctype: str, data: dict
call_method Call a whitelisted ERPNext RPC method method: str, params: dict = None

See docs/overview.md or docs/concepts.md for deeper operational examples.


Architecture

This package uses the standardized Agent-Utilities dynamic facade architecture:

graph TD
    User([User Agent]) --> Server[FastMCP Server]
    Server --> Facade[Api Dynamic Facade]
    Facade --> ClientBase[ApiClientBase]
    Facade --> Auth[Credentials Auth Handler]
    ClientBase --> Service([External Service API])

Deployment

Bare-Metal (Standard pip)

  1. Set up your Python virtual environment (>= 3.10).
  2. Install the package: pip install .[all]
  3. Export credentials:
    export ERPNEXT_URL="http://localhost:8000"
    
  4. Run: python -m erpnext_agent.mcp_server

Container (Docker Compose)

A standard compose structure is provided inside the docker/ folder. Build and deploy:

docker compose -f docker/compose.yml up --build -d

Contributing

Please audit all code changes against ecosystem guidelines in CONTRIBUTING.md if available, and run:

pre-commit run --all-files

License

This project is licensed under the MIT License. See the LICENSE file for complete details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erpnext_agent-0.23.2.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

erpnext_agent-0.23.2-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file erpnext_agent-0.23.2.tar.gz.

File metadata

  • Download URL: erpnext_agent-0.23.2.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for erpnext_agent-0.23.2.tar.gz
Algorithm Hash digest
SHA256 c56a84124dcdb074905961cd1e89282cef93c26f3d4c4a99d7fe4d3b953763e0
MD5 50fb0792e903e2edafde88070ba5db18
BLAKE2b-256 ae58e5e5cb9a52e9be33d1724e77181edcf74afbd903ca7d80b249c7cd925b65

See more details on using hashes here.

File details

Details for the file erpnext_agent-0.23.2-py3-none-any.whl.

File metadata

  • Download URL: erpnext_agent-0.23.2-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for erpnext_agent-0.23.2-py3-none-any.whl
Algorithm Hash digest
SHA256 62a57e08c67b91638f35022301634cfeca73dfb3b4493d8f58ccff7780f90ef7
MD5 ed0f8e1e85a04f92a33f1746ddff02a9
BLAKE2b-256 0fdff587534299ce0e07db5786d36fbbd3fb70053c5d9c81319134d179e13254

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page