-
Notifications
You must be signed in to change notification settings - Fork 546
Spec conformance: meta support and spec updates #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexhancock
merged 8 commits into
modelcontextprotocol:main
from
aharvard:feat/spec-conformance-meta-support
Sep 4, 2025
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2a7e60d
feat: add _meta to content blocks and embedded resources; update schemas
aharvard 3180808
feat: set default protocol version; add _meta to content blocks/resou…
aharvard 76d5533
chore: format content.rs via rustfmt
aharvard f021b00
chore(protocol): keep LATEST at 2025-03-26 per review until full 2025…
aharvard e9c8069
feat(prompt): add constructors with optional meta for image and resource
aharvard 1af6906
refactor(prompt): simplify constructors so meta is optional; remove d…
aharvard c8ff500
fix: modify code comment about version
aharvard 6ef61bb
refactor(prompt): rename meta parameters in new_resource function for…
aharvard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,56 +114,76 @@ impl PromptMessage { | |
| content: PromptMessageContent::Text { text: text.into() }, | ||
| } | ||
| } | ||
|
|
||
| /// Create a new image message. `meta` and `annotations` are optional. | ||
| #[cfg(feature = "base64")] | ||
| pub fn new_image( | ||
| role: PromptMessageRole, | ||
| data: &[u8], | ||
| mime_type: &str, | ||
| meta: Option<crate::model::Meta>, | ||
| annotations: Option<Annotations>, | ||
| ) -> Self { | ||
| let mime_type = mime_type.into(); | ||
|
|
||
| let base64 = BASE64_STANDARD.encode(data); | ||
|
|
||
| Self { | ||
| role, | ||
| content: PromptMessageContent::Image { | ||
| image: RawImageContent { | ||
| data: base64, | ||
| mime_type, | ||
| mime_type: mime_type.into(), | ||
| meta, | ||
| } | ||
| .optional_annotate(annotations), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| /// Create a new resource message | ||
| /// Create a new resource message. `top_meta`, `inner_meta`, and `annotations` are optional. | ||
| pub fn new_resource( | ||
| role: PromptMessageRole, | ||
| uri: String, | ||
| mime_type: String, | ||
| mime_type: Option<String>, | ||
| text: Option<String>, | ||
| top_meta: Option<crate::model::Meta>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexhancock, can you check if I executed as you expected? thanks! |
||
| inner_meta: Option<crate::model::Meta>, | ||
| annotations: Option<Annotations>, | ||
| ) -> Self { | ||
| let resource_contents = ResourceContents::TextResourceContents { | ||
| uri, | ||
| mime_type: Some(mime_type), | ||
| text: text.unwrap_or_default(), | ||
| meta: None, | ||
| let resource_contents = match text { | ||
| Some(t) => ResourceContents::TextResourceContents { | ||
| uri, | ||
| mime_type, | ||
| text: t, | ||
| meta: inner_meta, | ||
| }, | ||
| None => ResourceContents::BlobResourceContents { | ||
| uri, | ||
| mime_type, | ||
| blob: String::new(), | ||
| meta: inner_meta, | ||
| }, | ||
| }; | ||
|
|
||
| Self { | ||
| role, | ||
| content: PromptMessageContent::Resource { | ||
| resource: RawEmbeddedResource { | ||
| meta: None, | ||
| meta: top_meta, | ||
| resource: resource_contents, | ||
| } | ||
| .optional_annotate(annotations), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| /// Note: PromptMessage text content does not carry protocol-level _meta per current schema. | ||
| /// This function exists for API symmetry but ignores the meta parameter. | ||
| pub fn new_text_with_meta<S: Into<String>>( | ||
| role: PromptMessageRole, | ||
| text: S, | ||
| _meta: Option<crate::model::Meta>, | ||
| ) -> Self { | ||
| Self::new_text(role, text) | ||
| } | ||
|
|
||
| /// Create a new resource link message | ||
| pub fn new_resource_link(role: PromptMessageRole, resource: super::resource::Resource) -> Self { | ||
| Self { | ||
|
|
@@ -184,6 +204,7 @@ mod tests { | |
| let image_content = RawImageContent { | ||
| data: "base64data".to_string(), | ||
| mime_type: "image/png".to_string(), | ||
| meta: None, | ||
| }; | ||
|
|
||
| let json = serde_json::to_string(&image_content).unwrap(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?