MCP (Model Context Protocol) server for Bling ERP API v3, built with FastMCP 3.x in Python. It provides OAuth2 onboarding, a local wizard, and tools for products, orders, invoices, contacts, stock, and OpenAPI search.
- Python 3.14
- uv (recomendado) ou pip
- Conta Bling com acesso a API
- App Bling configurado com Redirect URI
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone <repo>
cd bling-erp-mcp-server
uv syncpython -m venv .venv
source .venv/bin/activate # ou .venv\Scripts\activate no Windows
pip install -e ".[dev]"Se voce nao quiser usar a interface web, use o comando bling-login para autenticar diretamente pelo terminal. Este e o metodo recomendado para ambientes sem UI (UI_ENABLE=off).
Pre-requisito: no painel do Bling, seu App deve ter o Redirect URI configurado como http://localhost:3333/oauth/callback (ajuste a porta conforme PORT no .env).
# 1. Configure as credenciais no .env
cp .env.example .env
# Edite .env e defina BLING_CLIENT_ID e BLING_CLIENT_SECRET
# 2. Execute o login
bling-login
# ou: python -m bling_mcp.loginO comando vai:
- Gerar a URL de autorizacao e abrir o browser automaticamente.
- Aguardar o callback do Bling em
http://localhost:{PORT}/oauth/callback. - Trocar o codigo por tokens e salvar em
TOKEN_STORE_PATH(padrao:.tokens.json).
Redirect URI nao-local (tunnel/deploy): se BLING_REDIRECT_URI ou PUBLIC_BASE_URL apontarem para um dominio externo, o comando imprime a URL de autorizacao e pede que voce cole a URL de retorno do Bling no terminal apos autorizar no browser.
Apos autenticar, inicie o servidor normalmente:
python -m bling_mcp- Copie
.env.examplepara.enve configureBLING_CLIENT_IDeBLING_CLIENT_SECRET. - Inicie o servidor via MCP client (stdio) ou diretamente:
python -m bling_mcp- Abra o wizard em
http://localhost:3333. - Defina
PUBLIC_BASE_URL(necessario para OAuth). Recomendado: Cloudflare Quick Tunnel:
cloudflared tunnel --url http://localhost:3333- Copie o Redirect URI exibido no wizard para o seu App da Bling.
- Na aba de Autenticacao, clique em Authorize with Bling.
Exemplo (Claude Desktop / VS Code):
{
"mcpServers": {
"bling": {
"command": ".venv/bin/python",
"args": ["-m", "bling_mcp"],
"env": {
"PORT": "3333"
}
}
}
}Para uso em web clients, habilite o transporte HTTP:
MCP_TRANSPORT=http python -m bling_mcpO MCP fica disponivel em http://<host>:3333/mcp.
Veja .env.example. Principais:
BLING_CLIENT_ID/BLING_CLIENT_SECRETPUBLIC_BASE_URL(URL publica do wizard/redirect)BLING_REDIRECT_URI(opcional; deriva de PUBLIC_BASE_URL)PORT(default 3333)MCP_TRANSPORT(stdioouhttp)TOKEN_STORE_PATH(arquivo JSON de tokens)UI_ENABLE(on/off)UI_AUTH_MODE(noneougithub)FASTMCP_SERVER_AUTHeFASTMCP_SERVER_AUTH_*(OAuth do FastMCP para HTTP)
Build e execute:
docker compose up --buildCrie um arquivo .env com:
BLING_CLIENT_ID=...
BLING_CLIENT_SECRET=...
PUBLIC_BASE_URL=...
O compose ja define MCP_TRANSPORT=http e monta ./data para persistir tokens.
- Python 3.14+
- uv (recommended) or pip
- Bling account with API access
- Bling App configured with a Redirect URI
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone <repo>
cd bling-erp-mcp-server
uv syncpython -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -e ".[dev]"If you prefer not to use the web interface, use bling-login to authenticate directly from the terminal. This is the recommended method when UI_ENABLE=off.
Prerequisite: in the Bling developer panel, your App must have Redirect URI set to http://localhost:3333/oauth/callback (adjust port to match PORT in .env).
# 1. Configure credentials in .env
cp .env.example .env
# Edit .env and set BLING_CLIENT_ID and BLING_CLIENT_SECRET
# 2. Run login
bling-login
# or: python -m bling_mcp.loginThe command will:
- Generate the authorization URL and open the browser automatically.
- Wait for the Bling callback at
http://localhost:{PORT}/oauth/callback. - Exchange the code for tokens and save them to
TOKEN_STORE_PATH(default:.tokens.json).
Non-local Redirect URI (tunnel/deploy): if BLING_REDIRECT_URI or PUBLIC_BASE_URL point to an external domain, the command prints the authorization URL, and asks you to paste the full callback URL from the browser after authorizing.
Once authenticated, start the server normally:
python -m bling_mcp- Copy
.env.exampleto.envand setBLING_CLIENT_IDandBLING_CLIENT_SECRET. - Start the server via MCP client (stdio) or directly:
python -m bling_mcp- Open the wizard at
http://localhost:3333. - Set
PUBLIC_BASE_URL(required for OAuth). Recommended: Cloudflare Quick Tunnel:
cloudflared tunnel --url http://localhost:3333- Copy the Redirect URI shown in the wizard into your Bling App settings.
- In the Auth tab, click Authorize with Bling.
Example (Claude Desktop / VS Code):
{
"mcpServers": {
"bling": {
"command": ".venv/bin/python",
"args": ["-m", "bling_mcp"],
"env": {
"PORT": "3333"
}
}
}
}For web clients, enable HTTP transport:
MCP_TRANSPORT=http python -m bling_mcpMCP endpoint: http://<host>:3333/mcp.
See .env.example. Main options:
BLING_CLIENT_ID/BLING_CLIENT_SECRETPUBLIC_BASE_URL(public URL for wizard/redirect)BLING_REDIRECT_URI(optional; derived from PUBLIC_BASE_URL)PORT(default 3333)MCP_TRANSPORT(stdioorhttp)TOKEN_STORE_PATH(token JSON file)UI_ENABLE(on/off)UI_AUTH_MODE(noneorgithub)FASTMCP_SERVER_AUTHandFASTMCP_SERVER_AUTH_*(FastMCP OAuth for HTTP)
Build and run:
docker compose up --buildCreate a .env file with:
BLING_CLIENT_ID=...
BLING_CLIENT_SECRET=...
PUBLIC_BASE_URL=...
The compose file sets MCP_TRANSPORT=http and mounts ./data to persist tokens.
bling_mcp/__main__.py: Entry point (stdio and/or HTTP + callback server)bling_mcp/config.py: Pydantic settings (env)bling_mcp/auth/: Token store, OAuth callback server, wizard UIbling_mcp/bling/: Bling API client, OAuth, views, OpenAPI searchbling_mcp/mcp/: FastMCP app, tool helpers, resource store, tools
See LICENSE.