MCP Factory: Building Plugin-Based Model Context Protocol Servers

In this lesson: Aaron Gallant breaks down the MCP Factory — a plugin-based framework for spinning up Model Context Protocol servers from any REST API quickly, consistently, and production-ready, using FastMCP, SOLID principles, and AI-assisted development.

Aaron Gallant · 62 min · Intermediate · July 22, 2026
Released July 23, 2026

Top 3 takeaways

01

MCP is sugar on REST

The Model Context Protocol is a decorated REST API — convenient dev UX that makes capabilities discoverable to any LLM agent.

02

A factory standardizes the boilerplate

A plugin-based service architecture reuses error handling, HTTP, and markdown plumbing, so each new MCP server is consistent and near production-grade.

03

Implement fetch and format only

Extend two base classes — fetch the API and format the JSON to markdown — and the factory standardizes everything else.

Aaron Gallant

Aaron Gallant

Lead Instructor, Gauntlet AI

Aaron Gallant is Lead Instructor at Gauntlet AI. With 18 years in tech including five at Google, he specializes in fine-tuning, reinforcement learning, and synthetic HIPAA-compliant data generation.

Lesson notes

A written walkthrough of the lecture — what the factory is, why it standardizes the boilerplate, the stack, and how to add and test a new service.

What is an MCP factory?

The MCP Factory is a plugin-based foundation for building Model Context Protocol servers. Since the Model Context Protocol is essentially a decorated REST API — convenient developer UX that dynamically adds discoverable capabilities to any LLM tooling — the factory makes it fast and consistent to wrap any existing REST API in an MCP server without rebuilding the same plumbing each time.

Why standardize: SOLID and a service-plugin architecture

Every MCP server is remarkably similar, so the factory standardizes the shared plumbing — error handling, HTTP calls, markdown formatting. Each server is a self-contained plugin under services, following SOLID and the open-closed principle: add new plugins, but don't edit shipped ones. A little generated redundancy is worth keeping services independent and shippable.

The tech stack

The factory uses FastMCP (a Python framework for rapid, performant async MCP servers — inspired by, but not related to, FastAPI) and Python 3.13. Dependencies and environment are managed with UV. The entry point is main.py; server.py is the FastMCP server; the service registry is where you register new services. Default transport is standard I/O (stdio); HTTPS deployment is possible but out of scope.

Four building blocks

Each plugin builds on four pieces: the base API client (an async contract that handles network requests — you implement fetch), the base formatter (turns data into an LLM- and human-friendly markdown string — you implement format), the service plugin (duck-typed, handles registering the service), and the service registry (where all plugins are collected and exposed).

Adding a new service

Practical steps: make a folder for the service, add config (load API keys from the environment, never hard-code secrets in config.py), implement the fetch client and the markdown formatter by extending the base classes, register it with one line in server.py, and add tests. Most of the work is creating new files; only server.py needs editing to integrate.

Testing: TDD, unit + end-to-end

Aaron is a fan of test-driven development — write tests early, even before the code. Unit tests exercise each piece in isolation and keep quality high (if code is hard to unit-test, that's a code smell — the function may be doing too much). End-to-end tests verify the connected system and map naturally onto user stories; run them before merging to main.

What "agent" really means

Aaron's preferred definition: an agent is when the programmer cedes the program's control flow (the if-statements, loops, branching) to a model. LLMs are statistical, probabilistic, text-to-text systems, so they can handle unstructured problems deterministic code can't — but they can also make mistakes. Tools always return text, because language models live in the token-in, token-out world.

Reference services and the live demo

The factory ships with two examples: NASA's Astronomy Picture of the Day (a public REST API with a working demo key) and Code Guardian (a non-HTTP service that scans a codebase for security issues). In a live demo, Aaron pointed Claude at an open currency-conversion API (Frankfurter) with a ready-made prompt following the repo's "house rules" (a CLAUDE.md of context); Claude built, registered, and tested a new currency service end-to-end with no hand-written code.

Philosophy: ship quality, not lines of code

A recurring theme: lines of code are debt, not productivity. LLMs generate code cheaply, which makes it more important — not less — to apply solid engineering principles so systems stay reliable, consistent, and maintainable. The goal is shipping quality products, not just shipping a lot.

FAQ

What is an MCP factory? +
An MCP factory is a plugin-based framework for building Model Context Protocol (MCP) servers on top of existing REST APIs. It standardizes the shared plumbing so you can add a new, near-production-grade MCP server by implementing just two things — how to fetch from the API and how to format the response as markdown.
What is the Model Context Protocol (MCP)? +
MCP is a standard that adds discoverable, self-documenting capabilities to LLM tooling. Aaron describes it as "a decorated REST API" — a convenience layer of sugar on top of REST that makes tools easy for agents like Claude or Cursor to find and use.
Why use MCP over a plain REST API? +
MCP adds consistency, reliability, and discoverability. It does the pre-prompting, output cleaning, and validation for you, so the developer (or user) doesn't have to think about prompts each time. The self-documenting, discoverable interface is built in — something a raw API doesn't guarantee.
What is FastMCP? +
FastMCP is a Python framework for rapidly building performant, asynchronous MCP servers. Despite the name it isn't related to FastAPI, though it follows a similar philosophy. The MCP Factory uses FastMCP with Python 3.13 and UV for dependency management.
How do you build an MCP server from a REST API? +
Create a service folder, add config that loads API keys from the environment, extend the base API client to implement fetch, extend the base formatter to turn the JSON response into markdown, register the service with one line in server.py, and add unit and end-to-end tests.
What's the difference between unit tests and end-to-end tests? +
Unit tests check each piece in isolation (mocking the rest) and should be cheap to run often; if something is hard to unit-test, the code may be doing too much. End-to-end tests verify the connected system as a whole and map onto user stories — run them before merging to main.
What is an AI agent? +
Aaron's definition: an agent is when the programmer cedes the program's control flow — the branching logic like if-statements and loops — to a model. Instead of hard-coding how a problem is solved, you let the model decide, which is powerful for unstructured problems.
Can you generate an MCP server with an LLM like Claude? +
Yes. In the demo, Claude read the repo's house-rules (a CLAUDE.md context file), connected to an open currency API, then built, registered, and tested a new service on its own. Aaron recommends still reviewing and running the tests before shipping, but it's a strong AI-first starting point.
Can I integrate an existing Go (Golang) MCP server? +
Not out of the box — the factory is Python-first. But it's a solvable problem: wrap the Go code from Python, or ask an LLM to refactor the Go server into Python using the factory as context.

What's next?

Keep building with the rest of Night School, or apply to Gauntlet — twelve weeks of technical intensity with the best AI engineers we can find.