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.
Get reminders
One signup gets you join links, reminders, and the recording library. No ongoing commitment.
Top 3 takeaways
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.
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.
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
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? +
What is the Model Context Protocol (MCP)? +
Why use MCP over a plain REST API? +
What is FastMCP? +
How do you build an MCP server from a REST API? +
server.py, and add unit and end-to-end tests.What's the difference between unit tests and end-to-end tests? +
What is an AI agent? +
Can you generate an MCP server with an LLM like Claude? +
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? +
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.