Skip to content

Add prompts and resources to fast-time-server - #52

Merged
jonpspri merged 2 commits into
mainfrom
fast-time-server-prompts-resources
Oct 13, 2026
Merged

jonpspri merged 2 commits into
mainfrom
fast-time-server-prompts-resources

Conversation

@jonpspri

@jonpspri jonpspri commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add three prompts that drive the server's own tools: current_time (get_system_time), convert_time (convert_time), and server_diagnostics (get_stats + verify-protocol), with typed arguments advertised from the same schema style the tools use.
  • Add resources mirroring the existing surface: config://timezones, server://info (mirrors /version), server://stats (mirrors get_stats), and the time://now/{timezone} resource template (mirrors get_system_time / /api/time).
  • Follow the tools' dual-era wire rules for 2026-07-28 conformance: resultType: "complete" plus SEP-2549 cache directives (cacheScope: "private", ttlMs: 0) on prompts/list, resources/list, resources/templates/list, and resources/read; all three fields absent on legacy sessions; capabilities advertised in initialize and server/discover.
  • Hand-route prompts through the SDK's PromptRouter instead of #[prompt_handler], whose generated list hardcodes CacheScope::Public and would drift from the existing list_tools behavior.
  • Unknown resource URIs return RESOURCE_NOT_FOUND on the legacy era (rewritten to invalid params at 2026-07-28); bad timezones in template reads reuse the tools' exact "Invalid timezone" wording.
  • Loosen the rmcp requirement to any 3.x and float the lockfile to 3.5.0; replace the deprecated ServerInfo alias with ServerConfig.

Testing

  • cargo test: 42/42 (three new integration tests covering both eras: list results and cache directives, prompts/get argument handling and defaults, resources/read for static/dynamic/template URIs, and error codes)
  • cargo fmt --check and cargo clippy --all-targets -- -D warnings: clean
  • Live smoke run on 127.0.0.1:9081: modern-era prompts/list / resources/list / resources/read over stateless HTTP with SEP-2243 headers (Mcp-Name carries the prompt name or resource URI), legacy-era prompts/get / resources/read over an SSE session, REST endpoints unaffected
  • cargo deny --no-default-features check advisories: ok against the updated lockfile

Serve prompts and resources alongside the existing tools on both MCP eras,
with 2026-07-28 conformance matching the tools' wire rules:

- Prompts: current_time, convert_time, and server_diagnostics each render a
  user message that drives one of the server's own tools, with typed
  arguments advertised from the same schema style the tools use.
- Resources: config://timezones, server://info, and server://stats mirror
  the timezone rules, the /version endpoint, and the get_stats tool; the
  time://now/{timezone} template mirrors get_system_time and /api/time.
- prompts/list, resources/list, and resources/templates/list carry
  resultType plus SEP-2549 cache directives (private, ttlMs 0) on the
  modern era only; resources/read does the same since nothing the server
  returns is cache-safe.
- Hand-route prompts through the SDK router instead of #[prompt_handler],
  whose generated list hardcodes CacheScope::Public and would drift from
  the existing list_tools behavior.
- Advertise prompts and resources capabilities in initialize and
  server/discover.

Loosen the rmcp requirement to any 3.x and float the lockfile to 3.5.0;
replace the deprecated ServerInfo alias with ServerConfig.

Signed-off-by: Jonathan Springer <jps@s390x.com>

@lucarlig lucarlig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for two reproducible correctness issues: RFC 6570 expansion of the advertised timezone template produces URIs the resource reader rejects, and raw prompt-argument interpolation can change the embedded tool arguments or produce invalid JSON. The two inline suggestions address these without adding dependencies. Please include regression tests for template expansion and prompt-argument round trips.

Validation of the reviewed head: all 42 tests, formatting, and strict Clippy passed. A release-build smoke test completed 4,000 requests across eight concurrent clients without failures; this was not a comparison against the base commit.

The suggested replacements were also checked locally: 45 tests and strict Clippy passed after updating the existing template assertion and adding three focused regression checks.

Comment thread mcp-servers/rust/fast-time-server/src/main.rs Outdated
Comment thread mcp-servers/rust/fast-time-server/src/main.rs
Advertise time://now/{+timezone} (RFC 6570 reserved expansion) so client
expansion of IANA names and fixed offsets produces URIs the reader
accepts, and serialize prompt arguments with json! so quotes, backslashes,
and newlines survive as JSON string values. Add regression tests for
template expansion and prompt-argument round trips.

Signed-off-by: Jonathan Springer <jps@s390x.com>
@jonpspri

jonpspri commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Both review comments are addressed in 4e64527, applying the suggested changes verbatim:

  • Template: TIME_NOW_URI_TEMPLATE is now time://now/{+timezone} (RFC 6570 reserved expansion). Updated the resources/templates/list assertion, the header comment, the resource-catalog and config://timezones doc strings, and both README references.
  • Prompt escaping: both current_time and convert_time now build their arguments with json! and embed the serialized object, so quotes, backslashes, and newlines survive as JSON string values.
  • Regression tests: three added — template expansion for Asia/Tokyo and +05:30 (plus the advertised-template assertion), and hostile-argument round trips for both prompts that parse the embedded JSON back out and compare for equality. Suite is now 45/45.

Verified locally: cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (45 passed), and a live smoke run confirming resources/templates/list advertises {+timezone}, reserved-expanded reads of time://now/Asia/Tokyo and time://now/+05:30 succeed, and the UTC\", \"timezone\": \"Asia/Tokyo injection now renders as a single escaped JSON string value.

@lucarlig lucarlig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both requested fixes are complete in 4e64527. The advertised {+timezone} template now expands to URIs the reader accepts, and both prompts serialize their argument objects with json!, preserving quotes, backslashes, newlines, braces, and Unicode. The documentation and regression tests were updated.

Rechecked locally: all 45 tests, cargo fmt --check, and strict Clippy passed. Eleven live modern-HTTP checks passed, covering expanded timezone resources and exact argument round trips for both prompts. CI is green. No remaining blocking findings.

@jonpspri
jonpspri merged commit 11cd09b into main Oct 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants