GitHub Stars
0
User Rating
Not Rated
Favorites
0
Views
5
Forks
0
Issues
0
Learn MCP (Model Context Protocol)
A learning project demonstrating how to build and use Model Context Protocol (MCP) servers and clients. This project implements a weather service that provides real-time weather alerts and forecasts using the National Weather Service API.
🌟 Features
- Weather Alerts: Get active weather alerts for any US state
- Weather Forecasts: Retrieve detailed weather forecasts for specific coordinates
- MCP Integration: Demonstrates MCP server/client architecture
- AI Assistant: Uses Anthropic's Claude for natural language interaction with weather tools
🛠️ Tech Stack
- Python 3.13+
- FastMCP: For building the MCP server
- Anthropic Claude: For AI-powered interactions
- National Weather Service API: For weather data
- asyncio/httpx: For asynchronous HTTP requests
📦 Installation
Clone the repository:
git clone <your-repo-url> cd learn-mcp
Install dependencies:
pip install -e .
Set up environment variables:
Create a
.env
file in the project root:ANTHROPIC_API_KEY=your_anthropic_api_key_here
🚀 Usage
Running the MCP Server
The server provides weather-related tools that can be accessed via MCP:
python server.py
Running the MCP Client
The client connects to the server and provides an interactive chat interface:
python client.py server.py
Available Tools
1. Get Weather Alerts
Get active weather alerts for a specified US state:
await get_alerts("CA") # Get alerts for California
2. Get Weather Forecast
Get detailed weather forecast for specific coordinates:
await get_forecast(34.0522, -118.2437) # Get forecast for Los Angeles
💬 Example Interactions
Once you start the client, you can ask natural language questions like:
- "What are the current weather alerts in Texas?"
- "Give me the forecast for New York City coordinates 40.7128, -74.0060"
- "Are there any severe weather warnings in Florida?"
🏗️ Project Structure
learn-mcp/
├── client.py # MCP client implementation
├── server.py # MCP server with weather tools
├── pyproject.toml # Project configuration
├── README.md # This file
├── LICENSE # License file
└── uv.lock # Dependency lock file
🔧 Key Components
Server (server.py
)
- Implements MCP server using FastMCP
- Provides weather alert and forecast tools
- Integrates with National Weather Service API
- Handles asynchronous HTTP requests
Client (client.py
)
- Connects to MCP server via stdio transport
- Integrates with Anthropic's Claude for AI interactions
- Provides interactive chat loop
- Handles tool calls and responses
📚 Learning Objectives
This project demonstrates:
- MCP Architecture: Understanding server/client communication
- Tool Definition: Creating tools that AI can use
- API Integration: Working with external APIs (NWS)
- Async Programming: Using asyncio for concurrent operations
- AI Integration: Combining MCP with language models
🤝 Contributing
This is a learning project! Feel free to:
- Add new weather-related tools
- Improve error handling
- Add tests
- Enhance documentation
- Experiment with different MCP features
📝 License
This project is licensed under the terms specified in the LICENSE file.
🔗 Resources
- Model Context Protocol Documentation
- FastMCP Documentation
- National Weather Service API
- Anthropic Claude API
⚠️ Notes
- This project uses the National Weather Service API, which provides data for US locations only
- An Anthropic API key is required for the AI features
- The project is designed for learning purposes and may need additional error handling for production use.
10
Followers
47
Repositories
0
Gists
0
Total Contributions
A MCP (Model Context Protocol) server for PowerPoint manipulation using python-pptx. This server provides tools for creating, editing, and manipulating PowerPoint presentations through the MCP protocol.