ERPNext MCP Server

ERPNext MCP Server

This MCP server connects ChatGPT to ERPNext, enabling AI-powered business analytics, report generation, and document management.

Category
访问服务器

README

ERPNext MCP Server for ChatGPT

A complete Model Context Protocol (MCP) integration that connects ChatGPT to your ERPNext instance, enabling AI-powered business analytics, report generation, and document management.

What This Does

This integration allows ChatGPT to:

  • Generate financial reports (P&L, Balance Sheet, Cash Flow)
  • Analyze sales trends and customer data
  • Check inventory and stock levels
  • Access HR and employee information
  • Create and update ERPNext documents
  • Build custom dashboards and visualizations

Project Structure

/home/frappe/test.bench/apps/erp_chatbot/
├── erp_chatbot/
│   ├── api.py                    # Main API endpoints
│   ├── mcp_server_sse.py         # Standalone MCP server with SSE transport
│   └── hooks.py                  # Frappe app hooks
├── chatgpt_openapi.yaml          # OpenAPI schema for ChatGPT Actions
├── chatgpt_gpt_instructions.md   # GPT behavior instructions
├── QUICK_START.md               # 5-minute setup guide
├── API_KEY_SETUP.md             # Authentication troubleshooting
└── pyproject.toml               # Dependencies

Quick Start (5 Minutes)

Step 1: Install Dependencies

cd /home/frappe/test.bench
./env/bin/pip install mcp sse-starlette starlette uvicorn

Step 2: Get ERPNext API Key

  1. Login to ERPNext as Administrator
  2. Go to User → API Access
  3. Click Generate Keys
  4. Copy API Key and API Secret

Step 3: Create ChatGPT GPT

  1. Go to chat.openai.com
  2. Click Explore GPTs → Create
  3. Name: ERPNext Assistant

Step 4: Configure GPT

Instructions Tab:

  • Copy contents from chatgpt_gpt_instructions.md
  • Paste in Instructions box

Actions Tab:

  1. Click Add actions
  2. Import schema: chatgpt_openapi.yaml
  3. Authentication:
    • Type: API Key
    • Key: Authorization
    • Value: Bearer YOUR_API_KEY:YOUR_API_SECRET
    • Auth Type: Bearer

Step 5: Test

Ask your GPT:

"What companies are available?"
"Show me this month's sales"

Available API Endpoints

Public Endpoints (No Auth Required)

Endpoint Method Description
/api/method/erp_chatbot.api.mcp_chatgpt_tools GET List all available tools

Authenticated Endpoints

Endpoint Method Description
/api/method/erp_chatbot.api.mcp_chatgpt_execute POST Execute MCP tools
/api/method/erp_chatbot.api.get_financial_analysis GET P&L and financial reports
/api/method/erp_chatbot.api.get_sales_dashboard GET Sales analytics dashboard
/api/method/erp_chatbot.api.get_inventory_summary GET Inventory overview
/api/method/erp_chatbot.api.generate_chart POST Create data visualizations
/api/method/erp_chatbot.api.create_report POST Build custom reports
/api/method/erp_chatbot.api.get_dashboard_kpis GET Key performance indicators

Available Tools

Reporting Tools

  • get_report_data - Execute standard ERPNext reports
  • get_sales_analytics - Sales trends with date filtering
  • get_financial_analysis - P&L statements with charts

Data Query Tools

  • get_list_data - Query any DocType with filters
  • get_document - Fetch single document
  • get_companies - List available companies
  • get_inventory_summary - Stock levels and overview

Document Management

  • create_document - Create new ERPNext records
  • update_document - Modify existing records

Analytics & Visualization

  • generate_chart - Create bar, pie, line charts
  • create_report - Build custom reports
  • get_dashboard_kpis - Business KPIs

Authentication

API Key Format

Authorization: Bearer api_key:api_secret

Example:

Authorization: Bearer d4e8f2c1b5a9:8f3e2d1c9b7a5f4e

Getting API Keys

  1. ERPNext → Users → Select your user
  2. Scroll to API Access section
  3. Click Generate Keys
  4. Save both API Key and API Secret

Important: API Secret is shown only once. Save it immediately!

Standalone MCP Server

Run the MCP server independently:

cd /home/frappe/test.bench
./env/bin/python apps/erp_chatbot/erp_chatbot/mcp_server_sse.py

Server starts on http://localhost:8000

Endpoints

  • GET /mcp/sse - SSE connection
  • POST /mcp/messages - MCP messages
  • GET /health - Health check

Usage Examples

Query Sales Data

{
  "tool": "get_list_data",
  "arguments": {
    "doctype": "Sales Invoice",
    "filters": {"status": "Overdue"},
    "fields": ["name", "customer", "grand_total"],
    "limit": 20
  }
}

Create a Customer

{
  "tool": "create_document",
  "arguments": {
    "doctype": "Customer",
    "data": {
      "customer_name": "New Customer Ltd",
      "customer_type": "Company",
      "territory": "Pakistan"
    }
  }
}

Generate P&L Report

{
  "tool": "get_report_data",
  "arguments": {
    "report_name": "Profit and Loss Statement",
    "filters": {
      "company": "Your Company",
      "fiscal_year": "2024-2025"
    }
  }
}

Create a Chart

{
  "chart_type": "bar",
  "labels": ["Jan", "Feb", "Mar", "Apr"],
  "values": [10000, 15000, 12000, 18000],
  "title": "Monthly Sales"
}

Troubleshooting

401 Authentication Error

  • Verify API Key format: Bearer key:secret (with colon)
  • Check user has proper permissions
  • Ensure API keys are generated correctly

Tools Not Showing

  • Refresh schema in ChatGPT Actions
  • Check chatgpt_openapi.yaml is properly uploaded
  • Verify server URL is correct

Connection Failed

  • Check ERPNext server is running
  • Verify domain URL in schema
  • Test endpoint directly in browser

Support

For issues:

  1. Check Frappe logs: bench --site yoursite.com logs
  2. Verify API permissions
  3. Test endpoints directly:
    https://yoursite.com/api/method/erp_chatbot.api.mcp_chatgpt_tools
    

Files Reference

File Purpose
chatgpt_openapi.yaml OpenAPI schema for ChatGPT
chatgpt_gpt_instructions.md GPT behavior configuration
api.py Backend API endpoints
mcp_server_sse.py Standalone MCP server
QUICK_START.md Quick setup guide
API_KEY_SETUP.md Auth troubleshooting

Security Notes

  • Keep API keys secret and secure
  • Use HTTPS in production
  • Regularly rotate API keys
  • Grant minimum required permissions

Ready to Use!

Your ChatGPT is now connected to ERPNext. Start asking business questions!

Example queries:

  • "Show me overdue invoices"
  • "What's our inventory status?"
  • "Create a sales order for ABC Corp"
  • "Generate P&L for Q1 2024"

Built for test.bench / erp.site.com

Created by Ibni for ERPNext MCP Server

License

mit

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选