← Portfolio · Projects · FastAPI-MCP-Architect
Case study · Open source project

FastAPI-MCP-Architect: giving a coding assistant the map of a FastAPI project

An open source MCP server: semantic navigation, dependency analysis and a knowledge graph, without running the code.

Context

A coding assistant that discovers a project reads the files one by one and guesses how they connect. In a FastAPI API, the important information sits precisely in those connections: which route goes through which dependency, which schema mirrors which database model, which function writes to which table.

FastAPI-MCP-Architect is an MCP server, the protocol that lets a coding assistant call tools. Instead of reading blindly, the assistant asks precise questions and gets structured answers. The project is open source and published as an installable package.

Overall architecture

The server exposes typed tools, grouped around three engines. None of them runs the project's code: everything is read and analyzed, which makes the tool safe on any repository.

Semantic engineA language analysis engine finds a symbol's references and its definition, and renames it safely across all files.
Syntax treeReads the structure of the code: routes with their full path, the dependency injection tree, model fields and validators.
Knowledge graphA typed, queryable map of the whole application: neighbors, impact of a change, paths, audit and visual export.
Coding assistant asks a question about the project MCP server typed tools, structured answers protocol They read the code, never run it Semantic engine references, safe rename, definition, completion Syntax tree routes, dependency injection, data models Knowledge graph report, neighbors, impact, paths, audit, export Incremental cache only changed files are read again

Wide diagram: scroll it to the right.

Building the graph

Each file is read once to extract facts: functions, classes, imports, route decorators, injections, hard-coded SQL queries, rendered templates. Names are then resolved from one module to another through the imports, and the facts are assembled into typed nodes and edges: application, router, route, dependency, schema, database model, table.

Each file's facts are cached in the project. A file is read again only if its date or size has changed, and only if its content has actually changed. After the first build, questions stay fast even on a large project.

Project files Changed? date and size, then hash Per-file extraction functions, classes, imports, decorators, SQL queries yes Cached facts reused as they are no saved Name resolution across modules, through imports Assembly typed nodes and edges, full path of every route No AI model in this step: the same code always gives the same graph.

Wide diagram: scroll it to the right.

Asking the graph

The graph answers questions that a plain text search cannot handle:

Application prefix /api Router prefix /users Route POST /api/users Function create_user includes contains handled by Dependency get_db depends on Schema UserCreate accepts ORM model User mirrors Table users stored in Impact analysis walks the edges backwards, from the model to the routes, with the full chain The names come from the small sample project used by the tests.

Wide diagram: scroll it to the right.

Technical choices