sergei-grigorev/mcp-server-play
If you are the rightful owner of mcp-server-play and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Server: Weather and Time Information Service is a learning project utilizing the RMCP library to demonstrate async Rust programming and microservice architecture.
MCP Server: Weather and Time Information Service
Project Overview
This Model Context Protocol (MCP) server is a learning project that leverages the RMCP (Rust Model Context Protocol) library to demonstrate:
- Async Rust programming with tokio
- Implementing a flexible microservice architecture
- Using the RMCP SDK for building extensible tools
The server provides two primary tools:
- Weather Information: Retrieve weather data for a specific city and country
- Local Time: Get the current local time for a given city and country
About RMCP
RMCP is a modern Rust SDK for the Model Context Protocol, offering:
- Clean and efficient async runtime with tokio
- Flexible and extensible tool implementation
- Improved data type handling compared to official SDKs
- Support for various transport mechanisms
- Server-Sent Events (SSE) for real-time communication
- Lightweight and efficient one-way server-to-client data streaming
- Built-in reconnection support and event tracking
Purpose
The primary goal of this project is to:
- Learn Rust programming
- Explore RMCP library capabilities
Features
- Weather data retrieval
- Local time information
- Stdio-based communication
- Structured logging with tracing
Prerequisites
- Rust (latest stable version)
- Cargo package manager
- just command runner
- Install with Homebrew:
brew install just - Install with Cargo:
cargo install just
- Install with Homebrew:
- API keys for:
- WeatherAPI for weather data
- IP Geolocation API for time data
Configuration
The server can be configured using the following environment variables:
BIND_ADDRESS: The IP address to bind the server to (default:0.0.0.0)PORT: The port number to listen on (default:8000)
Example usage:
# Bind to localhost on port 3000
BIND_ADDRESS=127.0.0.1 PORT=3000 cargo run
# Use default bind address but change port
PORT=8080 cargo run
Environment Setup
-
Copy the example environment file:
cp .env.example .env -
Edit the
.envfile and replace the placeholder values with your actual API keys:WEATHER_API_KEY: Get it from WeatherAPIIP_GEOLOCATION_API_KEY: Get it from IP Geolocation API
-
Optionally, you can also configure:
BIND_ADDRESS: The IP address to bind the server to (default:0.0.0.0)PORT: The port number to listen on (default:8000)
Installation
-
Clone the repository:
git clone https://github.com/sergei-grigorev/mcp-server-play.git cd mcp-server-play -
Build the project:
cargo build
Development Commands
The project uses just as a command runner. Available commands:
just # List available commands
just build # Build release artifact
just check # Run checks (clippy, fmt, etc.)
just clean # Clean build artifacts
just format # Format code using rustfmt
just serve # Run the server in development mode
just test # Run tests
Running the Server
Run the server using just:
just serve
Project Structure
src/main.rs: Entry point and server initializationsrc/api/mod.rs: Main server implementationweather.rs: Weather data retrieval logicweather/response.rs: Weather API response modelstime.rs: Time data retrieval logictime/response.rs: Time API response models
src/models/mod.rs: Models module definitionsweather.rs: Weather request/response modelstime.rs: Time request/response models
Tools and Endpoints
Weather Information
- Endpoint:
get_weather - Parameters:
city: Name of the citycountry: Country codeunit: Temperature unit (optional)- Values:
C(Celsius) orF(Fahrenheit) - Default:
C
- Values:
Local Time
- Endpoint:
get_local_time - Parameters:
city: Name of the citycountry: Country code
License
MIT