將 ERPNext 連接至 AI 智能體:MCP 伺服器真正需要做好的事
Connecting ERPNext to an AI Agent: What an MCP Server Actually Needs to Get Right
ERPNext 的 MCP 整合要在正式環境安全運作,關鍵不在協定本身,而在權限設計。讀取與寫入應設為不同工具,並採用不同審批流程;MCP 伺服器亦應以具備實際角色權限的 ERPNext 用戶進行驗證。具寫入權限的 AI 智能體需要在上線前及每次變更後接受情境測試。
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:
- Read vs. write is a different trust boundary, not a toggle
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.
- The MCP server should authenticate as a real ERPNext user, not a service account with blanket access
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.
- Evals matter more here than in a typical chatbot
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.
來源:DEV Community · dev.to