Skip to main content
Glama

mcp-fastapi

Servidor MCP que expõe os documentos de referência do FastAPI (docs/references/, 39 tópicos) como três tools, para que um agente/LLM consulte orientação real sobre FastAPI durante o desenvolvimento — em vez de depender só de conhecimento pré-treinado. Não é um buscador genérico de documentação: cada tool existe para responder "isso ajuda o agente a escrever FastAPI correto agora, no meio de uma tarefa de desenvolvimento?".

Tools

Nomes e parâmetros em português brasileiro (vocabulário de domínio do projeto). Schemas completos e cenários de erro em specs/001-search-fastapi-docs/contracts/mcp-tools.md.

buscar_documentos

Busca por tópico/palavra-chave. Recebe consulta (string, não pode ser vazia/só espaço) e devolve uma lista ranqueada (máx. 10) com id_documento, titulo, trecho (excerto que justifica o match) e pontuacao.

obter_documento

Recebe id_documento (ex.: o retornado por uma busca) e devolve o conteúdo markdown completo e sem modificação do documento, ou uma resposta encontrado: false clara se o id não existir.

listar_documentos

Sem parâmetros. Lista todos os documentos do corpus (id_documento + titulo), para descoberta de tópicos sem precisar adivinhar um termo de busca.

Related MCP server: OpenAPI MCP Server

Instalação

Pré-requisitos: Python 3.12+ e uv.

uv sync

Rodar o servidor

uv run python -m mcp_fastapi

O servidor fala o protocolo MCP via stdio (sem HTTP nesta versão). Para plugar num cliente MCP (ex. Claude Desktop/Claude Code), aponte para o comando acima com o diretório do projeto como cwd, por exemplo:

{
  "mcpServers": {
    "mcp-fastapi": {
      "command": "uv",
      "args": ["run", "python", "-m", "mcp_fastapi"],
      "cwd": "/caminho/para/mcp-fastapi"
    }
  }
}

Para validar o fluxo completo manualmente (os 3 tools, cenários de sucesso e erro), veja specs/001-search-fastapi-docs/quickstart.md.

Arquitetura

Pacote único em src/mcp_fastapi/, sem banco de dados — o corpus inteiro é carregado em memória na inicialização a partir de docs/references/*.md.

  • corpus.py — carrega e valida os documentos (DocumentoReferencia), um por arquivo; id único por nome de arquivo, título extraído do H1 do conteúdo.

  • search.py — tokenização e ranqueamento por frequência de termo (peso maior no título), stdlib apenas — sem dependência externa de busca.

  • server.py — instancia o servidor MCP (SDK oficial) e registra as três tools.

Detalhes de design e as decisões por trás deles estão em specs/001-search-fastapi-docs/ (plan.md, research.md, data-model.md) e na constituição do projeto.

Desenvolvimento

uv run pytest                  # suíte de testes (unit + contract)
uv run pytest --cov            # com relatório de cobertura no terminal
uv run ruff check .            # lint
uv run ruff format --check .   # formatação
uv run mypy                    # type-check estrito
uv run bandit -c pyproject.toml -r src   # SAST
uv run pip-audit               # CVEs nas dependências

pre-commit install roda essas checagens automaticamente antes de cada commit (config em .pre-commit-config.yaml).

CI (.github/workflows/ci.yml) roda as mesmas checagens em PR/push; release (.github/workflows/release.yml) gera versão/changelog/tag automaticamente via python-semantic-release a partir de Conventional Commits — sem bump manual.

Análise local no SonarQube

cp .env.example .env   # preencher SONAR_TOKEN
scripts/run-sonar-local.sh

Roda a suíte com cobertura e envia a análise para o SonarQube configurado em sonar-project.properties (só o token fica no .env, gitignored).

Convenções do projeto

  • Idioma: domínio de negócio (specs, comentários, nomes de tool/campo) em português brasileiro; termos técnicos padrão de mercado (nomes de framework, padrões de código, tipos de commit) em inglês.

  • Contrato antes do código: todo schema de tool deve refletir fielmente docs/references/; mudanças que quebram um contrato existente exigem bump de MAJOR (SemVer).

  • Test-first: lógica de tool/resource não é implementada sem teste escrito e falhando antes.

Regras completas em .specify/memory/constitution.md.

Available Tools

3 tools
buscar_documentosA

Busca documentos de referência do FastAPI por tópico/palavra-chave.

ParametersJSON Schema
NameRequiredDescriptionDefault
consultaYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It only says 'searches' without disclosing return format, matching behavior, side effects, or whether it is read-only. This is insufficient for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that directly conveys the tool's purpose without unnecessary words. It is well-structured and front-loads the action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has a simple parameter set, an output schema exists, and the description captures the core search intent. It lacks explicit usage guidance and behavioral details, but given the low complexity and presence of an output schema, it is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It does by clarifying that 'consulta' is a topic or keyword ('por tópico/palavra-chave'), adding meaning beyond the generic parameter title. However, it does not provide syntax or formatting details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Busca documentos de referência do FastAPI por tópico/palavra-chave' clearly states the action (search), the resource (FastAPI reference documents), and the method (by topic/keyword). It distinguishes from sibling tools (listar_documentos for listing, obter_documento for retrieval) by focusing on search functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when a topic/keyword is available, but it does not explicitly mention when to avoid this tool or suggest alternatives. Sibling tool names hint at alternatives, but the description itself provides no comparative guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

listar_documentosA

Lista todos os documentos de referência do FastAPI disponíveis.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. The verb 'list' implies a read-only operation, and 'disponíveis' adds a scoping detail, but the description does not explicitly disclose safety, side effects, or output behavior beyond the inherent meaning of 'list'. It is minimally adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence without any wasted words. It directly states the action and the object.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the zero-parameter complexity and the presence of an output schema, the description is largely complete. It could explicitly mention alternative tools, but that is covered under usage guidelines. The description sufficiently covers the tool's purpose for a simple list operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters and the schema is empty with 100% coverage. Per the baseline rule for 0-parameter tools, a score of 4 is appropriate; the description does not need to elaborate on parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'Lista' (lists) with the resource 'documentos de referência do FastAPI' and the scope 'todos...disponíveis' (all available). This clearly distinguishes it from sibling tools 'buscar_documentos' (search) and 'obter_documento' (get a single document).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage (when you want all available documents), but it does not explicitly state when to use this tool over alternatives. There is no mention of exclusions or when to use 'buscar_documentos' or 'obter_documento' instead.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

obter_documentoA

Obtém o conteúdo completo de um documento de referência pelo seu id.

ParametersJSON Schema
NameRequiredDescriptionDefault
id_documentoYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
tituloNo
conteudoNo
mensagemNo
encontradoYes
id_documentoYes

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the burden of behavioral disclosure. The verb 'Obtém' implies a read-only operation, but the description does not mention potential errors, permissions, or side effects. However, for a simple retrieval tool, this basic transparency is adequate, though it could add more context about failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that immediately states the action and object, front-loading the key information without any redundant words. It earns its place with zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one required parameter), the presence of an output schema, and the clear purpose statement, the description is nearly complete. It covers what the tool does and the parameter's role; the output schema handles return values. The only minor gap is lack of explicit guidance on when to prefer this over siblings, already partially addressed in usage guidelines.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, but it only says 'pelo seu id' which simply restates the parameter name 'id_documento' without adding new meaning. It does not clarify format, constraints, or behavior for invalid ids; the sole parameter's purpose is already evident from its name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'Obtém' (gets) and the resource 'conteúdo completo de um documento de referência' (complete content of a reference document), clearly distinguishing it from sibling tools like 'buscar_documentos' and 'listar_documentos' which involve searching or listing. The 'pelo seu id' (by its id) further specifies the exact retrieval method.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you have a specific document id ('pelo seu id'), which clearly differentiates it from searching or listing. It does not explicitly mention alternatives or exclusion criteria, but the id-based retrieval context is clear, meeting the 'clear context, no exclusions' criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv1.0.0
    • First observedbuscar_documentos
    • First observedlistar_documentos
    • First observedobter_documento

TDQS

A4.2/5.0
Disambiguation5/5

Each tool has a distinct purpose: searching by keyword, retrieving by ID, and listing all documents. There is no overlap or ambiguity between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in Portuguese (buscar_documentos, obter_documento, listar_documentos), with the expected singular/plural distinction for retrieving single vs. multiple items.

Tool Count5/5

Three tools is perfectly scoped for a documentation retrieval server. Each tool covers a fundamental operation without unnecessary bloat.

Completeness5/5

The set covers the full lifecycle of read-only document access: search, list, and retrieve by ID. There are no obvious gaps for the server's stated purpose.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pedroct/mcp-fastapi'

If you have feedback or need assistance with the MCP directory API, please join our Discord server