Skip to content

Commit 259ec1b

Browse files
authored
Add resources and prompts to time server closes #404 (#709)
Signed-off-by: Mihai Criveti <[email protected]>
1 parent fe0597a commit 259ec1b

File tree

6 files changed

+1364
-0
lines changed

6 files changed

+1364
-0
lines changed

docs/docs/using/servers/go-fast-time-server.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The **fast-time-server** is a high-performance Go-based MCP server that provides
88

99
- **Multiple Transport Modes**: stdio, HTTP (JSON-RPC), SSE, dual (MCP + REST), and REST API
1010
- **Comprehensive Time Operations**: Get system time, convert between timezones
11+
- **MCP Resources**: Timezone data, world times, format examples, business hours
12+
- **MCP Prompts**: Time comparisons, meeting scheduling, detailed conversions
1113
- **REST API**: Traditional HTTP endpoints alongside MCP protocol
1214
- **OpenAPI Documentation**: Interactive Swagger UI and OpenAPI 3.0 specification
1315
- **CORS Support**: Enabled for browser-based testing
@@ -115,6 +117,146 @@ Converts time between different timezones.
115117
}
116118
```
117119

120+
## MCP Resources
121+
122+
The server provides four MCP resources that can be accessed through the MCP protocol:
123+
124+
### timezone://info
125+
Comprehensive timezone information including offsets, DST status, major cities, and population data.
126+
127+
**Example Response:**
128+
```json
129+
{
130+
"timezones": [
131+
{
132+
"id": "America/New_York",
133+
"name": "Eastern Time",
134+
"offset": "-05:00",
135+
"dst": true,
136+
"abbreviation": "EST/EDT",
137+
"major_cities": ["New York", "Toronto", "Montreal"],
138+
"population": 141000000
139+
}
140+
],
141+
"timezone_groups": {
142+
"us_timezones": ["America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles"]
143+
}
144+
}
145+
```
146+
147+
### time://current/world
148+
Current time in major cities around the world, updated in real-time.
149+
150+
**Example Response:**
151+
```json
152+
{
153+
"last_updated": "2025-01-10T16:30:00Z",
154+
"times": {
155+
"New York": "2025-01-10 11:30:00 EST",
156+
"London": "2025-01-10 16:30:00 GMT",
157+
"Tokyo": "2025-01-11 01:30:00 JST"
158+
}
159+
}
160+
```
161+
162+
### time://formats
163+
Examples of supported time formats for parsing and display.
164+
165+
**Example Response:**
166+
```json
167+
{
168+
"input_formats": [
169+
"2006-01-02 15:04:05",
170+
"2006-01-02T15:04:05Z",
171+
"2006-01-02T15:04:05-07:00"
172+
],
173+
"output_formats": {
174+
"iso8601": "2006-01-02T15:04:05Z07:00",
175+
"rfc3339": "2006-01-02T15:04:05Z"
176+
}
177+
}
178+
```
179+
180+
### time://business-hours
181+
Standard business hours across different regions.
182+
183+
**Example Response:**
184+
```json
185+
{
186+
"regions": {
187+
"north_america": {
188+
"standard_hours": "9:00 AM - 5:00 PM",
189+
"lunch_break": "12:00 PM - 1:00 PM",
190+
"working_days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
191+
}
192+
}
193+
}
194+
```
195+
196+
## MCP Prompts
197+
198+
The server provides three prompt templates for common time-related tasks:
199+
200+
### compare_timezones
201+
Compare current times across multiple time zones.
202+
203+
**Arguments:**
204+
- `timezones` (required): Comma-separated list of timezone IDs
205+
- `reference_time` (optional): Reference time (defaults to now)
206+
207+
**Example:**
208+
```json
209+
{
210+
"prompt": "compare_timezones",
211+
"arguments": {
212+
"timezones": "UTC,America/New_York,Asia/Tokyo"
213+
}
214+
}
215+
```
216+
217+
### schedule_meeting
218+
Find optimal meeting time across multiple time zones.
219+
220+
**Arguments:**
221+
- `participants` (required): Comma-separated list of participant locations/timezones
222+
- `duration` (required): Meeting duration in minutes
223+
- `preferred_hours` (optional): Preferred time range (default: "9 AM - 5 PM")
224+
- `date_range` (optional): Date range to consider (default: "next 7 days")
225+
226+
**Example:**
227+
```json
228+
{
229+
"prompt": "schedule_meeting",
230+
"arguments": {
231+
"participants": "New York,London,Tokyo",
232+
"duration": "60",
233+
"preferred_hours": "9 AM - 5 PM"
234+
}
235+
}
236+
```
237+
238+
### convert_time_detailed
239+
Convert time with detailed context.
240+
241+
**Arguments:**
242+
- `time` (required): Time to convert
243+
- `from_timezone` (required): Source timezone
244+
- `to_timezones` (required): Comma-separated list of target timezones
245+
- `include_context` (optional): Include contextual information (true/false)
246+
247+
**Example:**
248+
```json
249+
{
250+
"prompt": "convert_time_detailed",
251+
"arguments": {
252+
"time": "2025-01-10T10:00:00Z",
253+
"from_timezone": "UTC",
254+
"to_timezones": "America/New_York,Europe/London,Asia/Tokyo",
255+
"include_context": "true"
256+
}
257+
}
258+
```
259+
118260
## REST API Endpoints
119261

120262
When using `rest` or `dual` transport modes, the following REST endpoints are available:
@@ -205,6 +347,35 @@ curl http://localhost:8080/api/v1/timezones/Asia/Tokyo/info
205347
}
206348
```
207349

350+
### MCP Resources via REST
351+
352+
```bash
353+
# List all resources
354+
curl http://localhost:8080/api/v1/resources
355+
356+
# Get specific resource
357+
curl http://localhost:8080/api/v1/resources/timezone-info
358+
curl http://localhost:8080/api/v1/resources/current-world
359+
curl http://localhost:8080/api/v1/resources/time-formats
360+
curl http://localhost:8080/api/v1/resources/business-hours
361+
```
362+
363+
### MCP Prompts via REST
364+
365+
```bash
366+
# List all prompts
367+
curl http://localhost:8080/api/v1/prompts
368+
369+
# Execute a prompt
370+
curl -X POST http://localhost:8080/api/v1/prompts/compare_timezones/execute \
371+
-H "Content-Type: application/json" \
372+
-d '{"timezones": "UTC,America/New_York,Asia/Tokyo"}'
373+
374+
curl -X POST http://localhost:8080/api/v1/prompts/schedule_meeting/execute \
375+
-H "Content-Type: application/json" \
376+
-d '{"participants": "New York,London,Tokyo", "duration": "60"}'
377+
```
378+
208379
### Test Endpoints
209380
```bash
210381
# Echo test

mcp-servers/go/fast-time-server/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,35 @@ docker-run-sse-auth: docker-build
180180
-e AUTH_TOKEN=$(TOKEN) \
181181
$(IMAGE) -transport=sse -listen=0.0.0.0 -port=8080 -auth-token=$(TOKEN)
182182

183+
# =============================================================================
184+
# 📚 MCP RESOURCES & PROMPTS TESTING
185+
# =============================================================================
186+
# help: 📚 MCP RESOURCES & PROMPTS
187+
# help: test-resources - Test MCP resources via REST API
188+
# help: test-prompts - Test MCP prompts via REST API
189+
# help: test-mcp - Test all MCP features (resources + prompts)
190+
191+
.PHONY: test-resources test-prompts test-mcp
192+
193+
test-resources:
194+
@echo "$(C_BLUE)➜ Testing MCP Resources...$(C_RESET)"
195+
@curl -s http://localhost:8080/api/v1/resources | jq .
196+
@echo "\n$(C_BLUE)➜ Timezone Info:$(C_RESET)"
197+
@curl -s http://localhost:8080/api/v1/resources/timezone-info | jq '.timezones[0]'
198+
@echo "\n$(C_BLUE)➜ Current World Times:$(C_RESET)"
199+
@curl -s http://localhost:8080/api/v1/resources/current-world | jq .
200+
201+
test-prompts:
202+
@echo "$(C_BLUE)➜ Testing MCP Prompts...$(C_RESET)"
203+
@curl -s http://localhost:8080/api/v1/prompts | jq .
204+
@echo "\n$(C_BLUE)➜ Compare Timezones:$(C_RESET)"
205+
@curl -s -X POST http://localhost:8080/api/v1/prompts/compare_timezones/execute \
206+
-H "Content-Type: application/json" \
207+
-d '{"timezones":"UTC,America/New_York,Asia/Tokyo"}' | jq .
208+
209+
test-mcp: test-resources test-prompts
210+
@echo "\n$(C_BLUE)✔ MCP Features Test Complete$(C_RESET)"
211+
183212
# =============================================================================
184213
# 🚀 BENCHMARKING (hey)
185214
# =============================================================================

mcp-servers/go/fast-time-server/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
## Features
1212

13+
- **MCP Tools**: `get_system_time` and `convert_time` for timezone operations
14+
- **MCP Resources**: Timezone information, world times, format examples, business hours
15+
- **MCP Prompts**: Time comparisons, meeting scheduling, detailed conversions
1316
- Five transports: `stdio`, `http` (JSON-RPC 2.0), `sse`, `dual` (MCP + REST), and `rest` (REST API only)
1417
- REST API with OpenAPI documentation for direct HTTP access
1518
- Single static binary (~2 MiB)
@@ -62,6 +65,49 @@ Also available as releases.
6265
| `-port` | `8080` | Port for HTTP/SSE/dual |
6366
| `-auth-token` | *(empty)* | Bearer token for SSE authentication |
6467

68+
## MCP Features
69+
70+
### Tools
71+
72+
The server provides two main MCP tools:
73+
74+
1. **get_system_time** - Returns the current time in any IANA timezone
75+
- Parameter: `timezone` (optional, defaults to UTC)
76+
77+
2. **convert_time** - Converts time between different timezones
78+
- Parameters: `time`, `source_timezone`, `target_timezone` (all required)
79+
80+
### Resources
81+
82+
The server exposes four MCP resources:
83+
84+
1. **timezone://info** - Comprehensive timezone information
85+
- Includes offset, DST status, major cities, and population data
86+
87+
2. **time://current/world** - Current time in major cities
88+
- Real-time updates for global cities
89+
90+
3. **time://formats** - Time format examples
91+
- Input/output format specifications and examples
92+
93+
4. **time://business-hours** - Business hours by region
94+
- Working hours, lunch breaks, and holidays for different regions
95+
96+
### Prompts
97+
98+
Three prompt templates are available:
99+
100+
1. **compare_timezones** - Compare times across multiple zones
101+
- Arguments: `timezones` (required), `reference_time` (optional)
102+
103+
2. **schedule_meeting** - Find optimal meeting times
104+
- Arguments: `participants` (required), `duration` (required),
105+
`preferred_hours` (optional), `date_range` (optional)
106+
107+
3. **convert_time_detailed** - Convert with context
108+
- Arguments: `time`, `from_timezone`, `to_timezones` (all required),
109+
`include_context` (optional)
110+
65111
## API Reference
66112

67113
### REST API Endpoints
@@ -133,6 +179,35 @@ curl http://localhost:8080/api/v1/timezones/Asia/Tokyo/info
133179

134180
Convert multiple times in a single request.
135181

182+
#### MCP Resources
183+
**GET** `/api/v1/resources` - List all available MCP resources
184+
**GET** `/api/v1/resources/{uri}` - Get specific resource content
185+
186+
Available resource URIs:
187+
- `timezone-info` - Comprehensive timezone information
188+
- `current-world` - Current world times
189+
- `time-formats` - Time format examples
190+
- `business-hours` - Business hours by region
191+
192+
```bash
193+
curl http://localhost:8080/api/v1/resources/timezone-info
194+
```
195+
196+
#### MCP Prompts
197+
**GET** `/api/v1/prompts` - List all available MCP prompts
198+
**POST** `/api/v1/prompts/{name}/execute` - Execute a prompt with arguments
199+
200+
Available prompts:
201+
- `compare_timezones` - Compare times across zones
202+
- `schedule_meeting` - Find optimal meeting times
203+
- `convert_time_detailed` - Convert with context
204+
205+
```bash
206+
curl -X POST http://localhost:8080/api/v1/prompts/compare_timezones/execute \
207+
-H "Content-Type: application/json" \
208+
-d '{"timezones":"UTC,America/New_York,Asia/Tokyo"}'
209+
```
210+
136211
#### Test Endpoints
137212
- **GET** `/api/v1/test/echo` - Echo test endpoint
138213
- **POST** `/api/v1/test/validate` - Validate JSON input

0 commit comments

Comments
 (0)