Skip to main content

gg-mcp-demo

一个最小可用的 MCP(Model Context Protocol)服务器示例,用来演示三件事:

  • 注册一个 tool(add)和一个 resource(greeting://{name});
  • 用 middleware 把每一次入站请求/通知(方法、参数、耗时、结果)写进调用日志;
  • 默认走 stdio 传输,可用环境变量切换成 sse / streamable-http。

安装

pip install gg-mcp-demo-server
# 或
uv add gg-mcp-demo-server

需要 Python 3.13 及以上。发行名是 gg-mcp-demo-server,安装后提供两个等价命令:gg-mcp-demo-server 和 gg-mcp-demo;导入名是 gg_mcp_demo。

运行

gg-mcp-demo-server       # 默认 stdio,供客户端拉起
MCP_TRANSPORT=sse gg-mcp-demo-server

用 uv 免安装直接跑(uvx 要求可执行文件名与包名一致,0.1.1 起已对齐):

uvx gg-mcp-demo-server

环境变量:

变量 默认值 说明
MCP_TRANSPORT stdio 传输方式:stdio / sse / streamable-http
GG_MCP_DEMO_LOG_DIR 见下 调用日志所在目录

调用日志默认写入当前用户的状态目录:

  • Windows:%LOCALAPPDATA%\gg-mcp-demo\logs\mcp-calls.log
  • Linux/macOS:$XDG_STATE_HOME/gg-mcp-demo/logs/mcp-calls.log(未设置时为 ~/.local/state/...)

在客户端里配置

以 stdio 方式接入 Cherry Studio / Cline / Claude Desktop 等客户端。

方式一:已 pip install 到某个环境,直接用命令(Windows 上建议写绝对路径):

{
  "mcpServers": {
    "gg-mcp-demo": {
      "command": "gg-mcp-demo-server",
      "env": {
        "GG_MCP_DEMO_LOG_DIR": "D:/logs/gg-mcp-demo"
      }
    }
  }
}

方式二:交给 uvx 免安装运行(首次会下载依赖,冷启动约 5~10 秒):

{
  "mcpServers": {
    "gg-mcp-demo": {
      "command": "uvx",
      "args": ["gg-mcp-demo-server"]
    }
  }
}

0.1.0 的可执行文件名叫 gg-mcp-demo,用 uvx 时必须写成 uvx --from gg-mcp-demo-server gg-mcp-demo;0.1.1 起 uvx gg-mcp-demo-server 可直接用。

提供的 tool 与 resource

  • add(a: int, b: int) -> int:返回两数之和。
  • greeting://{name}:返回 Hello, {name}!。

日志示例

[17:30:14.312] pid=23112 --> tools/call id=2 params={"name": "add", "arguments": {"a": 1, "b": 2}}
[17:30:14.313] pid=23112 <-- tools/call id=2 OK 1.2ms result={"content": [{"type": "text", "text": "3"}]}

许可

未声明许可证(发布前请按需要补充)。

Metadata

Release files for gg-mcp-demo-server 0.1.1

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

Source distribution (sdist)

Source distribution for gg-mcp-demo-server 0.1.1
File Size Uploaded Provenance Actions
gg_mcp_demo_server-0.1.1.tar.gz 4.0 kB Without provenance Details for gg_mcp_demo_server-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gg-mcp-demo-server 0.1.1
File Interpreter ABI Platform Actions
gg_mcp_demo_server-0.1.1-py3-none-any.whl Python 3 none any Details for gg_mcp_demo_server-0.1.1-py3-none-any.whl

Total release size: 9.1 kB

Release files / gg_mcp_demo_server-0.1.1.tar.gz

Download URL gg_mcp_demo_server-0.1.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
369568ed9f6393cd545d85c523501de0db0f473501bbd280e383d2c7d3cec7bf
BLAKE2b-256 checksum
How to use checksums
d7b8ff73ffc8197da560f081f0e61e7f873c51106f69f72533f62f9784cd649d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / gg_mcp_demo_server-0.1.1-py3-none-any.whl

Download URL gg_mcp_demo_server-0.1.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d2ee28ae3ffa2ca3dcbe0a3801f1db7e0e3d163d7017acfa6220fccb622f54b
BLAKE2b-256 checksum
How to use checksums
52e5c23c7c34ae281058a927173c08a4b25a2686c5bd2d5737919040df098299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for gg-mcp-demo-server 0.1.1

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.1 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