Skip to content

Commit b1e1eb1

Browse files
authored
Merge pull request #3246 from olaservo/fix/tool-annotations
feat(everything): add tool-level annotations to get-annotated-message
2 parents 97ba6b3 + 8f8f5be commit b1e1eb1

19 files changed

Lines changed: 121 additions & 4 deletions

‎src/everything/docs/structure.md‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ src/everything
4848
│ ├── get-sum.ts
4949
│ ├── get-tiny-image.ts
5050
│ ├── gzip-file-as-resource.ts
51+
│ ├── simulate-research-query.ts
5152
│ ├── toggle-simulated-logging.ts
5253
│ ├── toggle-subscriber-updates.ts
5354
│ ├── trigger-elicitation-request.ts
55+
│ ├── trigger-elicitation-request-async.ts
5456
│ ├── trigger-long-running-operation.ts
55-
│ └── trigger-sampling-request.ts
57+
│ ├── trigger-sampling-request.ts
58+
│ └── trigger-sampling-request-async.ts
5659
└── transports
5760
├── sse.ts
5861
├── stdio.ts
@@ -129,7 +132,7 @@ src/everything
129132
- `echo.ts`
130133
- Registers an `echo` tool that takes a message and returns `Echo: {message}`.
131134
- `get-annotated-message.ts`
132-
- Registers an `annotated-message` tool which demonstrates annotated content items by emitting a primary `text` message with `annotations` that vary by `messageType` (`"error" | "success" | "debug"`), and optionally includes an annotated `image` (tiny PNG) when `includeImage` is true.
135+
- Registers a `get-annotated-message` tool which demonstrates content-level annotations. Emits a primary `text` message with content `annotations` (`priority`, `audience`) that vary by `messageType` (`"error" | "success" | "debug"`), and optionally includes an annotated `image` (tiny PNG) when `includeImage` is true. All tools in this server include tool-level annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`).
133136
- `get-env.ts`
134137
- Registers a `get-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration.
135138
- `get-resource-links.ts`
@@ -147,18 +150,24 @@ src/everything
147150
- `GZIP_MAX_FETCH_SIZE` (bytes, default 10 MiB)
148151
- `GZIP_MAX_FETCH_TIME_MILLIS` (ms, default 30000)
149152
- `GZIP_ALLOWED_DOMAINS` (comma-separated allowlist; empty means all domains allowed)
153+
- `simulate-research-query.ts`
154+
- Registers a `simulate-research-query` task-based tool that demonstrates the MCP Tasks feature (SEP-1686). Simulates a multi-stage research operation with progress updates. If the query is marked as ambiguous and the client supports elicitation, it pauses mid-execution to request clarification via `elicitation/create`. Uses `server.experimental.tasks.registerToolTask()` with `execution: { taskSupport: "required" }`.
150155
- `trigger-elicitation-request.ts`
151156
- Registers a `trigger-elicitation-request` tool that sends an `elicitation/create` request to the client/LLM and returns the elicitation result.
157+
- `trigger-elicitation-request-async.ts`
158+
- Registers a `trigger-elicitation-request-async` tool that demonstrates bidirectional MCP tasks for elicitation. Sends an elicitation request with task metadata, then polls the client's `tasks/get` endpoint for completion status before fetching the final result.
152159
- `trigger-sampling-request.ts`
153160
- Registers a `trigger-sampling-request` tool that sends a `sampling/createMessage` request to the client/LLM and returns the sampling result.
161+
- `trigger-sampling-request-async.ts`
162+
- Registers a `trigger-sampling-request-async` tool that demonstrates bidirectional MCP tasks for sampling. Sends a sampling request with task metadata, then polls the client's `tasks/get` endpoint for completion status before fetching the final result.
154163
- `get-structured-content.ts`
155164
- Registers a `get-structured-content` tool that demonstrates structuredContent block responses.
156165
- `get-sum.ts`
157-
- Registers an `get-sum` tool with a Zod input schema that sums two numbers `a` and `b` and returns the result.
166+
- Registers a `get-sum` tool with a Zod input schema that sums two numbers `a` and `b` and returns the result.
158167
- `get-tiny-image.ts`
159168
- Registers a `get-tiny-image` tool, which returns a tiny PNG MCP logo as an `image` content item, along with surrounding descriptive `text` items.
160169
- `trigger-long-running-operation.ts`
161-
- Registers a `long-running-operation` tool that simulates a long-running task over a specified `duration` (seconds) and number of `steps`; emits `notifications/progress` updates when the client supplies a `progressToken`.
170+
- Registers a `trigger-long-running-operation` tool that simulates a long-running task over a specified `duration` (seconds) and number of `steps`; emits `notifications/progress` updates when the client supplies a `progressToken`.
162171
- `toggle-simulated-logging.ts`
163172
- Registers a `toggle-simulated-logging` tool, which starts or stops simulated logging for the invoking session.
164173
- `toggle-subscriber-updates.ts`

‎src/everything/tools/echo.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ const config = {
1313
title: "Echo Tool",
1414
description: "Echoes back the input string",
1515
inputSchema: EchoSchema,
16+
annotations: {
17+
readOnlyHint: true,
18+
destructiveHint: false,
19+
idempotentHint: true,
20+
openWorldHint: false,
21+
},
1622
};
1723

1824
/**

‎src/everything/tools/get-annotated-message.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ const config = {
2121
description:
2222
"Demonstrates how annotations can be used to provide metadata about content.",
2323
inputSchema: GetAnnotatedMessageSchema,
24+
annotations: {
25+
readOnlyHint: true, // This tool only returns data, no side effects
26+
destructiveHint: false, // Does not delete or modify anything
27+
idempotentHint: true, // Same input always produces same output
28+
openWorldHint: false, // Does not interact with external systems
29+
},
2430
};
2531

2632
/**

‎src/everything/tools/get-env.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const config = {
88
description:
99
"Returns all environment variables, helpful for debugging MCP server configuration",
1010
inputSchema: {},
11+
annotations: {
12+
readOnlyHint: true,
13+
destructiveHint: false,
14+
idempotentHint: true,
15+
openWorldHint: false,
16+
},
1117
};
1218

1319
/**

‎src/everything/tools/get-resource-links.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const config = {
2525
description:
2626
"Returns up to ten resource links that reference different types of resources",
2727
inputSchema: GetResourceLinksSchema,
28+
annotations: {
29+
readOnlyHint: true,
30+
destructiveHint: false,
31+
idempotentHint: true,
32+
openWorldHint: false,
33+
},
2834
};
2935

3036
/**

‎src/everything/tools/get-resource-reference.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ const config = {
2828
title: "Get Resource Reference Tool",
2929
description: "Returns a resource reference that can be used by MCP clients",
3030
inputSchema: GetResourceReferenceSchema,
31+
annotations: {
32+
readOnlyHint: true,
33+
destructiveHint: false,
34+
idempotentHint: true,
35+
openWorldHint: false,
36+
},
3137
};
3238

3339
/**

‎src/everything/tools/get-roots-list.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ const config = {
99
description:
1010
"Lists the current MCP roots provided by the client. Demonstrates the roots protocol capability even though this server doesn't access files.",
1111
inputSchema: {},
12+
annotations: {
13+
readOnlyHint: true,
14+
destructiveHint: false,
15+
idempotentHint: true,
16+
openWorldHint: false,
17+
},
1218
};
1319

1420
/**

‎src/everything/tools/get-structured-content.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ const config = {
2727
"Returns structured content along with an output schema for client data validation",
2828
inputSchema: GetStructuredContentInputSchema,
2929
outputSchema: GetStructuredContentOutputSchema,
30+
annotations: {
31+
readOnlyHint: true,
32+
destructiveHint: false,
33+
idempotentHint: true,
34+
openWorldHint: false,
35+
},
3036
};
3137

3238
/**

‎src/everything/tools/get-sum.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ const config = {
1414
title: "Get Sum Tool",
1515
description: "Returns the sum of two numbers",
1616
inputSchema: GetSumSchema,
17+
annotations: {
18+
readOnlyHint: true,
19+
destructiveHint: false,
20+
idempotentHint: true,
21+
openWorldHint: false,
22+
},
1723
};
1824

1925
/**

‎src/everything/tools/get-tiny-image.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const config = {
1111
title: "Get Tiny Image Tool",
1212
description: "Returns a tiny MCP logo image.",
1313
inputSchema: {},
14+
annotations: {
15+
readOnlyHint: true,
16+
destructiveHint: false,
17+
idempotentHint: true,
18+
openWorldHint: false,
19+
},
1420
};
1521

1622
/**

0 commit comments

Comments
 (0)