8000 Add several annotation fields by justin-yi-wang · Pull Request #201 · modelcontextprotocol/modelcontextprotocol · GitHub
[go: up one dir, main page]

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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions schema/2025-03-26/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,34 @@
},
"type": "array"
},
"contentSource": {
"description": "Attribution information for the content provider(s).\n\nIdentifies the original platform, service, or content creator. Multiple sources\nindicate aggregated or compiled content. Used for attribution, filtering, and\nhelping users identify trusted content origins.",
"items": {
"type": "string"
},
"type": "array"
},
"contentType": {
"description": "Semantic category of the object.\n\nRepresents the nature of the content in a user-facing format. Should use simple, recognizable terms\nthat categorize the data for users (e.g., \"Webpage\", \"Song\", \"Article\", \"Image\", \"Document\").\nThis helps clients render appropriate UI treatments and helps users understand what kind of\ncontent they're interacting with.",
"type": "string"
},
"displayTitle": {
"description": "Primary display name for the content.\n\nUsed for UI headings, navigation elements, content identification, etc.\nShould be concise yet descriptive enough to distinguish this content\nfrom others (e.g., webpage title, document name, media title).",
"type": "string"
},
"iconUrl": {
"description": "A URL from which a client can fetch an icon to represent this object.",
"type": "string"
},
"priority": {
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
"maximum": 1,
"minimum": 0,
"type": "number"
},
"sourceUrl": {
"description": "Direct link to access the original content.\n\nAllows users to navigate to the source material in its native context.\nMay require authentication if pointing to protected resources.",
"type": "string"
}
},
"type": "object"
Expand Down Expand Up @@ -638,6 +661,10 @@
"description": "This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.",
"type": "object"
},
"annotations": {
"$ref": "#/definitions/ServerAnnotations",
"description": "Optional annotations for the client."
},
"capabilities": {
"$ref": "#/definitions/ServerCapabilities"
},
Expand Down Expand Up @@ -1771,6 +1798,19 @@
],
"type": "object"
},
"ServerAnnotations": {
"properties": {
"iconUrl": {
"description": "A URL from which a client can fetch an icon to represent the server.",
"type": "string"
},
"serverName": {
"description": "Identifier for the server instance or service.\n\nHuman-readable name used for server identification. Should be concise yet distinctive enough to identify \nthis specific server among multiple instances.",
"type": "string"
}
},
"type": "object"
},
"ServerCapabilities": {
"description": "Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.",
"properties": {
Expand Down
62 changes: 62 additions & 0 deletions schema/2025-03-26/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ export interface InitializeRequest extends Request {
};
}


export interface ServerAnnotations {
/**
* Identifier for the server instance or service.
*
* Human-readable name used for server identification. Should be concise yet distinctive enough to identify
* this specific server among multiple instances.
*/
serverName?: string;

/**
* A URL from which a client can fetch an icon to represent the server.
*/
iconUrl?: string;
}

/**
* After receiving an initialize request from the client, the server sends this response.
*/
Expand All @@ -190,6 +206,11 @@ export interface InitializeResult extends Result {
* This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
*/
instructions?: string;

/**
* 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
Member

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
Member

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?

}

/**
Expand Down Expand Up @@ -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?

/**
* Primary display name for the content.
*
* Used for UI headings, navigation elements, content identification, etc.
* Should be concise yet descriptive enough to distinguish this content
* from others (e.g., webpage title, document name, media title).
*/
displayTitle?: string;

/**
* A URL from which a client can fetch an icon to represent this object.
*/
iconUrl?: string;

/**
* Attribution information for the content provider(s).
*
* Identifies the original platform, service, or content creator. Multiple sources
* 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


/**
* 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
Member

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

* 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.


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

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

}

/**
Expand Down
0