Token导航 LogoToken导航TokenDH.com
First MCP Server In Claude logo
地图位置stdio官方级别未说明来源级核验

First MCP Server In Claude

MCP Server

一个基于FastMCP的简单模型上下文协议(MCP)服务器,用于向AI运行时暴露自定义工具,如获取天气数据。

工具数

1

提示词数

0

GitHub Stars

0

资源数

0
位置天气Python本地部署STDIO

安装说明

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

作者 / 组织

bhavesh-kalluru

提供方

bhavesh-kalluru

最后核验

2026/5/17 20:21

运行时

Python

快速接入

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

命令预览

uv run python main.py

详细介绍

🌤️ 基于FastMCP的气象MCP服务器

一个简单的 模型上下文协议(MCP) 服务器构建于 FastMCP 演示了如何将自定义工具暴露给AI运行时。\ 该示例定义了单个工具, get_weather,它返回给定位置的模拟天气数据。

______________________________________________________________________

🚀 特性

  • ✅ 最小、易于理解的MCP服务器
  • ⚙️ 实现a get_weather 工具
  • 🧩 已准备好与MCP兼容的客户端集成
  • 🐍 用干净、现代的Python编写

______________________________________________________________________

🧠 运作原理

FastMCP 类封装了MCP stdio服务器的样板设置和通信。\ 当服务器启动时,它会暴露 get_weather 作为其他代理或IDE可以调用的可调用MCP工具。

______________________________________________________________________

🧩 代码概述

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("weather")

@mcp.tool()
def get_weather(location: str) -> str:
    """Get the current weather for a given location."""
    return f"The current weather in {location} is sunny with a temperature of 25°C."

if __name__ == "__main__":
    mcp.run()
⚡️ Getting Started
1️⃣ Clone the repo
bash
Copy code
git clone https://github.com//weather-mcp.git
cd weather-mcp
2️⃣ Create a virtual environment
bash
Copy code
uv venv
source .venv/bin/activate  # macOS/Linux
3️⃣ Install dependencies
bash
Copy code
uv pip install 'mcp[cli]'
4️⃣ Run the server
bash
Copy code
uv run python main.py
If everything is configured correctly, the server will start and listen for MCP stdio connections.

🔍 Example Usage
You can connect this MCP server to any MCP-compatible client (e.g., an IDE, LLM runtime, or agent).
When prompted, provide:

Setting	Value
Command	uv
Arguments	run --directory /path/to/weather-mcp python main.py

🧰 Project Structure
bash
Copy code
weather-mcp/
│
├── main.py          # MCP server source
├── pyproject.toml   # Project metadata (for uv/pdm)
└── README.md        # You are here
💡 Future Improvements
Integrate with a real weather API (e.g., OpenWeatherMap)

Add error handling and temperature units

Extend to multi-location forecasting and alerts

👨‍💻 Author
Bhavesh Kalluru
AI Engineer | Generative AI | LLM Applications | MCP Integrations
📍 Looking for full-time opportunities in the U.S.

目录标签

目录标签

位置天气Python本地部署STDIOMCP服务器天气数据AI工具Python开发

接入字段

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

stdio

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

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdionone部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP