mcp-server-forge 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_server_forge-0.1.0/.github/workflows/ci.yml +36 -0
- mcp_server_forge-0.1.0/.gitignore +14 -0
- mcp_server_forge-0.1.0/CONTRIBUTING.md +47 -0
- mcp_server_forge-0.1.0/GETTING_STARTED.md +155 -0
- mcp_server_forge-0.1.0/LICENSE +21 -0
- mcp_server_forge-0.1.0/PKG-INFO +242 -0
- mcp_server_forge-0.1.0/README.md +207 -0
- mcp_server_forge-0.1.0/ROADMAP.md +19 -0
- mcp_server_forge-0.1.0/examples/weather_server/pyproject.toml +16 -0
- mcp_server_forge-0.1.0/examples/weather_server/src/weather_server/__init__.py +3 -0
- mcp_server_forge-0.1.0/examples/weather_server/src/weather_server/resources.py +12 -0
- mcp_server_forge-0.1.0/examples/weather_server/src/weather_server/server.py +95 -0
- mcp_server_forge-0.1.0/examples/weather_server/src/weather_server/tools.py +83 -0
- mcp_server_forge-0.1.0/pyproject.toml +57 -0
- mcp_server_forge-0.1.0/src/mcp_forge/__init__.py +3 -0
- mcp_server_forge-0.1.0/src/mcp_forge/cli.py +178 -0
- mcp_server_forge-0.1.0/src/mcp_forge/scaffold.py +115 -0
- mcp_server_forge-0.1.0/src/mcp_forge/templates/dockerfile.j2 +10 -0
- mcp_server_forge-0.1.0/src/mcp_forge/templates/init.py.j2 +3 -0
- mcp_server_forge-0.1.0/src/mcp_forge/templates/project_pyproject.toml.j2 +19 -0
- mcp_server_forge-0.1.0/src/mcp_forge/templates/project_readme.md.j2 +42 -0
- mcp_server_forge-0.1.0/src/mcp_forge/templates/resources.py.j2 +31 -0
- mcp_server_forge-0.1.0/src/mcp_forge/templates/server.py.j2 +108 -0
- mcp_server_forge-0.1.0/src/mcp_forge/templates/tools.py.j2 +50 -0
- mcp_server_forge-0.1.0/src/mcp_forge/tester.py +227 -0
- mcp_server_forge-0.1.0/src/mcp_forge/validator.py +192 -0
- mcp_server_forge-0.1.0/tests/__init__.py +0 -0
- mcp_server_forge-0.1.0/tests/test_cli.py +36 -0
- mcp_server_forge-0.1.0/tests/test_scaffold.py +70 -0
- mcp_server_forge-0.1.0/tests/test_validator.py +79 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install -e ".[dev]"
|
|
28
|
+
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: pytest --cov=mcp_forge --cov-report=term-missing
|
|
31
|
+
|
|
32
|
+
- name: Check types
|
|
33
|
+
run: |
|
|
34
|
+
pip install mypy
|
|
35
|
+
mypy src/mcp_forge --ignore-missing-imports
|
|
36
|
+
continue-on-error: true
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Contributing to MCP Forge
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! Here's how to get started.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/manasvardhan/mcp-forge.git
|
|
9
|
+
cd mcp-forge
|
|
10
|
+
python -m venv .venv
|
|
11
|
+
source .venv/bin/activate
|
|
12
|
+
pip install -e ".[dev]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Running Tests
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pytest
|
|
19
|
+
pytest --cov=mcp_forge
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Code Style
|
|
23
|
+
|
|
24
|
+
- Python 3.10+ with type hints throughout
|
|
25
|
+
- Use `from __future__ import annotations` in all modules
|
|
26
|
+
- Follow PEP 8
|
|
27
|
+
|
|
28
|
+
## Pull Requests
|
|
29
|
+
|
|
30
|
+
1. Fork the repo and create a branch from `main`
|
|
31
|
+
2. Add tests for any new functionality
|
|
32
|
+
3. Make sure all tests pass
|
|
33
|
+
4. Update documentation if needed
|
|
34
|
+
5. Open a PR with a clear description
|
|
35
|
+
|
|
36
|
+
## Reporting Issues
|
|
37
|
+
|
|
38
|
+
Open an issue on GitHub with:
|
|
39
|
+
|
|
40
|
+
- A clear description of the problem
|
|
41
|
+
- Steps to reproduce
|
|
42
|
+
- Expected vs actual behavior
|
|
43
|
+
- Python version and OS
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Getting Started with mcp-forge
|
|
2
|
+
|
|
3
|
+
A step-by-step guide to get up and running from scratch.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
You need **Python 3.10 or newer** installed on your machine.
|
|
8
|
+
|
|
9
|
+
**Check if you have Python:**
|
|
10
|
+
```bash
|
|
11
|
+
python3 --version
|
|
12
|
+
```
|
|
13
|
+
If you see `Python 3.10.x` or higher, you're good. If not, download it from [python.org](https://www.python.org/downloads/).
|
|
14
|
+
|
|
15
|
+
## Step 1: Clone the repository
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/ManasVardhan/mcp-forge.git
|
|
19
|
+
cd mcp-forge
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Step 2: Create a virtual environment
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python3 -m venv venv
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Activate it:**
|
|
29
|
+
|
|
30
|
+
- **Mac/Linux:** `source venv/bin/activate`
|
|
31
|
+
- **Windows:** `venv\Scripts\activate`
|
|
32
|
+
|
|
33
|
+
## Step 3: Install the package
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install -e ".[dev]"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Step 4: Run the tests
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pytest tests/ -v
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
All 23 tests should pass.
|
|
46
|
+
|
|
47
|
+
## Step 5: Try it out
|
|
48
|
+
|
|
49
|
+
### 5a. Scaffold a new MCP server
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
mcp-forge new my-first-server --tools weather,calculator
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This generates a complete MCP server project. Take a look at what was created:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
ls -la my-first-server/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
You should see:
|
|
62
|
+
```
|
|
63
|
+
my-first-server/
|
|
64
|
+
src/
|
|
65
|
+
server.py # Main server with JSON-RPC handler
|
|
66
|
+
tools/
|
|
67
|
+
weather.py # Weather tool stub
|
|
68
|
+
calculator.py # Calculator tool stub
|
|
69
|
+
tests/
|
|
70
|
+
test_server.py # Test file
|
|
71
|
+
pyproject.toml # Package config
|
|
72
|
+
Dockerfile # Container config
|
|
73
|
+
README.md # Auto-generated docs
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 5b. Look at the generated server
|
|
77
|
+
|
|
78
|
+
Open `my-first-server/src/server.py` in any text editor. You'll see a working MCP server with:
|
|
79
|
+
- JSON-RPC stdio transport (how AI models communicate with MCP servers)
|
|
80
|
+
- Tool handler routing
|
|
81
|
+
- Proper error handling
|
|
82
|
+
|
|
83
|
+
### 5c. Validate the server
|
|
84
|
+
|
|
85
|
+
Check that the generated server follows the MCP specification:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
mcp-forge validate my-first-server/
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
You should see all checks passing.
|
|
92
|
+
|
|
93
|
+
### 5d. Test the server
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
mcp-forge test my-first-server/
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This sends test JSON-RPC requests to your server and shows the responses.
|
|
100
|
+
|
|
101
|
+
### 5e. Check out the example weather server
|
|
102
|
+
|
|
103
|
+
There's a pre-built example in the repo:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
ls examples/weather_server/
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 5f. Try different tool combinations
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
mcp-forge new api-server --tools search,translate,summarize
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Each tool gets its own file with a stub implementation ready to fill in.
|
|
116
|
+
|
|
117
|
+
## Step 6: Build your own MCP server
|
|
118
|
+
|
|
119
|
+
1. Scaffold it:
|
|
120
|
+
```bash
|
|
121
|
+
mcp-forge new my-custom-server --tools mytool
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
2. Edit `my-custom-server/src/tools/mytool.py` to add your logic
|
|
125
|
+
|
|
126
|
+
3. Test it:
|
|
127
|
+
```bash
|
|
128
|
+
mcp-forge test my-custom-server/
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
4. Validate it:
|
|
132
|
+
```bash
|
|
133
|
+
mcp-forge validate my-custom-server/
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Step 7: Run the linter (optional)
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
ruff check src/ tests/
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Troubleshooting
|
|
143
|
+
|
|
144
|
+
| Problem | Solution |
|
|
145
|
+
|---------|----------|
|
|
146
|
+
| `python3: command not found` | Install Python from [python.org](https://www.python.org/downloads/) |
|
|
147
|
+
| `No module named mcp_forge` | Make sure you ran `pip install -e ".[dev]"` with the venv activated |
|
|
148
|
+
| `mcp-forge: command not found` | Make sure your venv is activated |
|
|
149
|
+
| Tests fail | Make sure you're on the latest `main` branch: `git pull origin main` |
|
|
150
|
+
|
|
151
|
+
## What's next?
|
|
152
|
+
|
|
153
|
+
- Read the full [README](README.md) for custom templates, publishing, and advanced options
|
|
154
|
+
- Check `examples/weather_server/` for a complete working MCP server
|
|
155
|
+
- Try connecting your MCP server to Claude Desktop or another MCP-compatible AI client
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Manas Vardhan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-server-forge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Scaffold, test, and publish Model Context Protocol (MCP) servers in seconds
|
|
5
|
+
Project-URL: Homepage, https://github.com/manasvardhan/mcp-forge
|
|
6
|
+
Project-URL: Repository, https://github.com/manasvardhan/mcp-forge
|
|
7
|
+
Project-URL: Issues, https://github.com/manasvardhan/mcp-forge/issues
|
|
8
|
+
Author: Manas Vardhan
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,cli,mcp,model-context-protocol,scaffold
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Requires-Dist: click>=8.1
|
|
25
|
+
Requires-Dist: jinja2>=3.1
|
|
26
|
+
Requires-Dist: jsonschema>=4.20
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
31
|
+
Provides-Extra: publish
|
|
32
|
+
Requires-Dist: build>=1.0; extra == 'publish'
|
|
33
|
+
Requires-Dist: twine>=4.0; extra == 'publish'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# 🔨 MCP Forge
|
|
38
|
+
|
|
39
|
+
> **New here?** Start with the [Getting Started Guide](GETTING_STARTED.md).
|
|
40
|
+
|
|
41
|
+
**Scaffold, test, and publish Model Context Protocol (MCP) servers in seconds.**
|
|
42
|
+
|
|
43
|
+
[](https://www.python.org/downloads/)
|
|
44
|
+
[](LICENSE)
|
|
45
|
+
[]()
|
|
46
|
+
[]()
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## The Problem
|
|
51
|
+
|
|
52
|
+
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.
|
|
53
|
+
|
|
54
|
+
**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.
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- 🏗️ **Scaffold** full MCP server projects from templates in one command
|
|
59
|
+
- 🧪 **Test** servers with a built-in MCP test harness (JSON-RPC over stdio)
|
|
60
|
+
- 🔍 **Validate** server compliance against the MCP specification
|
|
61
|
+
- 📦 **Publish** to PyPI with a single command
|
|
62
|
+
- 🎨 **Jinja2-powered scaffolding** with clean, extensible templates
|
|
63
|
+
- 🐳 **Dockerfile** included in every generated project
|
|
64
|
+
- ⚡ **Zero config** needed for standard MCP servers
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### Install
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install mcp-forge
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Create a new MCP server
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
mcp-forge new my-server --tools weather,calculator
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
That's it. You now have a complete, runnable MCP server:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
my-server/
|
|
84
|
+
├── Dockerfile
|
|
85
|
+
├── README.md
|
|
86
|
+
├── pyproject.toml
|
|
87
|
+
├── .gitignore
|
|
88
|
+
├── src/
|
|
89
|
+
│ └── my_server/
|
|
90
|
+
│ ├── __init__.py
|
|
91
|
+
│ ├── server.py
|
|
92
|
+
│ ├── tools.py
|
|
93
|
+
│ └── resources.py
|
|
94
|
+
└── tests/
|
|
95
|
+
└── test_my_server.py
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Test your server
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
cd my-server
|
|
102
|
+
pip install -e .
|
|
103
|
+
mcp-forge test --cmd 'python -m my_server.server'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
┌──────────────────────────────────────────────────┐
|
|
108
|
+
│ MCP Forge Test Results │
|
|
109
|
+
├──────────────┬────────┬──────────────────────────┤
|
|
110
|
+
│ Test │ Status │ Details │
|
|
111
|
+
├──────────────┼────────┼──────────────────────────┤
|
|
112
|
+
│ server_start │ PASS │ Server started │
|
|
113
|
+
│ initialize │ PASS │ initialize response valid │
|
|
114
|
+
│ tools/list │ PASS │ Found 2 tools │
|
|
115
|
+
│ tools/call │ PASS │ Called 'weather' OK │
|
|
116
|
+
│ ping │ PASS │ Ping OK │
|
|
117
|
+
│ unknown │ PASS │ Correctly returned error │
|
|
118
|
+
│ server_stop │ PASS │ Server stopped cleanly │
|
|
119
|
+
├──────────────┴────────┴──────────────────────────┤
|
|
120
|
+
│ 7/7 passed All tests passed! │
|
|
121
|
+
└──────────────────────────────────────────────────┘
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Validate compliance
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
mcp-forge validate ./my-server
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Publish
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
mcp-forge publish ./my-server
|
|
134
|
+
mcp-forge publish ./my-server --repository testpypi --dry-run
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Scaffolding
|
|
138
|
+
|
|
139
|
+
The `new` command generates a complete MCP server with:
|
|
140
|
+
|
|
141
|
+
- A fully functional `server.py` with JSON-RPC request routing
|
|
142
|
+
- Tool definitions and handlers in `tools.py`
|
|
143
|
+
- Resource handlers in `resources.py`
|
|
144
|
+
- A `pyproject.toml` configured with hatchling
|
|
145
|
+
- A `Dockerfile` for containerized deployment
|
|
146
|
+
- A `README.md` with usage instructions
|
|
147
|
+
- Basic tests and `.gitignore`
|
|
148
|
+
|
|
149
|
+
### Options
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
mcp-forge new my-server \
|
|
153
|
+
--tools weather,calculator,search \
|
|
154
|
+
--resources "file://data,http://api" \
|
|
155
|
+
--description "My awesome MCP server" \
|
|
156
|
+
--author "Your Name" \
|
|
157
|
+
--output-dir ./projects
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Templates
|
|
161
|
+
|
|
162
|
+
MCP Forge uses Jinja2 templates internally. Each generated file comes from a template in the `templates/` directory:
|
|
163
|
+
|
|
164
|
+
| Template | Generates |
|
|
165
|
+
|----------|-----------|
|
|
166
|
+
| `server.py.j2` | Main server with JSON-RPC routing |
|
|
167
|
+
| `tools.py.j2` | Tool definitions and handlers |
|
|
168
|
+
| `resources.py.j2` | Resource definitions and handlers |
|
|
169
|
+
| `project_pyproject.toml.j2` | Package configuration |
|
|
170
|
+
| `project_readme.md.j2` | Project README |
|
|
171
|
+
| `dockerfile.j2` | Docker container config |
|
|
172
|
+
| `init.py.j2` | Package init file |
|
|
173
|
+
|
|
174
|
+
## Testing
|
|
175
|
+
|
|
176
|
+
The built-in test harness starts your MCP server as a subprocess and sends JSON-RPC requests over stdio, validating:
|
|
177
|
+
|
|
178
|
+
- **Server startup** and clean shutdown
|
|
179
|
+
- **initialize** response with protocol version, capabilities, and server info
|
|
180
|
+
- **tools/list** returns valid tool definitions
|
|
181
|
+
- **tools/call** executes a tool and returns content
|
|
182
|
+
- **ping** responds correctly
|
|
183
|
+
- **Unknown methods** return proper JSON-RPC errors
|
|
184
|
+
|
|
185
|
+
## Validation
|
|
186
|
+
|
|
187
|
+
The `validate` command checks your project for:
|
|
188
|
+
|
|
189
|
+
- Required file structure (`src/`, `pyproject.toml`, `server.py`, `tools.py`)
|
|
190
|
+
- Tool definitions match the MCP schema (name, description, inputSchema)
|
|
191
|
+
- Initialize responses include all required fields
|
|
192
|
+
- Tool results contain valid content arrays
|
|
193
|
+
|
|
194
|
+
## Publishing
|
|
195
|
+
|
|
196
|
+
The `publish` command wraps `build` and `twine` for a smooth publishing experience:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Build and publish to PyPI
|
|
200
|
+
mcp-forge publish .
|
|
201
|
+
|
|
202
|
+
# Dry run (build only)
|
|
203
|
+
mcp-forge publish . --dry-run
|
|
204
|
+
|
|
205
|
+
# Publish to TestPyPI
|
|
206
|
+
mcp-forge publish . --repository testpypi
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Make sure you have `build` and `twine` installed:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
pip install mcp-forge[publish]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Template Customization
|
|
216
|
+
|
|
217
|
+
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:
|
|
218
|
+
|
|
219
|
+
- `project_name` - the project name as given
|
|
220
|
+
- `pkg_name` - Python package name (snake_case)
|
|
221
|
+
- `title` - human readable title
|
|
222
|
+
- `description` - project description
|
|
223
|
+
- `author` - author name
|
|
224
|
+
- `tools` - list of tool names
|
|
225
|
+
- `resources` - list of resource URI patterns
|
|
226
|
+
|
|
227
|
+
## Development
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
git clone https://github.com/manasvardhan/mcp-forge.git
|
|
231
|
+
cd mcp-forge
|
|
232
|
+
pip install -e ".[dev]"
|
|
233
|
+
pytest
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
Built with 🔨 by [Manas Vardhan](https://github.com/manasvardhan)
|