# Connecting ERPNext to an AI Agent: What an MCP Server Actually Needs to Get Right

> Source: <https://dev.to/himalay_patel_b249bcb3cd4/connecting-erpnext-to-an-ai-agent-what-an-mcp-server-actually-needs-to-get-right-42ln>
> Published: 2026-11-26 08:32:42+00:00

**Recommendation:** Split read and write ERPNext tools into separate definitions with their own approval paths, and enforce access through a scoped user's native Frappe roles rather than a superuser proxy.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

Model Context Protocol (MCP) servers are becoming the standard way to connect AI assistants like Claude or ChatGPT to real business systems — and ERPNext is a natural candidate, since so much of a company's operational truth (orders, stock, customers, invoices) already lives there.

The part that's easy to get wrong isn't the protocol itself. It's permissions.

A naive ERPNext MCP integration gives an AI assistant the same access as an admin user — read and write across every doctype. That's a fast way to ship a demo and a slow way to cause an incident, because the moment the assistant can act (not just answer questions), every mistake it makes is a mistake made in your live ERP data.

The three things we've found actually matter when building these integrations in production:

An MCP tool that reads a customer's order history is low-risk. A tool that creates a sales invoice or triggers a payment is not — and it shouldn't live behind the same permission check. We scope these as genuinely separate tool definitions with separate approval paths, not a single "erpnext_action" tool with a parameter for what kind of action.

ERPNext's own role-based permissions are the right place to enforce "can this assistant touch payroll data" — re-implementing that logic in the MCP layer is how permission bugs get introduced. The server should sit between the AI client and the Frappe REST API, passing through a scoped user's actual role permissions rather than acting as a superuser proxy.

When an assistant can only answer questions, a wrong answer is a mildly bad experience. When it can act on ERPNext — issue a refund, adjust stock, approve a purchase order — you need a test suite that runs the agent through real scenarios before launch and re-runs on every change, the same discipline you'd apply to any system with write access to financial data.

None of this is unique to ERPNext — it's the general shape of "connect an AI agent to a system of record" — but ERPNext's specific role/permission model (and the fact that most installs have years of custom doctypes layered on top) makes the read/write distinction especially easy to blur if you're not deliberate about it.

We've built several of these integrations for manufacturing and trading businesses moving off Tally and spreadsheets, and the permission design is consistently where the real engineering effort goes — not the MCP boilerplate itself.

Written by the team at AGI Software Solutions, an AI development studio building AI agents, voice AI, and ERPNext/CRM integrations.
