MCP proxy for Microsoft Dynamics 365 Business Central with OAuth2 client credentials (daemon) authentication
Project description
bc-mcp-proxy-daemon
Proxy MCP (Model Context Protocol) para Microsoft Dynamics 365 Business Central con autenticación OAuth2 Client Credentials (service principal / daemon).
Actúa como puente entre clientes MCP stdio (como Claude Code) y el endpoint MCP de Business Central, gestionando automáticamente la obtención y renovación de tokens OAuth2 mediante MSAL.
Requisitos
- Python >= 3.11
- Un App Registration en Azure AD con permisos para Business Central
- Credenciales:
tenant_id,client_id,client_secret
Instalación
pip install bc-mcp-proxy-daemon
Desde el código fuente:
git clone git@github.com:BlackCoronel/bc-mcp-proxy-daemon.git
cd bc-mcp-proxy-daemon
pip install -e .
Configuración
Todos los parámetros se pueden configurar por argumentos CLI o variables de entorno. Los argumentos CLI tienen prioridad sobre las variables de entorno.
Parámetros obligatorios
| CLI | Variable de entorno | Descripción |
|---|---|---|
--TenantId |
BC_TENANT_ID |
Azure AD tenant ID |
--ClientId |
BC_CLIENT_ID |
Application (client) ID del App Registration |
--ClientSecret |
BC_CLIENT_SECRET |
Client secret del App Registration |
Parámetros opcionales
| CLI | Variable de entorno | Default | Descripción |
|---|---|---|---|
--Company |
BC_COMPANY |
— | Nombre de la empresa en BC |
--Environment |
BC_ENVIRONMENT |
Production |
Entorno de BC (Production, Sandbox, etc.) |
--ConfigurationName |
BC_CONFIGURATION_NAME |
— | Nombre de configuración MCP en BC |
--BaseUrl |
BC_BASE_URL |
https://api.businesscentral.dynamics.com |
URL base de la API |
--TokenScope |
BC_TOKEN_SCOPE |
https://api.businesscentral.dynamics.com/.default |
Scope OAuth2 |
--CustomAuthHeader |
BC_CUSTOM_AUTH_HEADER |
— | Token bearer estático (omite OAuth2) |
--ServerName |
BC_SERVER_NAME |
BcMCPProxyPython |
Nombre del servidor MCP local |
--ServerVersion |
BC_SERVER_VERSION |
0.2.0 |
Versión del servidor MCP local |
--Instructions |
BC_INSTRUCTIONS |
— | Instrucciones personalizadas para el servidor MCP |
--HttpTimeoutSeconds |
BC_HTTP_TIMEOUT_SECONDS |
30 |
Timeout para peticiones HTTP |
--SseTimeoutSeconds |
BC_SSE_TIMEOUT_SECONDS |
300 |
Timeout para conexiones SSE |
--LogLevel |
BC_LOG_LEVEL |
INFO |
Nivel de log (DEBUG, INFO, WARNING, ERROR) |
--Debug |
BC_DEBUG |
false |
Activa logs de depuración |
Uso
Ejecución directa
python -m bc_mcp_proxy \
--TenantId "tu-tenant-id" \
--ClientId "tu-client-id" \
--ClientSecret "tu-client-secret" \
--Company "CRONUS España S.A." \
--Environment Production
Con variables de entorno
export BC_TENANT_ID="tu-tenant-id"
export BC_CLIENT_ID="tu-client-id"
export BC_CLIENT_SECRET="tu-client-secret"
export BC_COMPANY="CRONUS España S.A."
export BC_ENVIRONMENT="Production"
python -m bc_mcp_proxy
Integración con Claude Code
Añade el proxy como servidor MCP en tu configuración de Claude Code (.claude/settings.json o similar):
{
"mcpServers": {
"bc": {
"command": "python",
"args": [
"-m", "bc_mcp_proxy",
"--TenantId", "tu-tenant-id",
"--ClientId", "tu-client-id",
"--ClientSecret", "tu-client-secret",
"--Company", "CRONUS España S.A.",
"--Environment", "Production"
]
}
}
}
Arquitectura
Claude Code (stdio) ←→ bc-mcp-proxy (stdio server) ←→ Business Central (Streamable HTTP)
│
MSAL OAuth2
(client credentials)
proxy.py— Servidor MCP stdio que reenvíalist_toolsycall_toolal endpoint remoto de BCauth.py— Proveedores de tokens:MsalClientCredentialsTokenProvider(OAuth2) oStaticTokenProvider(bearer fijo)config.py— Dataclass con toda la configuración del proxy__main__.py— CLI parser y entry point
Dependencias
mcp>= 1.0 — SDK del Model Context Protocolmsal>= 1.28.0 — Microsoft Authentication Libraryhttpx>= 0.27 — Cliente HTTP async
Licencia
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bc_mcp_proxy_daemon-0.2.0.tar.gz.
File metadata
- Download URL: bc_mcp_proxy_daemon-0.2.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07169018b404763d92b6d963a441f3268524826c3c3b286ed51dc84092a21bb1
|
|
| MD5 |
160b3495c37eebc3b2a0bb12e93efeba
|
|
| BLAKE2b-256 |
e9d0d91b6fc30960626afd05e7a48e8c7478a88bc501a099db881ac5557ebdbf
|
File details
Details for the file bc_mcp_proxy_daemon-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bc_mcp_proxy_daemon-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e722473d8fa5ec64a2d6838997c9d4612c50c4105477bf813379788a5b9584c
|
|
| MD5 |
a86f74bc7148b1462daeb311feb9ae99
|
|
| BLAKE2b-256 |
37462f609e1729cd2222dfe9ddb841ae730f0e5d5d953c9c15e715e3abd59620
|