feat: CVM fundo aberto (cadastro + série de cotas) no MCP público - #47
Conversation
Split the public surface onto a Cloudflare Worker (JSON sources only) and keep FastAPI Tailscale-only. Add an Access-protected Charlie stack with fail-closed origin token, Worker upstream bounds, and Tailscale bind validation. Co-authored-by: Cursor <cursoragent@cursor.com>
Enforce 60 req/60s and 20/10s burst per IP on /mcp via Workers Rate Limit bindings. Overflow is synchronous 429 + Retry-After. Landing and /health stay unlimited.
Cover 429/Retry-After and IP keying with fake Rate Limit bindings. Stop trusting X-Forwarded-For when CF-Connecting-IP is absent.
Resolve fundo aberto by CNPJ against official RCVM 175 registro and return INF_DIARIO quota/PL/cotistas. cad_fi.csv omits adapted funds. CDA carteira stays off the public Worker.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Vulnerable Libraries (1)
More info on how to fix Vulnerable Libraries in JavaScript. 👉 Go to the dashboard for detailed results. 📥 Happy? Share your feedback with us. |
Avoid materializing the ~48MB INF_DIARIO CSV in the 128MB isolate. Also run workers/mcp node:test in CI.
MCP Trust Review
AchadosNO_FINDINGS no head atual. Residuais aceitos (não High): teto 16 MB no ZIP comprimido ( Eixos
Over-engineeringNO_FINDINGS. A capacidade nova cabe numa tool já existente no FastAPI; no Worker ela é a 10ª tool, não um catálogo novo. Adversarial review (CROSS_FAMILY)
|
|
guardrails/scan (wrangler@4.122.0): mesmo finding de #45, herdado do Worker. Não é regressão deste incremento CVM. O aviso pede Não vou bump de wrangler neste PR só para silenciar o scanner (CLI de deploy, não runtime do CI do repo no |
Needle scan of the whole CSV row treated administrator/gestor CNPJs as fund identifiers. Filter to CNPJ_Fundo / CNPJ_Classe after the stream prefilter, same contract as the Python cadastro lookup.
Autoreview loopPass 1 (GPT, CROSS_FAMILY) no HEAD Pass 2 (Claude, CROSS_FAMILY) no HEAD Não reaberto: pin |
Contexto
O MCP público (
https://openfindata.com.br/mcp) só publicava 9 tools macro. O CIO não conseguiu resolver:38.729.027/0001-9221.494.444/0001-09Hipótese inicial (gap = allowlist do Worker sobre o FastAPI): descartada. O Worker é superfície TypeScript própria; não alcança a Tailscale e não faz proxy do FastAPI. O FastAPI privado já tinha
cvm_fund, masdataset=catalogliacad_fi.csv, que desde 2024-10 só lista fundos não adaptados à RCVM 175. Os dois CNPJs do CIO não estão nesse CSV.Cadastro oficial:
https://dados.cvm.gov.br/dados/FI/CAD/DADOS/registro_fundo_classe.zip(fundo + classe + subclasse). Série de cotas: INF_DIARIO mensal.Superfície pública (menor)
Nova tool no Worker:
cvm_fundcatalogcnpjouq(obrigatório)dailycnpj+year/month(default = mês UTC corrente)Fora do Worker (de propósito):
Rate limits de
/mcpnão mudam: 60/60s + burst 20/10s.FastAPI/CLI (VPS):
GET /cvm/funds/cadastro,findata cvm cadastro,findata cvm daily, e matching de CNPJ normalizado no INF_DIARIO.Caminho até o CIO
openfindata.com.br/mcpnão ganha a tool até deploy do Worker:Depois:
Este agente não fez o deploy.
Verificação
tests/test_cvm_fund_cadastro.py+workers/mcpnode:test (12). Preflightaf9887f: ruff + mypy + 343 pytest.af9887f: scan em stream. Re-parse live: 19 cotas AMW, delta RSS ~52 MB no Node local (inclui os ZIPs no mock).Relação com #45
Este PR é
main+ os commits do Worker público (#45, rebase) + CVM. Merge daqui leva Worker +cvm_fund. #45 pode fechar como superseded depois.MCP Trust
Classificação:
MCP_TOOL. Conclusão:PASS. Review no comentário abaixo.