Skip to content

Add several annotation fields #201

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

justin-yi-wang
Copy link

@justin-yi-wang justin-yi-wang commented Mar 15, 2025

This PR adds several optional fields for clients to power UI elements with. Fields are added to Annotations (for ToolResults) and a new ServerAnnotations type (analogous to ToolAnnotations).

Motivation and Context

Having said fields allows for richer client experiences.

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Sorry, something went wrong.

@bhosmer-ant bhosmer-ant mentioned this pull request Mar 18, 2025
9 tasks
* indicate aggregated or compiled content. Used for attribution, filtering, and
* helping users identify trusted content origins.
*/
contentSource?: string[];
Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure if it makes sense to make this and contentType available to just resources or all objects containing Annotations - open to guidance

/**
* Optional annotations for the client.
*/
annotations?: ServerAnnotations;
Copy link
Author

Choose a reason for hiding this comment

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

I believe this is the best place to expose server annotations, but let me know if I'm missing anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could be added to Implementation

Copy link
Contributor

Choose a reason for hiding this comment

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

infact these could both just be added to the implementation piece. potentially humanReadableName but also, could we also just use Implementation.name for this purpose? also - I'm thinking we could just use favicon for the server icon also?

Copy link
Author

Choose a reason for hiding this comment

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

implementation is also used for ClientInfo, where it wouldn't make sense to send these fields. We can remove serverName in favor for implementation.name (wanted more emphasis on human readability but this does seems confusing).

I'm thinking we could just use favicon for the server icon also

Is this referring to the result favicons or is there another favicon that I'm missing?

@justin-yi-wang justin-yi-wang marked this pull request as ready for review March 27, 2025 00:04
Copy link
Contributor

@jerome3o-anthropic jerome3o-anthropic left a comment

Choose a reason for hiding this comment

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

had a quick look, haven't thought very deeply on it though.

Also - the diff should be on the schema/draft/schema.* files instead of the released version

/**
* Optional annotations for the client.
*/
annotations?: ServerAnnotations;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be added to Implementation

/**
* Optional annotations for the client.
*/
annotations?: ServerAnnotations;
Copy link
Contributor

Choose a reason for hiding this comment

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

infact these could both just be added to the implementation piece. potentially humanReadableName but also, could we also just use Implementation.name for this purpose? also - I'm thinking we could just use favicon for the server icon also?

* Semantic category of the object.
*
* Represents the nature of the content in a user-facing format. Should use simple, recognizable terms
* that categorize the data for users (e.g., "Webpage", "Song", "Article", "Image", "Document").
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the type of the content i.e. ImageContent / TextContent could probably represent this information (especially for for the image piece).

Also - this seems specific to a search tool, how are you imagining this being used? on each content block from a tool you might have different UI treatment, independent of it being and image vs text?

Copy link
Author

Choose a reason for hiding this comment

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

imo it makes sense to have a descriptive/semantic field as opposed to the format of the data itself. for example some tools might return the weather as text but it still makes sense to annotate it as "Weather". For image, an example might be "Map".

I did think about only having this on EmbeddedResource, which might force MCP servers to be more specific about the types they return, but I think the use cases above are still valid - clients can choose to extrapolate info off the type of content or use this field

Copy link
Author

Choose a reason for hiding this comment

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

very simply, this can just be a text label in the UI denoting to the user what the content is. doesn't need to be an entirely different UI treatment

* Allows users to navigate to the source material in its native context.
* May require authentication if pointing to protected resources.
*/
sourceUrl?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this differ from content source?

Copy link
Author

Choose a reason for hiding this comment

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

content source is a human-readable (list of) name(s) describing where the information is from. sourceUrl is a single URL from which the content can be accessed in its original context

@justin-yi-wang
Copy link
Author

@jerome3o-anthropic my bad on changing the wrong file - I'll move them over once we resolve these threads

@@ -934,6 +955,47 @@ export interface Annotations {
* @maximum 1
*/
priority?: number;

Choose a reason for hiding this comment

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

@justin-yi-wang what happens if the tool result returns a list of items? Don't these fields need to map to each item within a tool result?

* This helps clients render appropriate UI treatments and helps users understand what kind of
* content they're interacting with.
*/
contentType?: string;
Copy link

Choose a reason for hiding this comment

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

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.

None yet

5 participants