Enables configuration management through environment variables loaded from a .env file, allowing customization of database connections and JWT settings
Supported as an optional database backend for storing financial accounting entries, configurable through the DB_URL environment variable
Used for database access and ORM capabilities, allowing the server to manage financial accounting entries through a standardized database interface
Used as the default database backend for storing financial accounting entries in a local file
MCP API
API de CRUD de Pessoas protegida por JWT, construída com FastAPI, SQLAlchemy e Alembic.
🚀 Visão Geral
Linguagem: Python 3.11
Framework: FastAPI
Banco de Dados: SQLite (
mcp.db)ORM: SQLAlchemy + Alembic
Documentação: Swagger UI (OpenAPI)
Autenticação: JWT (Bearer)
Servidor MCP: compatível com o MCP Client Tool do n8n, permitindo que fluxos de IA registrem clientes automaticamente no banco de dados via n8n
Related MCP server: Ledger CLI MCP Server
📂 Estrutura do Projeto
⚙️ Pré-requisitos
Python 3.11+
pip
Docker & Docker Compose (opcional para container)
🔧 Instalação Local
Clone o repositório:
git clone <SEU_REPO_URL> cd meu_projetoCrie e ative um virtualenv:
python3 -m venv .venv source .venv/bin/activate # Linux/macOS .venv\Scripts\activate.bat # WindowsInstale dependências:
pip install --upgrade pip pip install -r requirements.txtConfigure seu
.env(exemplo em.env.example):SECRET_KEY=uma_senha_supersecreta ALGORITHM=HS256 ACCESS_TOKEN_EXPIRE_MINUTES=60 DATABASE_URL=sqlite:///./mcp.dbGere o banco e suba o servidor:
uvicorn run:app --reload
🌐 Uso com Docker Compose
Build e up:
docker-compose build docker-compose up -dAcesse em
https://mcpfinanceiro.adjunto.com.brouhttp://localhost:8000.
📑 Documentação & Swagger UI
OpenAPI JSON:
/openapi.jsonSwagger UI:
/docsClique em Authorize, cole apenas o JWT.
Depois faça chamadas às rotas de
/pessoas.
🔐 Autenticação JWT
Esquema: Bearer JWT
Components/securitySchemes:
bearerAuthAs operações usam
Security(get_current_user)eglobal securityno OpenAPI.
Geração de Token (externa)
Exemplo de geração manual:
📝 Endpoints Principais
Método | Rota | Operation ID | Descrição |
POST |
|
| Cria nova pessoa |
GET |
|
| Lista pessoas |
GET |
|
| Busca pessoa por ID |
PATCH |
|
| Atualiza campos da pessoa |
DELETE |
|
| Remove pessoa |
📂 Migrações com Alembic
Inicializar repo:
alembic init migrationsCriar migration:
alembic revision --autogenerate -m "Descrição"Aplicar:
alembic upgrade head
⚖️ Licença
MIT License © Adjunto Sistemas