Skip to main content
Glama
FastAPI Scaffolder MCP Server

FastAPI Scaffolder MCP Server

FastAPI Scaffolder

FastAPI Scaffolder is a developer tool and AI system agent that transforms human- and machine-readable YAML architecture specifications into production-ready FastAPI applications.

It provides both a CLI interface for humans and a Model Context Protocol (MCP) server for AI agents (Gemini, Claude Desktop, Cursor, Windsurf, LangChain) to generate modular APIs instantly.


Capabilities

  • Dual Interface: Native CLI for developers and a zero-dependency JSON-RPC 2.0 MCP server for AI models.

  • Declarative Schemas: Define microservices, endpoints, HTTP methods, Pydantic request/response payloads, and service dependencies in single or split YAML files.

  • Modular Generation: Renders complete project structures complete with typed Pydantic models, FastAPI routers, configuration, dependency wiring, and test suites.

  • Python 3.14 Ready: Built natively without third-party wrapper bottlenecks or SDK version locks.


Related MCP server: MCP Server Template

Installation

Prerequisites

  • Python >= 3.10 (Tested up to 3.14)

  • uv or pip

Install Locally (Editable Mode)

# Clone and enter directory
cd fastapi-scaffolder

# Install with CLI and MCP entry points
pip install -e .

This registers two global commands in your active virtual environment:

  • scaffold — Human-facing CLI tool

  • scaffold-mcp — Executable stdio MCP server for AI clients


Schema Specification (architecture.yaml)

Define your API architecture using standard YAML:

system_name: PaymentInvoicingPlatform
version: 1.0.0

services:
  - name: AuthService
    description: Handles user authentication and tokens
    dependencies: []
    endpoints:
      - path: /auth/login
        method: POST
        summary: Authenticate user
        request_body:
          - name: email
            type: str
          - name: password
            type: str
        response_body:
          - name: access_token
            type: str

  - name: InvoiceService
    description: Manages client invoices
    dependencies:
      - AuthService
    endpoints:
      - path: /invoices
        method: POST
        summary: Create client invoice
        request_body:
          - name: client_email
            type: str
          - name: amount
            type: float
        response_body:
          - name: invoice_id
            type: str
          - name: status
            type: str

Usage Guide

1. Human CLI Usage

Scaffold an app directly from the terminal using the scaffold command:

# Generate app from YAML spec
scaffold -i architecture.yaml -o ./my_fastapi_app

# Combine multiple service specs
scaffold -i auth_service.yaml billing_service.yaml -o ./monorepo_app

2. AI Setup with Model Context Protocol (MCP)

scaffold-mcp communicates over Standard Input/Output (stdio) via JSON-RPC 2.0.

Cursor / Claude Desktop / Windsurf Setup

Add fastapi-scaffolder to your MCP configuration file (claude_desktop_config.json or Cursor MCP settings):

{
  "mcpServers": {
    "fastapi-scaffolder": {
      "command": "/path/to/your/venv/bin/scaffold-mcp",
      "args": []
    }
  }
}

Replace /path/to/your/venv/bin/scaffold-mcp with the absolute path returned by which scaffold-mcp.

System Prompt Directive for AI Agents

Add this instruction to your LLM system prompt so it outputs compliant YAML to invoke the tool:

FastAPI Scaffolder Schema Directive:

When generating an API, output a YAML string structured as follows:

system_name: MySystem
version: 1.0.0
services:
  - name: ServiceName
    description: Summary of responsibility
    dependencies: []
    endpoints:
      - path: /items/{id}
        method: GET
        summary: retrieve item
        response_body:
          - name: id
            type: str

Pass this raw YAML string to the build_fastapi_app tool with output_directory.


3. Usage with Google Gemini SDK

To run fastapi-scaffolder inside Gemini agent workflows:

from google import genai
from google.genai import types
from scaffolder.mcp_server import execute_scaffold

client = genai.Client()

# Pass the tool execution function to Gemini
response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Design a user profile microservice in YAML and build the code in ./user_service",
    config=types.GenerateContentConfig(
        tools=[execute_scaffold]
    )
)

# Execute the returned function call
if response.function_calls:
    for call in response.function_calls:
        if call.name == "execute_scaffold":
            result = execute_scaffold(call.args)
            print(result)

Testing the MCP Server Manually

Verify that the MCP server starts and receives messages via stdio:

# Run server executable
scaffold-mcp

Paste this test payload into stdout and press Enter:

{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}

Expected Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {
        "name": "build_fastapi_app",
        "description": "Scaffolds a complete FastAPI codebase from a YAML architecture definition.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "yaml_spec": {
              "type": "string",
              "description": "Raw YAML string matching the SystemArchitecture schema."
            },
            "output_directory": {
              "type": "string",
              "description": "Output directory path for generated files.",
              "default": "./generated_app"
            }
          },
          "required": ["yaml_spec"]
        }
      }
    ]
  }
}

Available Tools

1 tool
build_fastapi_appB

Scaffolds a complete FastAPI codebase from a YAML architecture definition.

Inputs: yaml_spec (required), output_directory.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of confusion or overlap. The tool has a distinct and singular purpose.

    Naming Consistency5/5

    The single tool name 'build_fastapi_app' follows a clear verb_noun pattern, and consistency is trivially maintained with only one tool.

    Tool Count3/5

    A single tool feels thin for a server, but it is borderline appropriate given the narrow, focused purpose of scaffolding FastAPI apps from YAML definitions.

    Completeness5/5

    The tool fully covers the stated domain of scaffolding a complete FastAPI codebase. There are no obvious missing operations for the intended workflow.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to generate standardized code using scaffolding templates, enforce architectural patterns, and validate outputs programmatically. Supports creating projects from boilerplates and adding features to existing codebases while maintaining team conventions.
      160
      AGPL 3.0
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      A scaffold project for building FastAPI-based Model Context Protocol servers with automatic tool discovery and router capabilities.
      -
    • F
      license
      B
      quality
      D
      maintenance
      A specialized toolchain that guides AI agents through a structured 'Atomic Development' workflow for building Python FastAPI and Supabase backends. It manages project scaffolding and enforces dependency-ordered generation of database models, API routes, and tests.
      9
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A production-ready Python scaffold for building Model Context Protocol (MCP) servers using FastMCP. It provides a structured framework for developers and AI agents to rapidly develop, test, and manage custom tools and workflows.
      1
      -