new mcp servers format
This commit is contained in:
parent
0112573d9b
commit
e98744b7a4
105
.cursorrules
Normal file
105
.cursorrules
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
# A2A SaaS - Regras e Estrutura do Projeto
|
||||||
|
|
||||||
|
## Tecnologias Principais
|
||||||
|
- FastAPI: Framework web para construção da API
|
||||||
|
- SQLAlchemy: ORM para interação com o banco de dados
|
||||||
|
- Alembic: Sistema de migrações do banco de dados
|
||||||
|
- PostgreSQL: Banco de dados principal
|
||||||
|
- Pydantic: Validação e serialização de dados
|
||||||
|
- Uvicorn: Servidor ASGI para execução da aplicação
|
||||||
|
- Redis: Cache e gerenciamento de sessões
|
||||||
|
|
||||||
|
## Estrutura do Projeto
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── api/
|
||||||
|
│ └── routes.py # Definição das rotas da API
|
||||||
|
├── config/
|
||||||
|
│ ├── database.py # Configuração do banco de dados
|
||||||
|
│ └── settings.py # Configurações gerais
|
||||||
|
├── core/
|
||||||
|
│ └── middleware.py # Middleware de autenticação
|
||||||
|
├── models/
|
||||||
|
│ └── models.py # Modelos SQLAlchemy
|
||||||
|
├── schemas/
|
||||||
|
│ └── schemas.py # Schemas Pydantic
|
||||||
|
└── services/
|
||||||
|
├── agent_service.py # Lógica de negócio para agentes
|
||||||
|
├── client_service.py # Lógica de negócio para clientes
|
||||||
|
├── contact_service.py # Lógica de negócio para contatos
|
||||||
|
├── mcp_server_service.py # Lógica de negócio para servidores MCP
|
||||||
|
└── tool_service.py # Lógica de negócio para ferramentas
|
||||||
|
```
|
||||||
|
|
||||||
|
## Padrões de Código
|
||||||
|
|
||||||
|
### Schemas (Pydantic)
|
||||||
|
- Usar `BaseModel` como base para todos os schemas
|
||||||
|
- Definir campos com tipos explícitos
|
||||||
|
- Usar `Optional` para campos opcionais
|
||||||
|
- Usar `Field` para validações e valores padrão
|
||||||
|
- Implementar `Config` com `from_attributes = True` para modelos
|
||||||
|
|
||||||
|
### Serviços
|
||||||
|
- Tratamento de erros com `SQLAlchemyError`
|
||||||
|
- Logging consistente com mensagens em português
|
||||||
|
- Tipagem forte com `Optional` para retornos nulos
|
||||||
|
- Documentação com docstrings
|
||||||
|
- Rollback em caso de erro
|
||||||
|
- Retornos padronizados
|
||||||
|
|
||||||
|
### Rotas
|
||||||
|
- Status codes apropriados (201 para criação, 204 para deleção)
|
||||||
|
- Tratamento de erros com `HTTPException`
|
||||||
|
- Mensagens de erro em português
|
||||||
|
- Paginação nas listagens
|
||||||
|
- Validação de entrada com schemas
|
||||||
|
- Autenticação via API Key em todas as rotas
|
||||||
|
|
||||||
|
### Migrações
|
||||||
|
- Usar Alembic para gerenciamento de migrações
|
||||||
|
- Nomes descritivos para as migrações
|
||||||
|
- Manter histórico de alterações
|
||||||
|
- Usar CASCADE quando necessário para remover dependências
|
||||||
|
|
||||||
|
### Autenticação
|
||||||
|
- Usar API Key para autenticação
|
||||||
|
- Gerar API Key automaticamente no primeiro acesso
|
||||||
|
- Armazenar API Key no arquivo .env
|
||||||
|
- Validar API Key em todas as rotas
|
||||||
|
- Logging de tentativas de acesso inválidas
|
||||||
|
|
||||||
|
### Variáveis de Ambiente
|
||||||
|
- Usar arquivo .env para configurações sensíveis
|
||||||
|
- Manter .env.example atualizado
|
||||||
|
- Documentar todas as variáveis de ambiente
|
||||||
|
- Usar valores padrão seguros
|
||||||
|
- Validar variáveis obrigatórias
|
||||||
|
|
||||||
|
## Convenções
|
||||||
|
- Nomes de variáveis e funções em inglês
|
||||||
|
- Mensagens de log e erro em português
|
||||||
|
- Documentação em português
|
||||||
|
- Indentação com 4 espaços
|
||||||
|
- Máximo de 79 caracteres por linha
|
||||||
|
|
||||||
|
## Boas Práticas
|
||||||
|
- Sempre validar entrada de dados
|
||||||
|
- Implementar logging adequado
|
||||||
|
- Tratar todos os erros possíveis
|
||||||
|
- Manter consistência nos retornos
|
||||||
|
- Documentar funções e classes
|
||||||
|
- Seguir princípios SOLID
|
||||||
|
- Manter testes atualizados
|
||||||
|
- Proteger rotas com autenticação
|
||||||
|
- Usar variáveis de ambiente para configurações sensíveis
|
||||||
|
|
||||||
|
## Comandos Úteis
|
||||||
|
- `make run`: Inicia o servidor
|
||||||
|
- `make alembic-revision message="descrição"`: Cria nova migração
|
||||||
|
- `make alembic-upgrade`: Aplica migrações pendentes
|
||||||
|
- `make alembic-downgrade`: Reverte última migração
|
||||||
|
- `make alembic-migrate`: Cria e aplica nova migração
|
||||||
|
- `make alembic-reset`: Reseta o banco de dados para o estado inicial
|
||||||
|
- `make alembic-upgrade-cascade`: Força upgrade removendo dependências
|
||||||
|
- `make clear-cache`: Limpa cache do projeto
|
37
.env
37
.env
@ -1,14 +1,33 @@
|
|||||||
OPENAI_API_KEY=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
|
API_TITLE="Evo API"
|
||||||
|
API_DESCRIPTION="API para execução de agentes de IA"
|
||||||
|
API_VERSION="1.0.0"
|
||||||
|
|
||||||
POSTGRES_CONNECTION_STRING=postgresql://postgres:root@localhost:5432/evo_ai
|
# Configurações do banco de dados
|
||||||
|
POSTGRES_CONNECTION_STRING="postgresql://postgres:root@localhost:5432/evo_ai"
|
||||||
|
|
||||||
TENANT_ID=45cffb85-51c8-41ed-aa8d-710970a7ce50
|
# Configurações de logging
|
||||||
KNOWLEDGE_API_URL=http://localhost:5540
|
LOG_LEVEL="INFO"
|
||||||
KNOWLEDGE_API_KEY=79405047-7a5e-4b18-b25a-4af149d747dc
|
LOG_DIR="logs"
|
||||||
|
|
||||||
REDIS_HOST=localhost
|
# Configurações da API de Conhecimento
|
||||||
|
KNOWLEDGE_API_URL="http://localhost:5540"
|
||||||
|
KNOWLEDGE_API_KEY="sua-chave-api-conhecimento"
|
||||||
|
TENANT_ID="seu-tenant-id"
|
||||||
|
|
||||||
|
# Configurações do Redis
|
||||||
|
REDIS_HOST="localhost"
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
REDIS_DB=3
|
REDIS_DB=8
|
||||||
REDIS_PASSWORD=
|
REDIS_PASSWORD=""
|
||||||
|
|
||||||
LOG_LEVEL=DEBUG
|
# TTL do cache de ferramentas em segundos (1 hora)
|
||||||
|
TOOLS_CACHE_TTL=3600
|
||||||
|
|
||||||
|
# Configurações da API
|
||||||
|
API_KEY="e9f6ef0a-425e-4d32-bdb6-1c917da6e649"
|
||||||
|
API_KEY_HEADER="X-API-Key"
|
||||||
|
|
||||||
|
# Configurações do Servidor
|
||||||
|
HOST="0.0.0.0"
|
||||||
|
PORT=8000
|
||||||
|
DEBUG=false
|
||||||
|
24
.env.example
Normal file
24
.env.example
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Configurações do banco de dados
|
||||||
|
POSTGRES_CONNECTION_STRING="postgresql://postgres:root@localhost:5432/evo_ai"
|
||||||
|
|
||||||
|
# Configurações de logging
|
||||||
|
LOG_LEVEL="INFO"
|
||||||
|
LOG_DIR="logs"
|
||||||
|
|
||||||
|
# Configurações do Redis
|
||||||
|
REDIS_HOST="localhost"
|
||||||
|
REDIS_PORT=6379
|
||||||
|
REDIS_DB=0
|
||||||
|
REDIS_PASSWORD="sua-senha-redis"
|
||||||
|
|
||||||
|
# TTL do cache de ferramentas em segundos (1 hora)
|
||||||
|
TOOLS_CACHE_TTL=3600
|
||||||
|
|
||||||
|
# Configurações da API
|
||||||
|
API_KEY="sua-api-key-gerada-automaticamente"
|
||||||
|
API_KEY_HEADER="X-API-Key"
|
||||||
|
|
||||||
|
# Configurações do Servidor
|
||||||
|
HOST="0.0.0.0"
|
||||||
|
PORT=8000
|
||||||
|
DEBUG=false
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user