Scaffold, test, and publish Model Context Protocol (MCP) servers in seconds
Project description
๐จ MCP Forge
New here? Start with the Getting Started Guide.
Scaffold, test, and publish Model Context Protocol (MCP) servers in seconds.
The Problem
Building MCP servers involves too much boilerplate. Every new server needs the same JSON-RPC handling, tool definitions, resource handlers, Dockerfile, tests, and packaging config. You end up copying from old projects, fixing import paths, and wasting time on plumbing instead of building.
MCP Forge fixes this. One command generates a complete, ready-to-develop MCP server project. Another command tests it. Another validates compliance. Another publishes it.
Features
- ๐๏ธ Scaffold full MCP server projects from templates in one command
- ๐งช Test servers with a built-in MCP test harness (JSON-RPC over stdio)
- ๐ Validate server compliance against the MCP specification
- ๐ฆ Publish to PyPI with a single command
- ๐จ Jinja2-powered scaffolding with clean, extensible templates
- ๐ณ Dockerfile included in every generated project
- โก Zero config needed for standard MCP servers
Quick Start
Install
pip install mcp-server-forge
Create a new MCP server
mcp-forge new my-server --tools weather,calculator
That's it. You now have a complete, runnable MCP server:
my-server/
โโโ Dockerfile
โโโ README.md
โโโ pyproject.toml
โโโ .gitignore
โโโ src/
โ โโโ my_server/
โ โโโ __init__.py
โ โโโ server.py
โ โโโ tools.py
โ โโโ resources.py
โโโ tests/
โโโ test_my_server.py
Test your server
cd my-server
pip install -e .
mcp-forge test --cmd 'python -m my_server.server'
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Forge Test Results โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Test โ Status โ Details โ
โโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ server_start โ PASS โ Server started โ
โ initialize โ PASS โ initialize response valid โ
โ tools/list โ PASS โ Found 2 tools โ
โ tools/call โ PASS โ Called 'weather' OK โ
โ ping โ PASS โ Ping OK โ
โ unknown โ PASS โ Correctly returned error โ
โ server_stop โ PASS โ Server stopped cleanly โ
โโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 7/7 passed All tests passed! โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Validate compliance
mcp-forge validate ./my-server
Publish
mcp-forge publish ./my-server
mcp-forge publish ./my-server --repository testpypi --dry-run
Scaffolding
The new command generates a complete MCP server with:
- A fully functional
server.pywith JSON-RPC request routing - Tool definitions and handlers in
tools.py - Resource handlers in
resources.py - A
pyproject.tomlconfigured with hatchling - A
Dockerfilefor containerized deployment - A
README.mdwith usage instructions - Basic tests and
.gitignore
Options
mcp-forge new my-server \
--tools weather,calculator,search \
--resources "file://data,http://api" \
--description "My awesome MCP server" \
--author "Your Name" \
--output-dir ./projects
Templates
MCP Forge uses Jinja2 templates internally. Each generated file comes from a template in the templates/ directory:
| Template | Generates |
|---|---|
server.py.j2 |
Main server with JSON-RPC routing |
tools.py.j2 |
Tool definitions and handlers |
resources.py.j2 |
Resource definitions and handlers |
project_pyproject.toml.j2 |
Package configuration |
project_readme.md.j2 |
Project README |
dockerfile.j2 |
Docker container config |
init.py.j2 |
Package init file |
Testing
The built-in test harness starts your MCP server as a subprocess and sends JSON-RPC requests over stdio, validating:
- Server startup and clean shutdown
- initialize response with protocol version, capabilities, and server info
- tools/list returns valid tool definitions
- tools/call executes a tool and returns content
- ping responds correctly
- Unknown methods return proper JSON-RPC errors
Validation
The validate command checks your project for:
- Required file structure (
src/,pyproject.toml,server.py,tools.py) - Tool definitions match the MCP schema (name, description, inputSchema)
- Initialize responses include all required fields
- Tool results contain valid content arrays
Publishing
The publish command wraps build and twine for a smooth publishing experience:
# Build and publish to PyPI
mcp-forge publish .
# Dry run (build only)
mcp-forge publish . --dry-run
# Publish to TestPyPI
mcp-forge publish . --repository testpypi
Make sure you have build and twine installed:
pip install mcp-server-forge[publish]
Template Customization
The scaffolding uses Jinja2 templates internally. To customize the generated code, fork the repo and modify the templates in src/mcp_forge/templates/. The Jinja2 context includes:
project_name- the project name as givenpkg_name- Python package name (snake_case)title- human readable titledescription- project descriptionauthor- author nametools- list of tool namesresources- list of resource URI patterns
Development
git clone https://github.com/manasvardhan/mcp-forge.git
cd mcp-forge
pip install -e ".[dev]"
pytest
License
MIT License. See LICENSE for details.
Built with ๐จ by Manas Vardhan
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_forge-0.1.1.tar.gz.
File metadata
- Download URL: mcp_server_forge-0.1.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de9063f18d8c76596c52eb3fab16256c2f7a0cec50a988061aa4806ed4cc0dc0
|
|
| MD5 |
b321769bc3af0f27e320233928fc900c
|
|
| BLAKE2b-256 |
1d175231c7720375a8fcb186b96bf8d358f7f044d65b89dcee4d7501a8f1aff0
|
File details
Details for the file mcp_server_forge-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mcp_server_forge-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6901657dd9e4c7c5904130b63033d9de9f963531ef8863ec0747f2dfdb0f562
|
|
| MD5 |
37dfa96fe819547df2422d8b6eabf131
|
|
| BLAKE2b-256 |
d174f5feae82a9a224d59249f5ed1475112a20f81c03fe3e1ffbd52891cb26c6
|