Skip to content

Conversation

@aharvard
Copy link
Contributor

@aharvard aharvard commented Sep 3, 2025

This PR updates the Rust SDK to align more closely with the 2025-06-18 Model Context Protocol specification and adds first-class support for meta.

Summary

  • Protocol/version: set LATEST to 2025-06-18
  • meta support: added to text and image content, and embedded resources
  • Annotated model: rename timestamp -> last_modified (schema lastModified)
  • Prompt helpers: added function to create text messages with meta
  • Tests: kept existing Rust tests passing locally; Python-dependent tests are skipped due to local env

Key changes

  • crates/rmcp/src/model.rs
    • Update LATEST constant to 2025-06-18
  • crates/rmcp/src/model/content.rs
    • Add optional meta to RawTextContent and RawImageContent
    • Comments clarifying meta intent and examples
  • crates/rmcp/src/model/prompt.rs
    • new_text_with_meta helper for convenience
    • Test updates to include meta in RawImageContent case
  • crates/rmcp/src/model/annotated.rs
    • Rename timestamp to last_modified and update accessors
  • crates/rmcp/tests/test_message_schema.rs
    • Reviewed; remains compatible

Notes

  • Local environment lacks Python, so Python-dependent tests were not executed; Rust tests pass.
  • Happy to extend meta to any additional surfaced interfaces if maintainers prefer a broader/narrower interpretation of where meta is allowed in the June 18, 2025 spec.

Follow-ups (open to maintainer guidance)

  • Confirm the precise set of interfaces that should expose meta in the SDK surface area
  • Add helpers for setting params._meta on requests (if desired)
  • Tighten schema/tests once final interpretation is agreed

Thanks!

@github-actions github-actions bot added T-test Testing related changes T-config Configuration file changes T-core Core library changes T-model Model/data structure changes labels Sep 3, 2025
@aharvard aharvard force-pushed the feat/spec-conformance-meta-support branch from b52133d to e6902c6 Compare September 3, 2025 12:39
@aharvard aharvard force-pushed the feat/spec-conformance-meta-support branch from e6902c6 to 3180808 Compare September 3, 2025 12:45
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none", rename = "lastModified")]
pub last_modified: Option<DateTime<Utc>>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was curious about this, I asked Goose, why did we change the timestamp to last_modified?

Short answer: to match the spec and be precise.

Details:

Spec alignment: The current MCP spec uses lastModified (camelCase on the wire) to mean “when this content/resource was last updated.” Our previous timestamp field was an SDK-ism and didn’t match the spec name.

Clearer semantics: timestamp was ambiguous (creation time? event time?); lastModified explicitly conveys modification time, which also aligns with common HTTP/metadata semantics.

Cross‑SDK consistency: Other SDKs and examples use lastModified, so this keeps the Rust SDK consistent.

Rust naming: In Rust we expose last_modified and serialize as lastModified to conform to the JSON field name.

@aharvard aharvard marked this pull request as ready for review September 3, 2025 13:06
@aharvard
Copy link
Contributor Author

aharvard commented Sep 3, 2025

@alexhancock, this PR addresses your comment #386 (review)

}

/// Create a new text message with meta
pub fn new_text_with_meta<S: Into<String>>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like we should have ways to create each kind of prompt message with meta optionally supplied vs just this one type that has new_text and new_text_with_meta

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I think I've addressed this. LMK if me and Goose got it wrong, thanks!

@aharvard aharvard force-pushed the feat/spec-conformance-meta-support branch from 4f95e7f to c8ff500 Compare September 3, 2025 15:53
@aharvard aharvard requested a review from alexhancock September 3, 2025 16:08
alexhancock
alexhancock previously approved these changes Sep 4, 2025
mime_type: String,
mime_type: Option<String>,
text: Option<String>,
top_meta: Option<crate::model::Meta>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

resource_meta and resource_content_meta perhaps better naming here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexhancock, can you check if I executed as you expected? thanks!

@alexhancock alexhancock merged commit 4eb413b into modelcontextprotocol:main Sep 4, 2025
11 checks passed
@github-actions github-actions bot mentioned this pull request Sep 4, 2025
takumi-earth pushed a commit to earthlings-dev/rmcp that referenced this pull request Jan 27, 2026
…#415)

* feat: add _meta to content blocks and embedded resources; update schemas

* feat: set default protocol version; add _meta to content blocks/resources; update schemas

* chore: format content.rs via rustfmt

* chore(protocol): keep LATEST at 2025-03-26 per review until full 2025-06-18 compliance

* feat(prompt): add constructors with optional meta for image and resource

- Keep text helper; meta is currently ignored for text until schema supports it.

* refactor(prompt): simplify constructors so meta is optional; remove duplicate non-meta variants

* fix: modify code comment about version

* refactor(prompt): rename meta parameters in new_resource function for clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-model Model/data structure changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants