A PHP implementation of a Model Context Protocol (MCP) server that provides weather information using the Open-Meteo API (no API key required).
- PHP 8.1 or higher
allow_url_fopenenabled in php.ini
php composer.phar installRun the test suite with PHPUnit:
php phpunit.pharThe project includes tests for both core components:
- McpServerTest - Tests MCP protocol handling including tool registration, invocation, JSON-RPC responses, and error handling
- WeatherServiceTest - Tests weather data processing including compass direction conversion, weather code mapping, and API response handling (uses mocks to avoid HTTP requests)
php server.phpThe server communicates via stdio using JSON-RPC 2.0.
Add to your claude_desktop_config.json:
{
"mcpServers": {
"weather": {
"command": "php",
"args": ["/full/path/to/server.php"]
}
}
}This project includes a .mcp.json file that automatically configures the weather MCP server when you open the project in Claude Code. Simply clone the repository and open it with Claude Code - the weather tools will be available immediately.
To add this server globally (available in all projects), use the Claude Code CLI:
claude mcp add weather php /full/path/to/server.phpOr add it to your user-level configuration at ~/.claude/settings.json:
{
"mcpServers": {
"weather": {
"command": "php",
"args": ["/full/path/to/server.php"]
}
}
}To use this MCP server with DevoxxGenie in IntelliJ IDEA or other JetBrains IDEs:
- Open DevoxxGenie settings (Settings > Tools > DevoxxGenie)
- Navigate to the MCP Servers configuration
- Add a new server with these settings:
| Setting | Value |
|---|---|
| Name | php-weather |
| Transport Type | STDIO |
| Command | php |
| Arguments | /full/path/to/server.php |
Or use the provided mcp-servers-config.json file:
{
"mcpServers": {
"php-weather": {
"command": "php",
"args": [
"/full/path/to/server.php"
],
"env": {}
}
}
}Note: Replace /full/path/to/server.php with the actual absolute path to server.php on your system.
Once configured, DevoxxGenie will discover the get_current_weather tool and the AI assistant can use it to fetch weather information.
Get current weather conditions for a location.
Parameters:
location(required): City name or location (e.g., "London", "New York", "Tokyo")
Example response:
Current Weather for London, United Kingdom
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Conditions: Overcast
Temperature: 9.3°C (feels like 7.8°C)
Humidity: 88%
Wind: 6.0 km/h from SSE
Coordinates: 51.5085, -0.1257
Updated: 2026-01-19T10:00
Get a weather forecast for a location.
Parameters:
location(required): City name or locationdays(optional): Number of days to forecast (1-16, default: 5)
Example response:
3-Day Forecast for Tokyo, Japan
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2026-01-19
Overcast
High: 11.1°C | Low: 2.2°C
Precipitation: 0% | Wind: 4.5 km/h
2026-01-20
Partly cloudy
High: 7.1°C | Low: 0.5°C
Precipitation: 0% | Wind: 13.3 km/h
├── .mcp.json # Claude Code MCP configuration (auto-loads server)
├── composer.json # Project dependencies
├── server.php # Main entry point
├── mcp-servers-config.json # MCP server configuration for clients
├── phpunit.xml # PHPUnit configuration
├── phpunit.phar # PHPUnit executable
├── src/
│ ├── McpServer.php # MCP protocol implementation
│ └── WeatherService.php # Weather API client
├── tests/
│ ├── McpServerTest.php # MCP server tests
│ └── WeatherServiceTest.php # Weather service tests
└── README.md
Weather data is provided by Open-Meteo, a free weather API that requires no API key.