mcp-hello-py

mcp-hello-py

Greets users in Korean by name, supporting single and multiple recipients.

Category
Visit Server

README

👋 MCP Hello Server (Python)

简单的 Hello MCP 服务器 - 接收输入的姓名,并用韩语打招呼!

📂 结构

mcp-hello-py/
├── src/
│   ├── __init__.py       # 包初始化
│   └── server.py         # MCP 服务器
├── .env                  # 环境变量配置
├── requirements.txt      # 依赖项
├── pyproject.toml        # 项目元数据
├── Dockerfile            # Docker 配置
└── README.md             # 此文件

✨ 主要功能

  • say_hello: 以 "안녕하세요, {name}님!" 的格式打招呼
  • say_hello_multiple: 一次向多个人打招呼
  • MCP 协议: 支持 Tools、Resources、Prompts

📦 安装

# 创建并激活虚拟环境
python3 -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# 安装依赖
pip install -r requirements.txt

🔧 环境变量配置

创建 .env 文件:

# .env 文件内容
PORT=8080

🚀 运行

🌐 Streamable HTTP 模式 (Cloud Run, Web)

python3 src/server.py --http-stream

# 使用自定义端口
PORT=3000 python3 src/server.py --http-stream

🏗️ 架构

┌─────────────┐       ┌─────────────────┐
│  Postman /  │ ───▶  │  MCP Hello      │
│  MCP Client │       │  Server         │
│             │ ◀───  │  (Python)       │
└─────────────┘       └─────────────────┘
     HTTP                  MCP
   POST /mcp             Protocol

🧪 测试(Postman)

📋 Headers 设置(所有请求必填)

Header Value
Content-Type application/json
Accept application/json

1️⃣ 初始化 MCP 服务器

  • Method: POST
  • URL: http://localhost:8080/mcp
  • Body (raw JSON):
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {"name": "postman", "version": "1.0.0"}
  }
}

2️⃣ 查看 Tool 列表

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list",
  "params": {}
}

3️⃣ say_hello 调用

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "say_hello",
    "arguments": {"name": "김철수"}
  }
}

响应示例:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [{"type": "text", "text": "안녕하세요, 김철수님!"}]
  }
}

4️⃣ say_hello_multiple 调用

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "say_hello_multiple",
    "arguments": {"names": ["김철수", "이영희", "박민수"]}
  }
}

响应示例:

{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "content": [{"type": "text", "text": "• 안녕하세요, 김철수님!\n• 안녕하세요, 이영희님!\n• 안녕하세요, 박민수님!"}]
  }
}

☁️ Cloud Run 部署

🧪 测试已部署的服务器

部署 URL 示例: https://mcp-hello-py-xxxxxx.asia-northeast3.run.app/mcp

在 Postman 中仅修改 URL 即可用同样方式测试。

🔧 环境变量配置(Cloud Run)

变量 说明
PORT 8080 Cloud Run 默认端口(自动设置)

🛠️ MCP Tools

say_hello

向一个人打招呼。

参数 类型 必填 说明
name string 要问候的人的姓名

say_hello_multiple

同时向多个人打招呼。

参数 类型 必填 说明
names array 姓名列表

📚 技术栈

  • Python: 3.11+
  • MCP SDK: 1.23.0+ (FastMCP)
  • Pydantic: 2.x
  • Uvicorn: ASGI 服务器
  • Docker: 容器化

📡 传输模式

模式 使用场景 端点
stdio Claude Desktop, MCP Inspector stdin/stdout
Streamable HTTP Cloud Run, Web POST /mcp

📖 参考

📄 许可证

MIT License

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured