pymcp-template 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.
- pymcp_template-0.1.0/.github/dependabot.yml +12 -0
- pymcp_template-0.1.0/.github/workflows/pypi-publish.yml +32 -0
- pymcp_template-0.1.0/.github/workflows/uv-pytest.yml +34 -0
- pymcp_template-0.1.0/.gitignore +194 -0
- pymcp_template-0.1.0/.pre-commit-config.yaml +34 -0
- pymcp_template-0.1.0/LICENSE +21 -0
- pymcp_template-0.1.0/PKG-INFO +93 -0
- pymcp_template-0.1.0/README.md +77 -0
- pymcp_template-0.1.0/glama.json +6 -0
- pymcp_template-0.1.0/pyproject.toml +38 -0
- pymcp_template-0.1.0/resources/logo.png +0 -0
- pymcp_template-0.1.0/resources/logo.svg +23 -0
- pymcp_template-0.1.0/smithery.dockerfile +12 -0
- pymcp_template-0.1.0/smithery.yaml +15 -0
- pymcp_template-0.1.0/src/pymcp/__init__.py +0 -0
- pymcp_template-0.1.0/src/pymcp/server.py +214 -0
- pymcp_template-0.1.0/tests/__init__.py +0 -0
- pymcp_template-0.1.0/tests/test_server.py +84 -0
- pymcp_template-0.1.0/uv.lock +663 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "uv" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
# A weekly schedule is reasonable.
|
|
12
|
+
interval: "weekly"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: pypi-publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
release-build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
uses: astral-sh/setup-uv@v5
|
|
19
|
+
|
|
20
|
+
- name: Install the project
|
|
21
|
+
run: uv sync --all-groups
|
|
22
|
+
|
|
23
|
+
- name: Build release distributions
|
|
24
|
+
run: |
|
|
25
|
+
uv build
|
|
26
|
+
|
|
27
|
+
- name: Upload distributions
|
|
28
|
+
env:
|
|
29
|
+
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
|
|
30
|
+
run: |
|
|
31
|
+
# Requires UV_PUBLISH_TOKEN repository secret to be set
|
|
32
|
+
uv publish
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
on:
|
|
2
|
+
push:
|
|
3
|
+
branches: [master]
|
|
4
|
+
paths:
|
|
5
|
+
- "**.py"
|
|
6
|
+
- "pyproject.toml"
|
|
7
|
+
- "uv.lock"
|
|
8
|
+
pull_request:
|
|
9
|
+
paths:
|
|
10
|
+
- "**.py"
|
|
11
|
+
- "pyproject.toml"
|
|
12
|
+
- "uv.lock"
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
name: pytest
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
uv-pytest:
|
|
21
|
+
name: python
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v5
|
|
29
|
+
|
|
30
|
+
- name: Install the project
|
|
31
|
+
run: uv sync --all-groups
|
|
32
|
+
|
|
33
|
+
- name: Run tests using pytest
|
|
34
|
+
run: uv run --group test pytest tests/
|
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Abstra
|
|
171
|
+
# Abstra is an AI-powered process automation framework.
|
|
172
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
173
|
+
# Learn more at https://abstra.io/docs
|
|
174
|
+
.abstra/
|
|
175
|
+
|
|
176
|
+
# Visual Studio Code
|
|
177
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
178
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
179
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
180
|
+
# you could uncomment the following to ignore the enitre vscode folder
|
|
181
|
+
# .vscode/
|
|
182
|
+
|
|
183
|
+
# Ruff stuff:
|
|
184
|
+
.ruff_cache/
|
|
185
|
+
|
|
186
|
+
# PyPI configuration file
|
|
187
|
+
.pypirc
|
|
188
|
+
|
|
189
|
+
# Cursor
|
|
190
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
191
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
192
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
193
|
+
.cursorignore
|
|
194
|
+
.cursorindexingignore
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: python3
|
|
3
|
+
|
|
4
|
+
repos:
|
|
5
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
6
|
+
rev: v5.0.0
|
|
7
|
+
hooks:
|
|
8
|
+
- id: trailing-whitespace
|
|
9
|
+
exclude: tests
|
|
10
|
+
- id: end-of-file-fixer
|
|
11
|
+
- id: check-merge-conflict
|
|
12
|
+
- id: check-case-conflict
|
|
13
|
+
- id: check-json
|
|
14
|
+
- id: check-toml
|
|
15
|
+
exclude: tests/fixtures/invalid_lock/uv\.lock
|
|
16
|
+
- id: check-yaml
|
|
17
|
+
- id: pretty-format-json
|
|
18
|
+
args: [--autofix, --no-ensure-ascii, --no-sort-keys]
|
|
19
|
+
- id: check-ast
|
|
20
|
+
- id: debug-statements
|
|
21
|
+
- id: check-docstring-first
|
|
22
|
+
- id: detect-private-key
|
|
23
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
24
|
+
# Ruff version.
|
|
25
|
+
rev: v0.12.0
|
|
26
|
+
hooks:
|
|
27
|
+
# Run the linter.
|
|
28
|
+
- id: ruff
|
|
29
|
+
args: [--fix, --exit-non-zero-on-fix, --respect-gitignore]
|
|
30
|
+
exclude: ".*uv.lock|.*_static"
|
|
31
|
+
# Run the formatter.
|
|
32
|
+
- id: ruff-format
|
|
33
|
+
args: [--respect-gitignore]
|
|
34
|
+
exclude: ".*uv.lock|.*_static"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Anirban Basu
|
|
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,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pymcp-template
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A template (repository) for developing MCP servers in Python
|
|
5
|
+
Author-email: Anirban Basu <anirbanbasu@users.noreply.github.com>
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: example,mcp-server,model-context-protocol-server,python3,server
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Requires-Dist: fastmcp>=2.9.2
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
[](https://www.python.org/downloads/release/python-3120/) [](https://github.com/anirbanbasu/pymcp/actions/workflows/uv-pytest.yml) [](https://smithery.ai/server/@anirbanbasu/pymcp)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<img width="256" height="84" src="https://raw.githubusercontent.com/anirbanbasu/pymcp/master/resources/logo.svg" alt="pymcp logo" style="filter: invert(1)">
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
Primarily to be used as a template repository for developing MCP servers with [FastMCP](http://gofastmcp.com/) in Python, PyMCP is somewhat inspired by the [official everything MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/everything) in Typescript.
|
|
25
|
+
|
|
26
|
+
# Installation
|
|
27
|
+
|
|
28
|
+
The directory where you clone this repository will be referred to as the _working directory_ or _WD_ hereinafter.
|
|
29
|
+
|
|
30
|
+
Install [uv](https://docs.astral.sh/uv/getting-started/installation/). To install the project with its minimal dependencies in a virtual environment, run the following in the _WD_. To install all non-essential dependencies (_which are required for developing and testing_), replace the `--no-dev` with the `--all-groups` flag in the following command.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv sync --no-dev
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
# Standalone usage
|
|
37
|
+
PyMCP can be started standalone as a MCP server with `stdio` transport by running the following. However, you are unlikely to use it this way.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uv run pymcp
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Furthermore, being a template repository, the code deliberately does not implement `streamable-http` and `sse` transports.
|
|
44
|
+
|
|
45
|
+
# Test with the MCP Inspector
|
|
46
|
+
|
|
47
|
+
The [MCP Inspector](https://github.com/modelcontextprotocol/inspector) is an _official_ Model Context Protocol tool that can be used by developers to test and debug MCP servers. This is the most comprehensive way to explore the MCP server.
|
|
48
|
+
|
|
49
|
+
To use it, you must have Node.js installed. The best way to install and manage `node` as well as packages such as the MCP Inspector is to use the [Node Version Manager (or, `nvm`)](https://github.com/nvm-sh/nvm). Once you have `nvm` installed, you can install and use the latest Long Term Release version of `node` by executing the following.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
nvm install --lts
|
|
53
|
+
nvm use --lts
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Following that, run the MCP Inspector and PyMCP by executing the following in the _WD_.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx @modelcontextprotocol/inspector uv run pymcp
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This will create a local URL at port 6274 with an authentication token, which you can copy and browse to on your browser. Once on the MCP Inspector UI, press _Connect_ to connect to the MCP server. Thereafter, you can explore the tools available on the server.
|
|
63
|
+
|
|
64
|
+
# Use it with Claude Desktop, Visual Studio, and so on
|
|
65
|
+
|
|
66
|
+
The server entry to run with `stdio` transport that you can use with systems such as Claude Desktop, Visual Studio Code, and so on is as follows.
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"command": "uv",
|
|
71
|
+
"args": [
|
|
72
|
+
"run",
|
|
73
|
+
"pymcp"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Instead of having `pymcp` as the last item in the list of `args`, you may need to specify the full path to the script, e.g., _WD_`/.venv/bin/pymcp`.
|
|
79
|
+
|
|
80
|
+
# Contributing
|
|
81
|
+
|
|
82
|
+
Install [`pre-commit`](https://pre-commit.com/) for Git by using the `--all-groups` flag for `uv sync` for the installation of PyMCP.
|
|
83
|
+
|
|
84
|
+
Then enable `pre-commit` by running the following in the _WD_.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pre-commit install
|
|
88
|
+
```
|
|
89
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
90
|
+
|
|
91
|
+
# License
|
|
92
|
+
|
|
93
|
+
[MIT](https://choosealicense.com/licenses/mit/).
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[](https://www.python.org/downloads/release/python-3120/) [](https://github.com/anirbanbasu/pymcp/actions/workflows/uv-pytest.yml) [](https://smithery.ai/server/@anirbanbasu/pymcp)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<p align="center">
|
|
5
|
+
<img width="256" height="84" src="https://raw.githubusercontent.com/anirbanbasu/pymcp/master/resources/logo.svg" alt="pymcp logo" style="filter: invert(1)">
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
Primarily to be used as a template repository for developing MCP servers with [FastMCP](http://gofastmcp.com/) in Python, PyMCP is somewhat inspired by the [official everything MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/everything) in Typescript.
|
|
9
|
+
|
|
10
|
+
# Installation
|
|
11
|
+
|
|
12
|
+
The directory where you clone this repository will be referred to as the _working directory_ or _WD_ hereinafter.
|
|
13
|
+
|
|
14
|
+
Install [uv](https://docs.astral.sh/uv/getting-started/installation/). To install the project with its minimal dependencies in a virtual environment, run the following in the _WD_. To install all non-essential dependencies (_which are required for developing and testing_), replace the `--no-dev` with the `--all-groups` flag in the following command.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv sync --no-dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
# Standalone usage
|
|
21
|
+
PyMCP can be started standalone as a MCP server with `stdio` transport by running the following. However, you are unlikely to use it this way.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
uv run pymcp
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Furthermore, being a template repository, the code deliberately does not implement `streamable-http` and `sse` transports.
|
|
28
|
+
|
|
29
|
+
# Test with the MCP Inspector
|
|
30
|
+
|
|
31
|
+
The [MCP Inspector](https://github.com/modelcontextprotocol/inspector) is an _official_ Model Context Protocol tool that can be used by developers to test and debug MCP servers. This is the most comprehensive way to explore the MCP server.
|
|
32
|
+
|
|
33
|
+
To use it, you must have Node.js installed. The best way to install and manage `node` as well as packages such as the MCP Inspector is to use the [Node Version Manager (or, `nvm`)](https://github.com/nvm-sh/nvm). Once you have `nvm` installed, you can install and use the latest Long Term Release version of `node` by executing the following.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
nvm install --lts
|
|
37
|
+
nvm use --lts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Following that, run the MCP Inspector and PyMCP by executing the following in the _WD_.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx @modelcontextprotocol/inspector uv run pymcp
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This will create a local URL at port 6274 with an authentication token, which you can copy and browse to on your browser. Once on the MCP Inspector UI, press _Connect_ to connect to the MCP server. Thereafter, you can explore the tools available on the server.
|
|
47
|
+
|
|
48
|
+
# Use it with Claude Desktop, Visual Studio, and so on
|
|
49
|
+
|
|
50
|
+
The server entry to run with `stdio` transport that you can use with systems such as Claude Desktop, Visual Studio Code, and so on is as follows.
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"command": "uv",
|
|
55
|
+
"args": [
|
|
56
|
+
"run",
|
|
57
|
+
"pymcp"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Instead of having `pymcp` as the last item in the list of `args`, you may need to specify the full path to the script, e.g., _WD_`/.venv/bin/pymcp`.
|
|
63
|
+
|
|
64
|
+
# Contributing
|
|
65
|
+
|
|
66
|
+
Install [`pre-commit`](https://pre-commit.com/) for Git by using the `--all-groups` flag for `uv sync` for the installation of PyMCP.
|
|
67
|
+
|
|
68
|
+
Then enable `pre-commit` by running the following in the _WD_.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pre-commit install
|
|
72
|
+
```
|
|
73
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
74
|
+
|
|
75
|
+
# License
|
|
76
|
+
|
|
77
|
+
[MIT](https://choosealicense.com/licenses/mit/).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pymcp-template"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A template (repository) for developing MCP servers in Python"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Anirban Basu", email = "anirbanbasu@users.noreply.github.com" }
|
|
8
|
+
]
|
|
9
|
+
keywords = ["python3", "example", "server", "model-context-protocol-server", "mcp-server"]
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"fastmcp>=2.9.2",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.scripts]
|
|
23
|
+
pymcp = "pymcp.server:main"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel]
|
|
26
|
+
packages = ["src/pymcp"]
|
|
27
|
+
|
|
28
|
+
[build-system]
|
|
29
|
+
requires = ["hatchling"]
|
|
30
|
+
build-backend = "hatchling.build"
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = [
|
|
34
|
+
"pre-commit>=4.2.0",
|
|
35
|
+
]
|
|
36
|
+
test = [
|
|
37
|
+
"pytest>=8.4.1",
|
|
38
|
+
]
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
3
|
+
|
|
4
|
+
<svg
|
|
5
|
+
width="178.55226pt"
|
|
6
|
+
height="58.240055pt"
|
|
7
|
+
viewBox="0 0 62.989271 20.545797"
|
|
8
|
+
version="1.1"
|
|
9
|
+
id="svg1"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
|
12
|
+
<defs
|
|
13
|
+
id="defs1" />
|
|
14
|
+
<g
|
|
15
|
+
id="layer1"
|
|
16
|
+
transform="translate(-2.3720312,-1.0159898)">
|
|
17
|
+
<path
|
|
18
|
+
style="font-weight:500;font-size:22.5778px;line-height:1;font-family:Megrim;-inkscape-font-specification:'Megrim Medium';letter-spacing:0.264583px;word-spacing:0px;opacity:0.6;fill:#343434;stroke-width:0.1"
|
|
19
|
+
d="M 7.9713259,9.4600873 7.6326589,8.8730644 8.8970157,8.1505748 q 1.5578683,-0.8579564 1.5578683,-2.7319139 0,-3.4995591 -5.328361,-3.4995591 H 3.0493653 V 17.046228 H 2.3720313 V 1.2417678 H 5.126523 q 2.9802697,0 4.4929824,1.1063122 1.5127126,1.0837345 1.5127126,3.0705809 0,2.2577801 -1.8965353,3.3189367 z M 15.212471,3.9511039 H 23.95008 L 18.644297,16.481783 v 5.080005 H 17.966963 V 16.481783 L 12.661179,3.9511039 h 0.72249 L 18.30563,15.533516 22.934079,4.6284379 H 15.212471 Z M 28.775388,16.368894 h 8.895654 V 2.8447916 L 32.591037,13.727292 27.511031,2.8222138 V 17.046228 l -0.677334,-0.02258 V 1.21919 h 0.677334 L 32.591037,12.124268 37.671042,1.2417678 38.348376,1.21919 v 15.827038 l -9.572988,-0.02258 z M 52.882135,14.15627 q -0.609601,1.490135 -1.715913,2.302935 -1.106312,0.812801 -3.318937,0.812801 -2.777069,0 -4.018848,-1.693335 -1.241779,-1.715913 -1.241779,-5.328361 V 8.0376858 q 0,-3.6124481 1.241779,-5.3057832 1.241779,-1.7159128 4.018848,-1.7159128 2.212625,0 3.318937,0.8128008 1.106312,0.8128008 1.715913,2.3029357 L 52.272534,4.4252377 Q 51.753245,3.1157253 50.804977,2.4158134 49.85671,1.6933238 47.847285,1.6933238 q -1.106312,0 -1.896535,0.2935114 -0.790223,0.2709336 -1.422401,0.9482676 -0.632179,0.6773341 -0.948268,1.9642687 -0.316089,1.2643569 -0.316089,3.1383143 V 10.25031 q 0,1.873958 0.316089,3.160892 0.316089,1.264357 0.948268,1.941691 0.632178,0.677334 1.422401,0.970846 0.790223,0.270933 1.896535,0.270933 2.009425,0 2.957692,-0.699912 0.948268,-0.722489 1.467557,-2.032002 z M 62.20041,9.4600873 61.861743,8.8730644 63.1261,8.1505748 q 1.557868,-0.8579564 1.557868,-2.7319139 0,-3.4995591 -5.328361,-3.4995591 H 57.278449 V 17.046228 H 56.601115 V 1.2417678 h 2.754492 q 2.98027,0 4.492982,1.1063122 1.512713,1.0837345 1.512713,3.0705809 0,2.2577801 -1.896535,3.3189367 z"
|
|
20
|
+
id="text1"
|
|
21
|
+
aria-label="PyMCP" />
|
|
22
|
+
</g>
|
|
23
|
+
</svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Smithery does not work with base images such as ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
|
2
|
+
FROM python:3.12-alpine3.22
|
|
3
|
+
# Install system dependencies
|
|
4
|
+
RUN apk add --no-cache gcc musl-dev linux-headers
|
|
5
|
+
# Set the working directory in the container
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
COPY src pyproject.toml README.md LICENSE ./
|
|
9
|
+
# Install the latest version from the cloned repository
|
|
10
|
+
RUN pip install --upgrade pip && pip install --no-cache-dir .
|
|
11
|
+
|
|
12
|
+
ENTRYPOINT ["python3", "-m", "pymcp.server"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Check reference at https://smithery.ai/docs/build/project-config/smithery-yaml
|
|
2
|
+
# runtime: "container"
|
|
3
|
+
build:
|
|
4
|
+
dockerfile: "smithery.dockerfile"
|
|
5
|
+
dockerBuildPath: "."
|
|
6
|
+
startCommand:
|
|
7
|
+
type: "stdio" # Changed from http
|
|
8
|
+
configSchema:
|
|
9
|
+
# JSON Schema defining the configuration options for the MCP.
|
|
10
|
+
{}
|
|
11
|
+
commandFunction:
|
|
12
|
+
# A JS function that produces the CLI command based on the given config to start the MCP on stdio.
|
|
13
|
+
|-
|
|
14
|
+
(config) => ({ command: 'python3', args: ['-m', 'pymcp.server'] })
|
|
15
|
+
exampleConfig: {}
|
|
File without changes
|