Token导航 LogoToken导航TokenDH.com
Hello MCP Server Python logo
AI代理stdio官方级别未说明来源级核验

Hello MCP Server Python

MCP Server

一个基于Model Context Protocol的Python服务器示例项目,提供BMI计算和天气查询功能,适用于LLM工具集成。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
Python服务器PythonClaudeClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

jongkwang

提供方

jongkwang

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install httpx "mcp[cli]"

详细介绍

MCP服务器Python

*语言: 英语 | 韩语*

英语

使用模型上下文协议的Python服务器示例项目。

目录

概述

这个项目是一个服务器示例,它使用模型上下文协议(MCP)为Claude AI等LLM提供工具。它提供BMI计算和天气信息查找功能。

参考

此项目是基于以下开源项目创建的:

先决条件

  • Python 3.9或更高版本
  • pip或pip3(包管理器)
  • httpx(异步HTTP客户端)
  • MCP Python SDK

安装

  1. 克隆存储库:
git clone https://github.com/yourusername/hello-mcp-server-python.git
cd hello-mcp-server-python
  1. 安装所需的软件包:
pip install httpx "mcp[cli]"
  1. 运行服务器:(如果通过Cursor或Claude for Desktop连接,则可选)
python server.py
# or
mcp run server.py

连接到Cursor和Claude for Desktop

连接到游标

  1. 打开Cursor IDE并加载项目。
  2. 创建一个 mcp.json 在项目根目录中创建文件,并添加以下内容:
{
  "mcpServers": {
      "mcp-server-python": {
            "command": "mcp",
            "args": [
                "run",
                "/_____PATH_OF_FILE_____/server.py"
                ]
      }
  }
}
  1. 在Cursor中与Claude聊天时,MCP工具将被自动识别。服务器将根据mcp.json设置自动运行。

连接到Claude for Desktop

  1. 安装桌面版的Claude。
  2. 在终端中运行服务器:
python server.py
  1. 转到Claude中的MCP服务器部分进行桌面设置,并添加本地MCP服务器。
  2. 根据需要配置服务器URL或端口。
  3. 与克劳德聊天时,您可以使用BMI计算和天气查找工具。

项目结构

hello-mcp-server-python/
├── server.py       # MCP server main file
└── requirements.txt  # Dependency package list (optional)

特性

服务器目前提供两个工具:

  1. calculate_bmi:根据身高和体重输入计算BMI。
  2. fetch_weather:检索给定城市名称的天气信息。(需要API密钥)

天气API设置

要使用天气API,您需要一个API密钥。打开 server.py 文件并按如下方式修改:

@mcp.tool()
async def fetch_weather(city: str) -> str:
    """Fetch current weather for a city"""
    API_KEY = "your_api_key_here"  # Enter your API key here
    async with httpx.AsyncClient() as client:
        response = await client.get(f"https://api.weather.com/{city}?apiKey={API_KEY}")
        return response.text

许可证

该项目在MIT许可证下分发。有关详细信息,请参阅LICENSE文件。

参考文献

______________________________________________________________________

韩语

使用Model Context Protocol的Python服务器示例项目。

目录

概述

此项目是使用Model Context Protocol(MCP)为LLM(如Claude AI)提供工具功能的服务器示例。提供BMI计算和天气信息查询功能。

参考的网址

此项目是参考以下开源项目创建的:

预装事项

  • Python3.9或更高版本
  • pip或pip3(包管理器)
  • httpx(异步HTTP客户端)
  • MCP Python SDK

安装方法

  1. 克隆存储库:
git clone https://github.com/yourusername/hello-mcp-server-python.git
cd hello-mcp-server-python
  1. 安装所需的软件包:
pip install httpx "mcp[cli]"
  1. 运行服务器:(通过Cursor或Claude for Desktop连接时,此步骤是可选的)
python server.py
# 또는
mcp run server.py

如何连接到Cursor和Claude for Desktop

连接到Cursor

  1. 打开Cursor IDE并加载项目。
  2. Cursor项目根目录 mcp.json 创建文件并添加以下内容:
{
  "mcpServers": {
      "mcp-server-python": {
            "command": "mcp",
            "args": [
                "run",
                "/_____PATH_OF_FILE_____/server.py"
                ]
      }
  }
}
  1. 在Cursor与Claude聊天时,MCP工具会自动识别。服务器将根据mcp.json设置自动运行。

连接到Claude for桌面

  1. 安装Claude for Desktop。
  2. 在终端上运行服务器:
python server.py
  1. 在Claude for Desktop设置中,转到MCP服务器部分,添加本地MCP服务器。
  2. 根据需要配置服务器URL或端口。
  3. 与Claude对话后,您可以使用BMI计算和天气查询工具。

项目结构

hello-mcp-server-python/
├── server.py       # MCP 서버 메인 파일
└── requirements.txt  # 의존성 패키지 목록 (선택 사항)

功能

目前服务器提供两种工具:

  1. calculate_bmi:输入身高和体重计算BMI。
  2. fetch_weather:输入城市名称以获取该城市的天气信息。(需要设置API密钥)

天气API设置

使用天气API需要API密钥。 server.py 打开文件并进行以下修改:

@mcp.tool()
async def fetch_weather(city: str) -> str:
    """Fetch current weather for a city"""
    API_KEY = "your_api_key_here"  # 여기에 API 키를 입력하세요
    async with httpx.AsyncClient() as client:
        response = await client.get(f"https://api.weather.com/{city}?apiKey={API_KEY}")
        return response.text

许可证

此项目在MIT许可证下分发。有关详细信息,请参阅LICENSE文件。

参考文档

目录标签

目录标签

Python服务器PythonClaude本地部署MCP协议LLM工具BMI计算天气API

支持客户端

ClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP