|
| 1 | +# Time MCP Server |
| 2 | + |
| 3 | +A Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection. |
| 4 | + |
| 5 | +### Available Tools |
| 6 | + |
| 7 | +- `get_current_time` - Get current time in a specific timezone or system timezone. |
| 8 | + - Optional argument: `timezone` (string): IANA timezone name (e.g., 'America/New_York', 'Europe/London') |
| 9 | + - If timezone is not provided, returns time in system timezone |
| 10 | + |
| 11 | +- `convert_time` - Convert time between timezones. |
| 12 | + - Required arguments: |
| 13 | + - `source_timezone` (string): Source IANA timezone name |
| 14 | + - `time` (string): Time in 24-hour format (HH:MM) |
| 15 | + - `target_timezone` (string): Target IANA timezone name |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +### Using uv (recommended) |
| 20 | + |
| 21 | +When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will |
| 22 | +use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *mcp-server-time*. |
| 23 | + |
| 24 | +### Using PIP |
| 25 | + |
| 26 | +Alternatively you can install `mcp-server-time` via pip: |
| 27 | + |
| 28 | +```bash |
| 29 | +pip install mcp-server-time |
| 30 | +``` |
| 31 | + |
| 32 | +After installation, you can run it as a script using: |
| 33 | + |
| 34 | +```bash |
| 35 | +python -m mcp_server_time |
| 36 | +``` |
| 37 | + |
| 38 | +## Configuration |
| 39 | + |
| 40 | +### Configure for Claude.app |
| 41 | + |
| 42 | +Add to your Claude settings: |
| 43 | + |
| 44 | +<details> |
| 45 | +<summary>Using uvx</summary> |
| 46 | + |
| 47 | +```json |
| 48 | +"mcpServers": { |
| 49 | + "time": { |
| 50 | + "command": "uvx", |
| 51 | + "args": ["mcp-server-time"] |
| 52 | + } |
| 53 | +} |
| 54 | +``` |
| 55 | +</details> |
| 56 | + |
| 57 | +<details> |
| 58 | +<summary>Using pip installation</summary> |
| 59 | + |
| 60 | +```json |
| 61 | +"mcpServers": { |
| 62 | + "time": { |
| 63 | + "command": "python", |
| 64 | + "args": ["-m", "mcp_server_time"] |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | +</details> |
| 69 | + |
| 70 | +### Configure for Zed |
| 71 | + |
| 72 | +Add to your Zed settings.json: |
| 73 | + |
| 74 | +<details> |
| 75 | +<summary>Using uvx</summary> |
| 76 | + |
| 77 | +```json |
| 78 | +"context_servers": [ |
| 79 | + "mcp-server-time": { |
| 80 | + "command": "uvx", |
| 81 | + "args": ["mcp-server-time"] |
| 82 | + } |
| 83 | +], |
| 84 | +``` |
| 85 | +</details> |
| 86 | + |
| 87 | +<details> |
| 88 | +<summary>Using pip installation</summary> |
| 89 | + |
| 90 | +```json |
| 91 | +"context_servers": { |
| 92 | + "mcp-server-time": { |
| 93 | + "command": "python", |
| 94 | + "args": ["-m", "mcp_server_time"] |
| 95 | + } |
| 96 | +}, |
| 97 | +``` |
| 98 | +</details> |
| 99 | + |
| 100 | +### Customization - System Timezone |
| 101 | + |
| 102 | +By default, the server automatically detects your system's timezone. You can override this by adding the argument `--local-timezone` to the `args` list in the configuration. |
| 103 | + |
| 104 | +Example: |
| 105 | +```json |
| 106 | +{ |
| 107 | + "command": "python", |
| 108 | + "args": ["-m", "mcp_server_time", "--local-timezone=America/New_York"] |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +## Example Interactions |
| 113 | + |
| 114 | +1. Get current time (using system timezone): |
| 115 | +```json |
| 116 | +{ |
| 117 | + "name": "get_current_time", |
| 118 | + "arguments": {} |
| 119 | +} |
| 120 | +``` |
| 121 | +Response: |
| 122 | +```json |
| 123 | +{ |
| 124 | + "timezone": "Europe/London", |
| 125 | + "time": "14:30 BST", |
| 126 | + "date": "2024-11-25", |
| 127 | + "full_datetime": "2024-11-25 14:30:00 BST", |
| 128 | + "is_dst": true |
| 129 | +} |
| 130 | +``` |
| 131 | + |
| 132 | +2. Get current time in specific timezone: |
| 133 | +```json |
| 134 | +{ |
| 135 | + "name": "get_current_time", |
| 136 | + "arguments": { |
| 137 | + "timezone": "America/New_York" |
| 138 | + } |
| 139 | +} |
| 140 | +``` |
| 141 | +Response: |
| 142 | +```json |
| 143 | +{ |
| 144 | + "timezone": "America/New_York", |
| 145 | + "time": "09:30 EDT", |
| 146 | + "date": "2024-11-25", |
| 147 | + "full_datetime": "2024-11-25 09:30:00 EDT", |
| 148 | + "is_dst": true |
| 149 | +} |
| 150 | +``` |
| 151 | + |
| 152 | +3. Convert time between timezones: |
| 153 | +```json |
| 154 | +{ |
| 155 | + "name": "convert_time", |
| 156 | + "arguments": { |
| 157 | + "source_timezone": "America/New_York", |
| 158 | + "time": "16:30", |
| 159 | + "target_timezone": "Asia/Tokyo" |
| 160 | + } |
| 161 | +} |
| 162 | +``` |
| 163 | +Response: |
| 164 | +```json |
| 165 | +{ |
| 166 | + "source": { |
| 167 | + "timezone": "America/New_York", |
| 168 | + "time": "16:30 EDT", |
| 169 | + "date": "2024-11-25" |
| 170 | + }, |
| 171 | + "target": { |
| 172 | + "timezone": "Asia/Tokyo", |
| 173 | + "time": "05:30 JST", |
| 174 | + "date": "2024-11-26" |
| 175 | + }, |
| 176 | + "time_difference": "+13.0h", |
| 177 | + "date_changed": true, |
| 178 | + "day_relation": "next day" |
| 179 | +} |
| 180 | +``` |
| 181 | + |
| 182 | +## Tips for Using IANA Timezone Names |
| 183 | + |
| 184 | +Common timezone formats: |
| 185 | +- North America: `America/New_York`, `America/Los_Angeles`, `America/Chicago` |
| 186 | +- Europe: `Europe/London`, `Europe/Paris`, `Europe/Berlin` |
| 187 | +- Asia: `Asia/Tokyo`, `Asia/Shanghai`, `Asia/Dubai` |
| 188 | +- Pacific: `Pacific/Auckland`, `Pacific/Honolulu` |
| 189 | +- Australia: `Australia/Sydney`, `Australia/Melbourne` |
| 190 | + |
| 191 | +The server will automatically detect and use your system timezone if no specific timezone is provided. |
| 192 | + |
| 193 | +## Debugging |
| 194 | + |
| 195 | +You can use the MCP inspector to debug the server. For uvx installations: |
| 196 | + |
| 197 | +```bash |
| 198 | +npx @modelcontextprotocol/inspector uvx mcp-server-time |
| 199 | +``` |
| 200 | + |
| 201 | +Or if you've installed the package in a specific directory or are developing on it: |
| 202 | + |
| 203 | +```bash |
| 204 | +cd path/to/servers/src/time |
| 205 | +npx @modelcontextprotocol/inspector uv run mcp-server-time |
| 206 | +``` |
| 207 | + |
| 208 | +## Examples of Questions for Claude |
| 209 | + |
| 210 | +1. "What time is it now?" (will use system timezone) |
| 211 | +2. "What time is it in Tokyo?" |
| 212 | +3. "When it's 4 PM in New York, what time is it in London?" |
| 213 | +4. "Convert 9:30 AM Tokyo time to New York time" |
| 214 | + |
| 215 | +## Contributing |
| 216 | + |
| 217 | +We encourage contributions to help expand and improve mcp-server-time. Whether you want to add new time-related tools, enhance existing functionality, or improve documentation, your input is valuable. |
| 218 | + |
| 219 | +For examples of other MCP servers and implementation patterns, see: |
| 220 | +https://github.com/modelcontextprotocol/servers |
| 221 | + |
| 222 | +Pull requests are welcome! Feel free to contribute new ideas, bug fixes, or enhancements to make mcp-server-time even more powerful and useful. |
| 223 | + |
| 224 | +## License |
| 225 | + |
| 226 | +mcp-server-time is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository. |
0 commit comments