A Model Context Protocol (MCP) plugin for working with time and timezone information. The rstime plugin provides tools for retrieving the current time in different timezones and parsing RFC2822 formatted time strings.
The rstime plugin is a WebAssembly-based MCP plugin written in Rust that exposes time-related functionality through the Model Context Protocol. It allows LLM clients to:
- Get the current time in any timezone
- Parse RFC2822 formatted time strings to Unix timestamps
- Complete timezone names for better user experience
Returns the current time in a specified timezone.
Input:
timezone(optional, string): The timezone identifier (e.g.,America/New_York,Europe/London,Asia/Tokyo). Defaults toUTCif not provided.
Output:
current_time(string): The current time in RFC2822 format for the specified timezone.
Example:
Tool: get_time
Input: {"timezone": "America/Los_Angeles"}
Output: "Tue, 15 Jan 2024 10:30:45 -0800"
Parses an RFC2822 formatted time string and returns the corresponding Unix timestamp.
Input:
time(required, string): The time string in RFC2822 format to parse.
Output:
timestamp(integer): The parsed timestamp in seconds since the Unix epoch.
Example:
Tool: parse_time
Input: {"time": "Tue, 15 Jan 2024 18:30:45 +0000"}
Output: 1705344645
A prompt that guides the user to get the current time for a specific timezone.
Arguments:
timezone(optional, string): The timezone to retrieve time information for. Defaults toUTC.
Response: Returns an assistant message suggesting to get the time for the specified timezone.
- Rust 1.70 or later
- Extism toolchain for WASM compilation
# Build the WebAssembly plugin
cargo build --release --target wasm32-wasip1
# The compiled WASM file will be available at target/wasm32-wasip1/release/plugin.wasmAlternatively, you can use the provided prepare.sh script:
./prepare.shThis will create the compiled rstime.wasm file.
A Dockerfile is included for containerized deployment. Build it with:
docker build -t rstime:latest .The plugin includes comprehensive test coverage. Run tests with, changing the target to your architecture:
cargo test --lib --target x86_64-apple-darwinThe test suite covers:
- Getting time in UTC and various timezones
- Handling invalid timezone names
- Parsing valid and invalid RFC2822 time strings
- Tool listing and metadata
- Prompt retrieval and listing
- Resource operations
- Error handling and edge cases
The plugin supports all timezones from the IANA timezone database through the chrono-tz crate. Some common examples include:
UTC- Coordinated Universal TimeAmerica/New_York- Eastern TimeAmerica/Chicago- Central TimeAmerica/Denver- Mountain TimeAmerica/Los_Angeles- Pacific TimeEurope/London- Greenwich Mean TimeEurope/Paris- Central European TimeAsia/Tokyo- Japan Standard TimeAsia/Shanghai- China Standard TimeAustralia/Sydney- Australian Eastern Time
For a complete list, refer to the IANA timezone database.
- chrono - Date and time handling
- chrono-tz - Timezone support
- extism-pdk - Extism Plugin Development Kit for MCP
- serde - Serialization/deserialization
- serde_json - JSON handling
- anyhow - Error handling
- base64 - Base64 encoding/decoding
When integrated with an MCP-compatible client, you can use the plugin like this:
User: What time is it in Tokyo?
Client calls: get_time tool with {"timezone": "Asia/Tokyo"}
Plugin returns: Current time in RFC2822 format for Asia/Tokyo
Client: The current time in Tokyo is [result]
The plugin follows the Extism PDK architecture:
- lib.rs: Main plugin implementation with tool and prompt logic
- pdk: PDK-specific types and exported functions for MCP communication
- Cargo.toml: Rust dependencies and build configuration
The plugin compiles to WebAssembly and implements the MCP protocol through Extism's foreign function interface.
The plugin gracefully handles common errors:
- Invalid timezone: Returns a descriptive error message
- Missing required arguments: Provides helpful feedback about required parameters
- Invalid time format: Reports parsing errors with context
- Unknown tools/prompts: Returns appropriate error responses
When contributing to this plugin:
- Maintain the existing code style
- Add tests for new functionality
- Update this README with any new features
- Ensure all tests pass before submitting
This plugin is part of the hyper-mcp project. See the main project repository for license information.