Skip to main content

Say Hi MCP Server

PyPI version Python Support License: MIT

这是一个简单的 MCP (Model Context Protocol) Server 示例,提供了几个向不同人打招呼的工具。这个项目旨在展示如何创建和部署一个基本的 MCP Server。

特性

  • 🚀 基于 FastMCP 的简单实现
  • 👋 提供多个打招呼工具
  • 🛠️ 包含错误处理示例
  • 📦 完整的 Python 包结构
  • 🔧 易于扩展和自定义
  • ✅ 使用 Pydantic 进行参数验证和类型安全
  • 📝 详细的工具参数描述和示例

安装

使用 uvx(推荐)

uvx 是运行 Python 包的现代方式,无需全局安装,避免依赖冲突:

# 直接运行,无需安装
uvx say-hi-mcp

# 或者使用完整的 PyPI 包名
uvx --from say-hi-mcp say-hi-mcp

从 PyPI 安装

pip install say-hi-mcp

从源码安装

git clone https://github.com/yourusername/say-hi-mcp.git
cd say-hi-mcp
pip install -e .

使用方法

使用 uvx 运行(推荐)

uvx say-hi-mcp

作为命令行工具运行

如果已通过 pip 安装:

say-hi-mcp

作为 Python 模块运行

python -m say_hi_mcp.server

在代码中使用

from say_hi_mcp import SayHiMCPServer

# 创建服务器实例
server = SayHiMCPServer()

# 运行服务器
server.run()

可用工具

该 MCP Server 提供以下工具,所有工具都使用 Pydantic 进行参数验证:

1. hi_alice - 向Alice打招呼

  • 参数: my_name (string, 必需)
    • 描述: 你的名字,用于介绍自己
    • 限制: 长度1-50字符
    • 示例: "张三", "李四", "John", "Alice"
  • 功能: 与热情开朗的Alice进行友好互动

2. hi_bob - 向Bob打招呼

  • 参数: my_name (string, 必需)
    • 描述: 你的名字,用于介绍自己
    • 限制: 长度1-50字符
  • 功能: 与实用主义者Bob进行简洁友好的交流

3. hi_charlie - 向Charlie打招呼(测试工具)

  • 参数: my_name (string, 必需)
    • 描述: 你的名字,用于介绍自己
    • 限制: 长度1-50字符
  • 功能: ⚠️ 专门用于测试错误处理,总是抛出异常

4. hi_all - 获取完整打招呼指导

  • 参数: my_name (string, 必需)
    • 描述: 你的名字,用于介绍自己
    • 限制: 长度1-50字符
  • 功能: 返回详细的工具使用指南和步骤说明

配置 Claude Desktop

使用 uvx(推荐)

使用 uvx 可以避免全局安装依赖,保持环境整洁:

{
    "mcpServers": {
        "say-hi": {
            "command": "uvx",
            "args": ["say-hi-mcp"]
        }
    }
}

uvx 的优势:

  • ✅ 无需预先安装包
  • ✅ 自动管理依赖和虚拟环境
  • ✅ 避免依赖冲突
  • ✅ 始终使用最新版本(除非指定版本)

使用已安装的包

如果你已经通过 pip 安装了包:

{
    "mcpServers": {
        "say-hi": {
            "command": "say-hi-mcp"
        }
    }
}

使用 Python 直接运行

{
    "mcpServers": {
        "say-hi": {
            "command": "python",
            "args": [
                "-m", "say_hi_mcp.server"
            ]
        }
    }
}

指定特定版本(uvx)

如果需要使用特定版本:

{
    "mcpServers": {
        "say-hi": {
            "command": "uvx",
            "args": ["--from", "say-hi-mcp==0.1.0", "say-hi-mcp"]
        }
    }
}

开发

设置开发环境

# 克隆仓库
git clone https://github.com/yourusername/say-hi-mcp.git
cd say-hi-mcp

# 安装开发依赖
pip install -e ".[dev]"

运行测试

pytest

代码格式化

black say_hi_mcp/
isort say_hi_mcp/

类型检查

mypy say_hi_mcp/

贡献

欢迎贡献!请先 fork 这个仓库,然后创建一个新的分支来进行你的修改。

  1. Fork 这个项目
  2. 创建你的特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交你的修改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开一个 Pull Request

许可证

这个项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。

相关链接

更新日志

查看 CHANGELOG.md 了解版本历史和更新内容。

Metadata

Release files for say-hi-mcp 0.1.23

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

Source distribution (sdist)

Source distribution for say-hi-mcp 0.1.23
File Size Uploaded Provenance
say_hi_mcp-0.1.23.tar.gz 16.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for say-hi-mcp 0.1.23
File Interpreter ABI Platform
say_hi_mcp-0.1.23-py3-none-any.whl Python 3 none any Details

Total release size: 28.0 kB

Release files / say_hi_mcp-0.1.23.tar.gz

Download URL say_hi_mcp-0.1.23.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d459edd963e45ac939c72b1c451c381bf8e19ad402d59e36e485b888d74504e8
BLAKE2b-256 checksum
How to use checksums
37a01fbf032864ecdcfb1d531f84588c8d9ab3297202e27bbe7853ed98fb499e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / say_hi_mcp-0.1.23-py3-none-any.whl

Download URL say_hi_mcp-0.1.23-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad435fa779c1798ee7d4f90880d26d1900e9fa2139c0d98075f62965db7ef765
BLAKE2b-256 checksum
How to use checksums
916e5314d816058ba9ec08efb468da598bb527e2b852afdc04da3b0cf09da737
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for say-hi-mcp 0.1.23

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