mcpgen-cli 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.
- mcpgen_cli-0.1.0/.github/workflows/ci.yml +29 -0
- mcpgen_cli-0.1.0/.gitignore +73 -0
- mcpgen_cli-0.1.0/PKG-INFO +155 -0
- mcpgen_cli-0.1.0/README.md +124 -0
- mcpgen_cli-0.1.0/examples/swagger_petstore_openapi_3_0_mcp/requirements.txt +5 -0
- mcpgen_cli-0.1.0/examples/swagger_petstore_openapi_3_0_mcp/server.py +1253 -0
- mcpgen_cli-0.1.0/mcpgen/__init__.py +5 -0
- mcpgen_cli-0.1.0/mcpgen/cli.py +199 -0
- mcpgen_cli-0.1.0/mcpgen/generator/__init__.py +3 -0
- mcpgen_cli-0.1.0/mcpgen/generator/python.py +90 -0
- mcpgen_cli-0.1.0/mcpgen/ir/__init__.py +3 -0
- mcpgen_cli-0.1.0/mcpgen/ir/models.py +87 -0
- mcpgen_cli-0.1.0/mcpgen/parser/__init__.py +3 -0
- mcpgen_cli-0.1.0/mcpgen/parser/loader.py +144 -0
- mcpgen_cli-0.1.0/mcpgen/parser/openapi.py +374 -0
- mcpgen_cli-0.1.0/mcpgen/parser/postman.py +216 -0
- mcpgen_cli-0.1.0/mcpgen/templates/python/requirements.txt.jinja2 +5 -0
- mcpgen_cli-0.1.0/mcpgen/templates/python/server.py.jinja2 +165 -0
- mcpgen_cli-0.1.0/pyproject.toml +52 -0
- mcpgen_cli-0.1.0/tests/__init__.py +0 -0
- mcpgen_cli-0.1.0/tests/fixtures/petstore.json +1 -0
- mcpgen_cli-0.1.0/tests/test_cli.py +67 -0
- mcpgen_cli-0.1.0/tests/test_generator.py +79 -0
- mcpgen_cli-0.1.0/tests/test_parser.py +90 -0
|
@@ -0,0 +1,29 @@
|
|
|
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"]
|
|
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
|
+
pip install -e ".[dev]"
|
|
27
|
+
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: pytest tests/ -v
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
*.egg-info/
|
|
13
|
+
*.egg
|
|
14
|
+
|
|
15
|
+
# Virtual environment
|
|
16
|
+
venv/
|
|
17
|
+
.env
|
|
18
|
+
.venv
|
|
19
|
+
|
|
20
|
+
# pyenv
|
|
21
|
+
.python-version
|
|
22
|
+
|
|
23
|
+
# Installer logs
|
|
24
|
+
pip-log.txt
|
|
25
|
+
pip-delete-this-directory.txt
|
|
26
|
+
|
|
27
|
+
# Unit test / coverage reports
|
|
28
|
+
htmlcov/
|
|
29
|
+
.tox/
|
|
30
|
+
.nox/
|
|
31
|
+
.coverage
|
|
32
|
+
.coverage.*
|
|
33
|
+
.cache
|
|
34
|
+
nosetests.xml
|
|
35
|
+
coverage.xml
|
|
36
|
+
*.cover
|
|
37
|
+
*.py,cover
|
|
38
|
+
.hypothesis/
|
|
39
|
+
.pytest_cache/
|
|
40
|
+
|
|
41
|
+
# Jupyter Notebook
|
|
42
|
+
.ipynb_checkpoints
|
|
43
|
+
|
|
44
|
+
# pytype static type analyzer
|
|
45
|
+
.pytype/
|
|
46
|
+
|
|
47
|
+
# IDE / editor files
|
|
48
|
+
.idea/
|
|
49
|
+
.vscode/
|
|
50
|
+
*.swp
|
|
51
|
+
*.swo
|
|
52
|
+
*~
|
|
53
|
+
|
|
54
|
+
# OS generated files
|
|
55
|
+
.DS_Store
|
|
56
|
+
.DS_Store?
|
|
57
|
+
._*
|
|
58
|
+
.Spotlight-V100
|
|
59
|
+
.Trashes
|
|
60
|
+
ehthumbs.db
|
|
61
|
+
Thumbs.db
|
|
62
|
+
|
|
63
|
+
# Project-specific
|
|
64
|
+
mcp-demo/
|
|
65
|
+
*.cast
|
|
66
|
+
*.gif
|
|
67
|
+
frames/
|
|
68
|
+
node_modules/
|
|
69
|
+
config.yml
|
|
70
|
+
demo2.yml
|
|
71
|
+
|
|
72
|
+
# Environment variables
|
|
73
|
+
.env
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcpgen-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Turn any API into an MCP server in 30 seconds
|
|
5
|
+
Project-URL: Homepage, https://github.com/JnanaSrota/mcpgen
|
|
6
|
+
Project-URL: Repository, https://github.com/JnanaSrota/mcpgen
|
|
7
|
+
Project-URL: Issues, https://github.com/JnanaSrota/mcpgen/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/JnanaSrota/mcpgen#readme
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: anthropic,api,claude,code-generation,llm,mcp,openapi
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: httpx>=0.27.0
|
|
21
|
+
Requires-Dist: jinja2>=3.1.0
|
|
22
|
+
Requires-Dist: mcp>=1.0.0
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0.0
|
|
25
|
+
Requires-Dist: rich>=13.7.0
|
|
26
|
+
Requires-Dist: typer>=0.12.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# mcpgen
|
|
33
|
+
|
|
34
|
+
> Turn any API into an MCP server in 30 seconds.
|
|
35
|
+
|
|
36
|
+
[](https://asciinema.org/a/r5QCO433SyihhTjx)
|
|
37
|
+
|
|
38
|
+
[](https://badge.fury.io/py/mcpgen)
|
|
39
|
+
[](https://opensource.org/licenses/MIT)
|
|
40
|
+
[](https://www.python.org/downloads/)
|
|
41
|
+
|
|
42
|
+
Point mcpgen at an OpenAPI spec or Postman collection. Get back a complete, **source-code MCP server you own** — no runtime dependency on mcpgen, no black box, no lock-in. Read it. Modify it. Ship it.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install mcpgen
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quickstart
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# From a URL
|
|
56
|
+
mcpgen https://petstore3.swagger.io/api/v3/openapi.json
|
|
57
|
+
|
|
58
|
+
# From a local file
|
|
59
|
+
mcpgen stripe.yaml
|
|
60
|
+
|
|
61
|
+
# Preview without writing anything
|
|
62
|
+
mcpgen openapi.json --dry-run
|
|
63
|
+
|
|
64
|
+
# Custom output directory
|
|
65
|
+
mcpgen openapi.json --output ~/my-mcp-servers
|
|
66
|
+
|
|
67
|
+
# Control the output name
|
|
68
|
+
mcpgen https://petstore3.swagger.io/api/v3/openapi.json --name "Petstore"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
That's it. mcpgen reads your spec and writes a Python MCP server to disk.
|
|
72
|
+
|
|
73
|
+
## What you get
|
|
74
|
+
|
|
75
|
+
A self-contained directory you can read, edit, and deploy anywhere:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
stripe_api_mcp/
|
|
79
|
+
├── server.py ← the MCP server (yours to customize)
|
|
80
|
+
└── requirements.txt ← httpx, mcp
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Run it immediately:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cd stripe_api_mcp
|
|
87
|
+
pip install -r requirements.txt
|
|
88
|
+
export STRIPE_API_TOKEN="sk_live_..."
|
|
89
|
+
python server.py
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Add to Claude Desktop
|
|
93
|
+
|
|
94
|
+
mcpgen prints the exact config block to paste into `claude_desktop_config.json`:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"stripe-api-mcp": {
|
|
100
|
+
"command": "python",
|
|
101
|
+
"args": ["/path/to/stripe_api_mcp/server.py"],
|
|
102
|
+
"env": { "STRIPE_API_TOKEN": "your-key-here" }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Supported inputs
|
|
109
|
+
|
|
110
|
+
| Format | Example |
|
|
111
|
+
|-------------------------|------------------------------------------------------|
|
|
112
|
+
| OpenAPI 3.x JSON | `mcpgen openapi.json` |
|
|
113
|
+
| OpenAPI 3.x YAML | `mcpgen api.yaml` |
|
|
114
|
+
| URL (OpenAPI) | `mcpgen https://api.example.com/openapi.json` |
|
|
115
|
+
| Postman Collection v2.1 | `mcpgen collection.json` |
|
|
116
|
+
|
|
117
|
+
## Why mcpgen?
|
|
118
|
+
|
|
119
|
+
Most API-to-MCP tools are **runtime proxies** — your server only works as long as their service does. mcpgen is different:
|
|
120
|
+
|
|
121
|
+
- **You own the code.** The output is plain Python. Read it, audit it, fork it.
|
|
122
|
+
- **No runtime dependency.** mcpgen is only needed to generate. After that, throw it away.
|
|
123
|
+
- **Deploy anywhere.** The generated server runs wherever Python runs.
|
|
124
|
+
- **Customize freely.** Auth logic, retry behavior, response shaping — it's all in a file you control.
|
|
125
|
+
|
|
126
|
+
## Tested APIs
|
|
127
|
+
|
|
128
|
+
- Petstore (`https://petstore3.swagger.io/api/v3/openapi.json`)
|
|
129
|
+
- GitHub REST API
|
|
130
|
+
- Stripe (subset)
|
|
131
|
+
- Any OpenAPI 3.x spec
|
|
132
|
+
|
|
133
|
+
## Roadmap
|
|
134
|
+
|
|
135
|
+
Contributions are welcome in these areas:
|
|
136
|
+
|
|
137
|
+
- [ ] TypeScript output (`--lang ts`)
|
|
138
|
+
- [ ] Swagger 2.x support
|
|
139
|
+
- [ ] `$ref` recursive resolution
|
|
140
|
+
- [ ] Auto-detect OpenAPI URL from well-known paths (`.well-known/openapi.json`)
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
PRs and issues welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
git clone https://github.com/JnanaSrota/mcpgen
|
|
148
|
+
cd mcpgen
|
|
149
|
+
pip install -e ".[dev]"
|
|
150
|
+
pytest
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT — do whatever you want with mcpgen and with the code it generates.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# mcpgen
|
|
2
|
+
|
|
3
|
+
> Turn any API into an MCP server in 30 seconds.
|
|
4
|
+
|
|
5
|
+
[](https://asciinema.org/a/r5QCO433SyihhTjx)
|
|
6
|
+
|
|
7
|
+
[](https://badge.fury.io/py/mcpgen)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://www.python.org/downloads/)
|
|
10
|
+
|
|
11
|
+
Point mcpgen at an OpenAPI spec or Postman collection. Get back a complete, **source-code MCP server you own** — no runtime dependency on mcpgen, no black box, no lock-in. Read it. Modify it. Ship it.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install mcpgen
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quickstart
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# From a URL
|
|
25
|
+
mcpgen https://petstore3.swagger.io/api/v3/openapi.json
|
|
26
|
+
|
|
27
|
+
# From a local file
|
|
28
|
+
mcpgen stripe.yaml
|
|
29
|
+
|
|
30
|
+
# Preview without writing anything
|
|
31
|
+
mcpgen openapi.json --dry-run
|
|
32
|
+
|
|
33
|
+
# Custom output directory
|
|
34
|
+
mcpgen openapi.json --output ~/my-mcp-servers
|
|
35
|
+
|
|
36
|
+
# Control the output name
|
|
37
|
+
mcpgen https://petstore3.swagger.io/api/v3/openapi.json --name "Petstore"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
That's it. mcpgen reads your spec and writes a Python MCP server to disk.
|
|
41
|
+
|
|
42
|
+
## What you get
|
|
43
|
+
|
|
44
|
+
A self-contained directory you can read, edit, and deploy anywhere:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
stripe_api_mcp/
|
|
48
|
+
├── server.py ← the MCP server (yours to customize)
|
|
49
|
+
└── requirements.txt ← httpx, mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Run it immediately:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cd stripe_api_mcp
|
|
56
|
+
pip install -r requirements.txt
|
|
57
|
+
export STRIPE_API_TOKEN="sk_live_..."
|
|
58
|
+
python server.py
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Add to Claude Desktop
|
|
62
|
+
|
|
63
|
+
mcpgen prints the exact config block to paste into `claude_desktop_config.json`:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"mcpServers": {
|
|
68
|
+
"stripe-api-mcp": {
|
|
69
|
+
"command": "python",
|
|
70
|
+
"args": ["/path/to/stripe_api_mcp/server.py"],
|
|
71
|
+
"env": { "STRIPE_API_TOKEN": "your-key-here" }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Supported inputs
|
|
78
|
+
|
|
79
|
+
| Format | Example |
|
|
80
|
+
|-------------------------|------------------------------------------------------|
|
|
81
|
+
| OpenAPI 3.x JSON | `mcpgen openapi.json` |
|
|
82
|
+
| OpenAPI 3.x YAML | `mcpgen api.yaml` |
|
|
83
|
+
| URL (OpenAPI) | `mcpgen https://api.example.com/openapi.json` |
|
|
84
|
+
| Postman Collection v2.1 | `mcpgen collection.json` |
|
|
85
|
+
|
|
86
|
+
## Why mcpgen?
|
|
87
|
+
|
|
88
|
+
Most API-to-MCP tools are **runtime proxies** — your server only works as long as their service does. mcpgen is different:
|
|
89
|
+
|
|
90
|
+
- **You own the code.** The output is plain Python. Read it, audit it, fork it.
|
|
91
|
+
- **No runtime dependency.** mcpgen is only needed to generate. After that, throw it away.
|
|
92
|
+
- **Deploy anywhere.** The generated server runs wherever Python runs.
|
|
93
|
+
- **Customize freely.** Auth logic, retry behavior, response shaping — it's all in a file you control.
|
|
94
|
+
|
|
95
|
+
## Tested APIs
|
|
96
|
+
|
|
97
|
+
- Petstore (`https://petstore3.swagger.io/api/v3/openapi.json`)
|
|
98
|
+
- GitHub REST API
|
|
99
|
+
- Stripe (subset)
|
|
100
|
+
- Any OpenAPI 3.x spec
|
|
101
|
+
|
|
102
|
+
## Roadmap
|
|
103
|
+
|
|
104
|
+
Contributions are welcome in these areas:
|
|
105
|
+
|
|
106
|
+
- [ ] TypeScript output (`--lang ts`)
|
|
107
|
+
- [ ] Swagger 2.x support
|
|
108
|
+
- [ ] `$ref` recursive resolution
|
|
109
|
+
- [ ] Auto-detect OpenAPI URL from well-known paths (`.well-known/openapi.json`)
|
|
110
|
+
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
PRs and issues welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
git clone https://github.com/JnanaSrota/mcpgen
|
|
117
|
+
cd mcpgen
|
|
118
|
+
pip install -e ".[dev]"
|
|
119
|
+
pytest
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT — do whatever you want with mcpgen and with the code it generates.
|