# Testing the Weather MCP Server
## Quick Test Steps
### 1. Verify Server Starts (Optional Manual Test)
The MCP server communicates via stdio, so when you run it directly, it will wait for input. To verify it starts without errors:
```bash
# In terminal 1 - Start the server (it will wait for input)
uv run python main.py
# The server should start and wait silently - this is normal!
# Press Ctrl+C to stop it
```
If you see import errors or other exceptions, fix those first.
### 2. Verify Cursor IDE Configuration
1. **Check Cursor Settings:**
- Open Cursor Settings (Cmd/Ctrl + ,)
- Go to **Features** → **MCP Servers**
- Verify "weather" server is listed and enabled
- Check that the path is correct: `/Users/pratik/weather/main.py`
2. **Check Server Status:**
- In Cursor, look for MCP server status indicators
- Some versions show a connection status badge
- Check Cursor's developer console for MCP connection logs
### 3. Test Tools (Functions)
In Cursor's chat/composer, try these commands:
**Test Current Weather:**
```
What's the weather in New York?
```
**Test Forecast:**
```
Get a 3-day weather forecast for London
```
**Test Location Search:**
```
Search for locations matching "Paris"
```
**Direct Tool Calls:**
You can also explicitly ask to use the tools:
```
Use the get_current_weather tool to check the weather in San Francisco
```
### 4. Test Resources
Resources are accessed via URI patterns. In Cursor, you might ask:
```
Read the weather://current/New York resource
```
Or the AI might automatically use resources when you ask:
```
Show me the current weather data for Tokyo
```
### 5. Test Prompts
Prompts are templates the AI can use. Try:
```
Use the analyze_weather prompt for Seattle
```
Or:
```
Compare the weather in New York and Los Angeles using the compare_locations prompt
```
## Expected Behavior
### When Working Correctly:
1. **Server Connection:**
- Cursor should connect to the server automatically
- No errors in Cursor's console/logs
- Server process should be running (check Activity Monitor/Task Manager)
2. **Tool Responses:**
- AI should be able to call weather tools
- You should get JSON weather data back
- If no API key, you'll see mock data with a note
3. **Resource Access:**
- AI can read weather resources
- Data is returned in JSON format
4. **Prompt Usage:**
- AI can use prompt templates
- Prompts guide the AI's analysis
### Troubleshooting
**Server Not Connecting:**
- Verify the path in Cursor settings is absolute and correct
- Check that Python is in your PATH
- Try using full path to Python: `/usr/local/bin/python3` or `python3`
- Restart Cursor IDE after configuration changes
**Import Errors:**
- Make sure dependencies are installed: `uv sync`
- Verify you're using the correct Python environment
- Check that `mcp` package is installed: `uv pip list | grep mcp`
**Tools Not Working:**
- Check Cursor's MCP server logs/console
- Verify the server is actually running
- Try restarting Cursor IDE
**No Response:**
- The server might be waiting for input (normal for stdio servers)
- Check if Cursor is actually sending requests
- Verify the MCP server is enabled in Cursor settings
## Manual Testing (Advanced)
If you want to test the server manually, you can send MCP protocol messages:
```bash
# This is complex - usually not needed
# The server expects JSON-RPC messages via stdin
```
For most users, testing through Cursor IDE is sufficient.
## Verification Checklist
- [ ] Server starts without errors (`uv run python main.py`)
- [ ] Cursor IDE shows MCP server as connected/enabled
- [ ] Can ask for weather and get responses
- [ ] Tools are callable (get_current_weather, get_forecast, search_locations)
- [ ] Resources are accessible (weather://current/{location})
- [ ] Prompts work (analyze_weather, compare_locations)
## Example Test Conversation
Try this conversation flow in Cursor:
1. **"What's the weather in New York?"**
- Should trigger `get_current_weather` tool
- Returns weather data
2. **"Get a 5-day forecast for London"**
- Should trigger `get_weather_forecast` tool
- Returns forecast data
3. **"Compare weather in San Francisco and Seattle"**
- Should use `compare_locations` prompt
- Calls `get_current_weather` for both locations
- Provides comparison
4. **"Search for locations with 'Tokyo' in the name"**
- Should trigger `search_locations` tool
- Returns matching locations