MCP server
ERP DLM exposes an MCP (Model Context Protocol) server at /api/mcp that allows AI assistants to query ERP data in read-only mode.
What is MCP?
Section titled “What is MCP?”MCP is an open protocol for connecting language models with external data sources and tools. Through the MCP server, an assistant can:
- List sales and purchase invoices.
- Query customers, suppliers and products.
- View the chart of accounts, journal entries and balances.
- Get a treasury snapshot and bank movements.
Available transports
Section titled “Available transports”HTTP SSE (production / cloud)
Section titled “HTTP SSE (production / cloud)”Mounted inside the FastAPI application:
GET /api/mcp/sse— Server-Sent Events connection.POST /api/mcp/messages/— JSON-RPC message endpoint.
The mount is wired directly in backend/app/main.py through _McpBypassApp, preventing FastAPI middleware from breaking streaming responses.
stdio (local)
Section titled “stdio (local)”For local usage with Hermes or other stdio MCP clients:
cd backend. .venv/bin/activatepython mcp_server.pyTo require authentication in stdio as well, export MCP_AUTH_TOKEN.
Authentication
Section titled “Authentication”The HTTP transport requires the header Authorization: Bearer <token>. The token is SHA-256 hashed and looked up in api_tokens; it must be active, not expired, and have at least one api_access rule with:
resource_name = 'mcp'(global access), orresource_name = '*'(wildcard), or- the concrete scope of the tool (e.g.
mcp:invoices).
For the stdio transport, if MCP_AUTH_TOKEN is not exported, the server allows unlimited local access (useful for mono-tenant development).
Multi-tenant
Section titled “Multi-tenant”The company_id field of api_tokens determines which company data the assistant sees. If it is NULL, all companies are queried (default behaviour in single-company installations). For SaaS multi-tenant it is recommended to set company_id on every token.
Exposed tools
Section titled “Exposed tools”The server exposes 13 read-only tools:
| Tool | Scope | Description | Main parameters |
|---|---|---|---|
list_invoices |
mcp:invoices |
Sales invoices | status, date_from, date_to, client_id, paid, limit, offset |
get_invoice |
mcp:invoices |
Sales invoice detail | invoice_id or document_number |
list_purchase_invoices |
mcp:purchase_invoices |
Purchase invoices | status, date_from, date_to, supplier_id, paid, limit, offset |
get_purchase_invoice |
mcp:purchase_invoices |
Purchase invoice detail | invoice_id or document_number |
list_contacts |
mcp:contacts |
Customers and/or suppliers | contact_type, search, is_active, limit, offset |
get_contact |
mcp:contacts |
Contact detail | contact_id |
list_products |
mcp:products |
Products | search, family_code, is_active, limit, offset |
get_product |
mcp:products |
Product detail | product_id or reference |
list_accounts |
mcp:accounting |
Chart of accounts | fiscal_year_code, is_active, limit, offset |
get_account_balance |
mcp:accounting |
Account balance | account_code, fiscal_year_code |
list_journal_entries |
mcp:accounting |
Journal entries | fiscal_year_code, date_from, date_to, limit, offset |
get_cash_flow |
mcp:treasury |
Treasury snapshot | — |
list_bank_movements |
mcp:banking |
Bank movements | status, date_from, date_to, limit, offset |
Claude Desktop configuration example
Section titled “Claude Desktop configuration example”{ "mcpServers": { "erp-dlm": { "command": "npx", "args": ["-y", "@anthropic-ai/mcp-sse-proxy"], "env": { "SSE_URL": "https://erp.ovlicuo.com/api/mcp/sse", "MCP_AUTHORIZATION": "Bearer tok-..." } } }}More information
Section titled “More information”- Official MCP documentation
- ERP DLM REST API
- Implementation file:
backend/app/modules/mcp_server/server.py - SQL queries:
backend/app/modules/mcp_server/queries.py - MCP authentication:
backend/app/modules/mcp_server/auth.py