NOVA MCP Server
NOVA MCP Server
只读的 Model Context Protocol 服务器,暴露演示公司 NOVA(Dolibarr 23.0.3)的会计和商业数据,供 AI 助手通过 Cowork 进行渐进式调查。完整规范见 spec-final.md。
架构
Auth(
app/auth/):Keycloak JWT 验证(通过PyJWKClient的 JWKS)、身份解析(iss, sub)、CredentialStore(本地 YAML)将每个用户映射到 Dolibarr API 密钥、中间件credential_gate(身份未映射时返回 403)。Dolibarr(
app/dolibarr/):用于 Dolibarr 标准 REST API(第三方、发票、付款、银行)的集中式 HTTP 客户端(持久连接池、有限重试、Decimal 转换)。NOVA 配套模块(
dolibarr-module/):会计科目表和总账不由 Dolibarr 标准 API 暴露——见下文专门章节。隐私层(
app/privacy/):将任何第三方身份替换为稳定的技术引用(THIRDPARTY:<id>等),由服务系统性地应用。Domain(
app/domain/):独立于任何框架的确定性会计规则(EBITDA、账龄、分页、验证)。Services(
app/services/):业务逻辑,每个领域一个模块。MCP(
app/mcp_server/):MCP 服务器(Anthropic 官方 SDK),按领域的工具,集中的错误翻译 + 日志记录装饰器(errors.py)。
Related MCP server: NuMetric MCP Server
为什么需要 Dolibarr 配套模块?
Dolibarr 23.0 的标准 REST API 不暴露任何用于会计科目表或总账的端点(唯一的原生入口 GET /accountancy/exportdata 在服务器端写入文件,但不在 HTTP 响应中返回)。dolibarr-module/nova/ 在相同的原生 REST 机制(DOLAPIKEY、应用权限)下添加了两个只读端点(GET /nova/accounts、GET /nova/bookkeeping)。该模块单独安装在 Dolibarr NOVA 实例上——见 dolibarr-module/README.md。
本地启动
uv sync --extra dev
cp .env.example .env # renseigner OIDC_ISSUER, CREDENTIAL_STORE_PATH, DOLIBARR_API_URL
cp credentials/credentials.example.yaml credentials/credentials.yaml # ne pas versionner
uv run uvicorn app.main:app --reloadGET /health/live、GET /health/ready:健康检查(无需认证)。POST /mcp:MCP 端点(Streamable HTTP)。
测试
uv run pytest # suite complète (couverture terminal + coverage.xml)
uv run pytest --cov=app --cov-report=html无需数据库:测试使用 DolibarrClient 的测试替身(tests/fixtures/),没有 PostgreSQL/NullPool fixtures。
Docker
docker compose up --buildCredentialStore 以只读方式挂载(./credentials:/app/credentials:ro)——切勿将 credentials/credentials.yaml 纳入版本控制。
Dolibarr NOVA 端前置条件
安装
dolibarr-module/nova/(见其 README)。为每位审计员:创建专用的 Dolibarr 用户,生成其
DOLAPIKEY,授予通过 NOVA API 读取会计科目表和总账的权限,然后将其条目添加到credentials/credentials.yaml(包含其 Keycloak 令牌的sub)——重启 MCP 服务器以生效(无热重载,H2)。对于
get_company:为每个使用的登录名填写 Dolibarr 常量API_LOGINS_ALLOWED_FOR_GET_COMPANY(或授予管理员权限)——否则该特定工具会因上游 403 错误而失败(预期行为)。
Related MCP Connectors
Query your books, company data, business health, and ship invoices from your AI assistant.
AI accounting: ask about your live AccountsOS books in plain English. Read-only tools for transactions, cash balances, invoices, bills, VAT, filing deadlines and reports across 32 countries. OAuth sign-in; free 14-day trial at accounts-os.com.
Odoo MCP connector for ChatGPT and Claude: ask sales, invoices and stock in plain words. Read-only.
Read-only by architecture: ask AI about QuickBooks, Xero and NetSuite, across every entity.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive interaction with ERPNext systems through natural language, providing secure access to any document type (customers, items, invoices, etc.) with enterprise-grade permission controls and audit logging.MIT
- AlicenseNot gradedqualityCmaintenanceA read-only MCP server for the NuMetric.work accounting/POS/ERP platform, exposing 38 tools to query live business data such as financial statements, invoices, taxes, projects, inventory, and documents. It enables AI assistants to answer from real accounting data without any create, edit, or delete capabilities.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to natively interact with Dolibarr ERP/CRM through its REST API, providing over 30 tools for managing customers, contacts, products, quotes, orders, invoices, stock, projects, contracts, interventions, and PDF generation, while supporting complex workflow orchestration and read-only security modes.MIT
- AlicenseBqualityBmaintenanceEnables read-only access to Merit Aktiva accounting data, including customers, vendors, sales invoices, accounts, payments, and taxes, through natural language MCP tools.771MIT