Purpose
mcp-factory is a manifest-driven engine for scaffolding MCP (Model Context Protocol) servers from a single mcp.yaml file, and provides a runtime hub that serves the tools of all registered bots through a single endpoint. It is designed to provide underlying support for MCP integration sprints: write one mcp.yaml for a bot repository, and the factory generates the server stub and the ~/.claude.json entry; after running the hub, every bot's tools can be served through a single MCP endpoint.
Main Capabilities
Factory Mode (generate configuration from a single manifest)
Output is written by default to ~/.claude.json.factory-test, and never directly to the live ~/.claude.json. Users must manually copy the entry after review.
Scan Mode (batch-register all bots)
--scan discovers all projects/*/mcp.yaml files, validates them one by one, and diffs them against the current ~/.claude.json. The default root directory is C:\path\to\projects. When --apply is used, a timestamped backup ~/.claude.json.scan-backup-<timestamp> is created before writing. Skip logic: if a name in the manifest already exists in ~/.claude.json, it is skipped unless --force is passed. This prevents accidental overwriting of hand-written entries.
Run Mode (runtime hub—all bots share one MCP)
At startup, the hub scans all mcp.yaml manifests under each --scan-root, then exposes each bot's tools under the <bot>.<tool> namespace (for example fleet-health.fleet_status, my-bot.run_scan). Tools are proxied to each bot's subprocess MCP server via lazy startup. The Hub meta-tool _hub.list_bots returns the registered bots and their subprocess status. The Hub is already pre-registered in ~/.claude.json as mcp-factory-hub (see scripts/register_hub.py).
Node.js Template
When mcp.yaml sets runtime.type: node, the factory generates a Node.js stub. The generated stub uses @modelcontextprotocol/sdk with stdio transport, and uses zod for parameter validation. See examples/node_example.yaml.
Two Python Styles: Raw SDK and FastMCP
For runtime.type: python, the factory can scaffold either of two styles from the exact same manifest. Both styles read the same tools: / env_required: fields and generate servers that use the same stdio JSON-RPC wire protocol—the runtime hub's SubprocessAdapter can proxy either one without any adapter changes.
mcp.yaml Schema
- runtime.script + existing file → the factory references it and skips scaffolding
- runtime.script + missing file → validation error (use runtime.output for new scaffolding)
- runtime.output → explicit path for generating the stub (absolute paths are recommended)
- neither script nor output → error at the configuration write step
title and annotations
title is a human-readable display name, letting name remain a programmatic identifier. Display priority is title → annotations.title → name; the factory only exposes the top-level title. The four hints of annotations have pessimistic defaults—destructiveHint and openWorldHint default to true, and readOnlyHint defaults to false—so tools that declare nothing are treated by cautious clients as the most dangerous case. Only the four hint names above are accepted, each must be a real boolean, and unknown keys are hard errors rather than being silently discarded. annotations are hints, not a security boundary. Both Python templates output these two fields; the Node template does not yet render them.
Tool Design Lint at Generation Time
Every time factory mode runs, the tool design lint (step 2) also runs, covering three scopes of 15 rules. By default they are advisory—discovered issues are printed, generation continues, and the exit code is 0. --lint-strict makes error-level findings fatal: they are reported, no scaffold is written, and the exit code is 3. When there is no discriminating capability, it reports INDETERMINATE rather than passing. There is no tool-name character-set rule, because the manifest's own identifier validation is already stricter. Each rule comes with a positive-control test.
workflow_runner.py
A CLI tool independent of hub_server.py, used for researching workflows. By default it scans SKILL.md files with YAML frontmatter in ~/research (can be overridden with --scan-root). Each SKILL.md defines a named workflow containing metadata. Features include: discovery (git ls-files enumeration), validation (checking the required frontmatter fields name and description), caching (SHA-based, keyed by prompt content; auto by default skips reruns when the output is unchanged, force-refresh always reruns, read-only never writes), running (invoking claude -p <prompt> as a subprocess, with streaming output), writing output (expanding output_path_template and writing the result to the vault), and registry (--write-registry persists discovered skills to registry.json; --check detects drift between the filesystem and the registry without writing).
Usage
60-second quick start
Install from PyPI (registry users), or use it from a git checkout (contributors). hub_server.py is located at the repository root and is a backward-compatible wrapper around the same mcp_factory.cli module, with identical behavior.
How to add a new MCP
- Write mcp.yaml at the root of the bot repository (or in examples/)
- Run the factory: python hub_server.py --manifest path/to/mcp.yaml
- Review ~/.claude.json.factory-test—confirm the entry is correct
- Copy the entry into ~/.claude.json's mcUnder pServers
- Restart Claude Code If the bot has no existing server, the factory will generate a stub at generated/<name>_server.py. Fill in the # TODO: implement section and set runtime.script to that stub path for future runs.
Runtime Hub Architecture
Subprocess lifecycle: adapters start lazily on first tool call (not pre-spawned); they stay alive for the duration of the hub session (one process per bot); _hub.list_bots() reports status: idle (not yet started) or running; all adapters are stopped via atexit when the hub exits; stop() kills the process after 5 seconds if necessary. Tool naming: <bot-name>.<tool-name>—hyphens are preserved, the dot is the separator.
When to Use
Suitable for development teams that need to build MCP servers for internal tools, especially scenarios that require bulk registration of multiple bots and unified exposure of tools through a single endpoint. Also suitable for MCP integration projects that need production-grade engineering practices (scoped authentication/environment variables, soft-failure error handling, manifest validation, conflict-resistant registry, full test suite).
Limitations
- The factory generates scaffolding and runs the hub—it does not "generate production servers," nor does it make any client/CI claims. The hardened production layer (per-tool authentication boundaries, full failure set, dual-axis version pinning) is built per project on top of this engine.
- Neither Python style implements per-tool authorization, rate limiting, or the "full failure set" (typed errors, lazy startup, atexit cleanup) that hub-level subprocess_adapter.py provides for free—this is still built per project on top of either scaffold.
- The FastMCP template's soft-failure wrapper and environment existence checks are new code and have not yet been backported to the original template, so what the two styles provide out of the box differs slightly.
- The Node template does not yet render the title and annotations fields; the repository does not bundle node_modules, so the changed call shape cannot be executed in tests.
- Tool design lint is advisory by default; only --lint-strict makes error-level findings fatal.
- Test counts: on a clean checkout (Python 3.12), using pip install -e .[dev], 348 passed, 8 skipped, 0 failed. The 8 skipped tests are skipped automatically when required resources or conditions are missing.
Commercial Support
Maintained by Jaimen Bell. For production MCP integration, custom servers, or agent reliability work, see jaimenbell.dev. The MCP Starter Kit provides templates, a build manual, and packaging experience.