Skip to content

Commit 42273f1

Browse files
authored
Merge pull request modelcontextprotocol#603 from modelcontextprotocol/basil/resource_reference_tool_result
add ResourceLink to CallToolResult
2 parents 4161f02 + bfbd362 commit 42273f1

File tree

4 files changed

+113
-38
lines changed

4 files changed

+113
-38
lines changed

docs/specification/draft/changelog.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ the previous revision, [2025-03-26](/specification/2025-03-26).
2121
5. Added support for **[elicitation](client/elicitation)**, enabling servers to request additional
2222
information from users during interactions.
2323
(PR [#382](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/382))
24+
6. Added support for **[resource links](/specification/draft/server/tools#resource-links)** in
25+
tool call results. (PR [#603](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/603))
2426

2527
## Other schema changes
2628

docs/specification/draft/server/tools.mdx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,38 @@ Tool results may contain [**structured**](#structured-content) or **unstructured
230230
}
231231
```
232232

233+
#### Resource Links
234+
235+
A tool **MAY** return links to [Resources](/specification/draft/server/resources), to provide additional context
236+
or data. In this case, the tool will return a URI that can be subscribed to or fetched by the client:
237+
238+
```json
239+
{
240+
"type": "resource_link",
241+
"uri": "file:///project/src/main.rs",
242+
"name": "main.rs",
243+
"description": "Primary application entry point",
244+
"mimeType": "text/x-rust"
245+
}
246+
```
247+
248+
<Info>
249+
Resource links returned by tools are not guaranteed to appear in the results
250+
of a `resources/list` request.
251+
</Info>
252+
233253
#### Embedded Resources
234254

235-
[Resources](/specification/draft/server/resources) **MAY** be embedded, to provide additional context
236-
or data, behind a URI that can be subscribed to or fetched again by the client later:
255+
A tool **MAY** return embedded [Resource contents](/specification/draft/server/resources), to provide additional context
256+
or data, along with a URI that can be subscribed to or fetched again by the client later:
237257

238258
```json
239259
{
240260
"type": "resource",
241261
"resource": {
242-
"uri": "resource://example",
243-
"mimeType": "text/plain",
244-
"text": "Resource content"
262+
"uri": "file:///project/src/main.rs",
263+
"mimeType": "text/x-rust",
264+
"text": "fn main() {\n println!(\"Hello world!\");\n}"
245265
}
246266
}
247267
```

schema/draft/schema.json

Lines changed: 61 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/draft/schema.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,16 @@ export type Role = "user" | "assistant";
634634
*/
635635
export interface PromptMessage {
636636
role: Role;
637-
content: TextContent | ImageContent | AudioContent | EmbeddedResource;
637+
content: ContentBlock;
638+
}
639+
640+
/**
641+
* A resource that the server is capable of reading, included in a prompt or tool call result.
642+
*
643+
* Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
644+
*/
645+
export interface ResourceLink extends Resource {
646+
type: "resource_link";
638647
}
639648

640649
/**
@@ -652,7 +661,6 @@ export interface EmbeddedResource {
652661
*/
653662
annotations?: Annotations;
654663
}
655-
656664
/**
657665
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
658666
*/
@@ -682,7 +690,7 @@ export interface CallToolResult extends Result {
682690
/**
683691
* A list of content objects that represent the unstructured result of the tool call.
684692
*/
685-
content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[];
693+
content: ContentBlock[];
686694

687695
/**
688696
* An optional JSON object that represents the structured result of the tool call.
@@ -953,6 +961,14 @@ export interface Annotations {
953961
priority?: number;
954962
}
955963

964+
/** */
965+
export type ContentBlock =
966+
| TextContent
967+
| ImageContent
968+
| AudioContent
969+
| ResourceLink
970+
| EmbeddedResource;
971+
956972
/**
957973
* Text provided to or from an LLM.
958974
*/
@@ -1291,7 +1307,7 @@ export interface EnumSchema {
12911307
title?: string;
12921308
description?: string;
12931309
enum: string[];
1294-
enumNames?: string[]; // Display names for enum values
1310+
enumNames?: string[]; // Display names for enum values
12951311
}
12961312

12971313
/**
@@ -1335,7 +1351,11 @@ export type ClientNotification =
13351351
| InitializedNotification
13361352
| RootsListChangedNotification;
13371353

1338-
export type ClientResult = EmptyResult | CreateMessageResult | ListRootsResult | ElicitResult;
1354+
export type ClientResult =
1355+
| EmptyResult
1356+
| CreateMessageResult
1357+
| ListRootsResult
1358+
| ElicitResult;
13391359

13401360
/* Server messages */
13411361
export type ServerRequest =

0 commit comments

Comments
 (0)