Skip to main content

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.

Python 3.10+ License: MIT Tests PyPI


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-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.py with JSON-RPC request routing
  • Tool definitions and handlers in tools.py
  • Resource handlers in resources.py
  • A pyproject.toml configured with hatchling
  • A Dockerfile for containerized deployment
  • A README.md with 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-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 given
  • pkg_name - Python package name (snake_case)
  • title - human readable title
  • description - project description
  • author - author name
  • tools - list of tool names
  • resources - 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_forge-0.1.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_forge-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_forge-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_server_forge-0.1.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for mcp_server_forge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ae40e6e58040caf216464ba1249c4e08c92fae8e6a59c20a3cc1f882bd9e79f
MD5 e0b4e3f669396aa8ca50516476f9b5fa
BLAKE2b-256 3c8b8798f756a2c8366f0945c2a750fbda971873624fa4ac6c09630e431e4e60

See more details on using hashes here.

File details

Details for the file mcp_server_forge-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_forge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 456d630827197ef587b55bfc598187f2183a464403666e5329699a844016b069
MD5 a97864341b76df934480d793fa011c13
BLAKE2b-256 03a87069152814ee7e853d99b00c8adea2a48cc525ed2499a6057ef0dd01a72f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page