Skip to main content

MCP服务开发、测试、发布全流程

1、在某个conda环境中(比如llm-mcp),安装好uv:

pip install uv

2、PyCharm项目初始化为uv项目:

uv init .

3、创建、激活虚拟环境

uv venv source .venv/bin/activate

4、安装 MCP SDK

uv add openai dotenv mcp

5、创建项目源代码

创建src/weather 文件夹

添加 server.py 文件

6、本地测试(使用Inspector进行)

安装nodejs

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash - sudo apt install -y nodejs

运行Inspector

npx -y @modelcontextprotocol/inspector uv run ./src/weather/server.py --api_key apikey123abc

7、打包

添加__init__.py、main.py

修改pyproject.toml文件

填写内容,注意[project.scripts]中的rents-mcp-weather2名称:

[build-system] requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta"

[project.scripts] rents-mcp-weather2 = "weather:main" [tool.setuptools] package-dir = {"" = "src"} [tool.setuptools.packages.find] where = ["src"]

安装打包/发布(上传)工具包

uv pip install build twine

打包(回到项⽬主⽬录)

cd /Users/rents/PycharmProjects/rents-mcp-weather python -m build

8、发布

python -m twine upload dist/*

Metadata

Release files for rents-mcp-weather 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rents-mcp-weather 0.1.2
File Size Uploaded Provenance Actions
rents_mcp_weather-0.1.2.tar.gz 5.1 kB Without provenance Details for rents_mcp_weather-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rents-mcp-weather 0.1.2
File Interpreter ABI Platform Actions
rents_mcp_weather-0.1.2-py3-none-any.whl Python 3 none any Details for rents_mcp_weather-0.1.2-py3-none-any.whl

Total release size: 11.4 kB

Release files / rents_mcp_weather-0.1.2.tar.gz

Download URL rents_mcp_weather-0.1.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
befd5efe33b58882e4092c729d28cea537f7ed99f58a18cbac6a897646fe83f0
BLAKE2b-256 checksum
How to use checksums
b7e918096c2c3d362289b44e63949a50cb496d7173a179bdaf8b6fc52a38f044
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Release files / rents_mcp_weather-0.1.2-py3-none-any.whl

Download URL rents_mcp_weather-0.1.2-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efde94a375c241a508c197b01a12da9d76a38af456ec12642ded4c9196430fa0
BLAKE2b-256 checksum
How to use checksums
3f315b0044b5027b110646879562af51533d2d41f529a84f86077fbb44fc8be8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Security for rents-mcp-weather 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page