Merge pull request #3246 from olaservo/fix/tool-annotations

feat(everything): add tool-level annotations to get-annotated-message
This commit is contained in:
Alex Akimov 2026-05-17 19:59:27 +02:00 • committed by GitHub
commit b1e1eb1a55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 121 additions and 4 deletions

View file

@ -48,11 +48,14 @@ src/everything
│ ├── get-sum.ts │ ├── get-sum.ts
│ ├── get-tiny-image.ts │ ├── get-tiny-image.ts
│ ├── gzip-file-as-resource.ts │ ├── gzip-file-as-resource.ts
│ ├── simulate-research-query.ts
│ ├── toggle-simulated-logging.ts │ ├── toggle-simulated-logging.ts
│ ├── toggle-subscriber-updates.ts │ ├── toggle-subscriber-updates.ts
│ ├── trigger-elicitation-request.ts │ ├── trigger-elicitation-request.ts
│ ├── trigger-elicitation-request-async.ts
│ ├── trigger-long-running-operation.ts │ ├── trigger-long-running-operation.ts
│ └── trigger-sampling-request.ts │ ├── trigger-sampling-request.ts
│ └── trigger-sampling-request-async.ts
└── transports └── transports
├── sse.ts ├── sse.ts
├── stdio.ts ├── stdio.ts
@ -129,7 +132,7 @@ src/everything
- `echo.ts` - `echo.ts`
- Registers an `echo` tool that takes a message and returns `Echo: {message}`. - Registers an `echo` tool that takes a message and returns `Echo: {message}`.
- `get-annotated-message.ts` - `get-annotated-message.ts`
- 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. - 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`).
- `get-env.ts` - `get-env.ts`
- Registers a `get-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration. - Registers a `get-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration.
- `get-resource-links.ts` - `get-resource-links.ts`
@ -147,18 +150,24 @@ src/everything
- `GZIP_MAX_FETCH_SIZE` (bytes, default 10 MiB) - `GZIP_MAX_FETCH_SIZE` (bytes, default 10 MiB)
- `GZIP_MAX_FETCH_TIME_MILLIS` (ms, default 30000) - `GZIP_MAX_FETCH_TIME_MILLIS` (ms, default 30000)
- `GZIP_ALLOWED_DOMAINS` (comma-separated allowlist; empty means all domains allowed) - `GZIP_ALLOWED_DOMAINS` (comma-separated allowlist; empty means all domains allowed)
- `simulate-research-query.ts`
- 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" }`.
- `trigger-elicitation-request.ts` - `trigger-elicitation-request.ts`
- Registers a `trigger-elicitation-request` tool that sends an `elicitation/create` request to the client/LLM and returns the elicitation result. - Registers a `trigger-elicitation-request` tool that sends an `elicitation/create` request to the client/LLM and returns the elicitation result.
- `trigger-elicitation-request-async.ts`
- 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.
- `trigger-sampling-request.ts` - `trigger-sampling-request.ts`
- Registers a `trigger-sampling-request` tool that sends a `sampling/createMessage` request to the client/LLM and returns the sampling result. - Registers a `trigger-sampling-request` tool that sends a `sampling/createMessage` request to the client/LLM and returns the sampling result.
- `trigger-sampling-request-async.ts`
- 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.
- `get-structured-content.ts` - `get-structured-content.ts`
- Registers a `get-structured-content` tool that demonstrates structuredContent block responses. - Registers a `get-structured-content` tool that demonstrates structuredContent block responses.
- `get-sum.ts` - `get-sum.ts`
- Registers an `get-sum` tool with a Zod input schema that sums two numbers `a` and `b` and returns the result. - Registers a `get-sum` tool with a Zod input schema that sums two numbers `a` and `b` and returns the result.
- `get-tiny-image.ts` - `get-tiny-image.ts`
- Registers a `get-tiny-image` tool, which returns a tiny PNG MCP logo as an `image` content item, along with surrounding descriptive `text` items. - Registers a `get-tiny-image` tool, which returns a tiny PNG MCP logo as an `image` content item, along with surrounding descriptive `text` items.
- `trigger-long-running-operation.ts` - `trigger-long-running-operation.ts`
- 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`. - 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`.
- `toggle-simulated-logging.ts` - `toggle-simulated-logging.ts`
- Registers a `toggle-simulated-logging` tool, which starts or stops simulated logging for the invoking session. - Registers a `toggle-simulated-logging` tool, which starts or stops simulated logging for the invoking session.
- `toggle-subscriber-updates.ts` - `toggle-subscriber-updates.ts`

View file

@ -13,6 +13,12 @@ const config = {
title: "Echo Tool", title: "Echo Tool",
description: "Echoes back the input string", description: "Echoes back the input string",
inputSchema: EchoSchema, inputSchema: EchoSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -21,6 +21,12 @@ const config = {
description: description:
"Demonstrates how annotations can be used to provide metadata about content.", "Demonstrates how annotations can be used to provide metadata about content.",
inputSchema: GetAnnotatedMessageSchema, inputSchema: GetAnnotatedMessageSchema,
annotations: {
readOnlyHint: true, // This tool only returns data, no side effects
destructiveHint: false, // Does not delete or modify anything
idempotentHint: true, // Same input always produces same output
openWorldHint: false, // Does not interact with external systems
},
}; };
/** /**

View file

@ -8,6 +8,12 @@ const config = {
description: description:
"Returns all environment variables, helpful for debugging MCP server configuration", "Returns all environment variables, helpful for debugging MCP server configuration",
inputSchema: {}, inputSchema: {},
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -25,6 +25,12 @@ const config = {
description: description:
"Returns up to ten resource links that reference different types of resources", "Returns up to ten resource links that reference different types of resources",
inputSchema: GetResourceLinksSchema, inputSchema: GetResourceLinksSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -28,6 +28,12 @@ const config = {
title: "Get Resource Reference Tool", title: "Get Resource Reference Tool",
description: "Returns a resource reference that can be used by MCP clients", description: "Returns a resource reference that can be used by MCP clients",
inputSchema: GetResourceReferenceSchema, inputSchema: GetResourceReferenceSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -9,6 +9,12 @@ const config = {
description: description:
"Lists the current MCP roots provided by the client. Demonstrates the roots protocol capability even though this server doesn't access files.", "Lists the current MCP roots provided by the client. Demonstrates the roots protocol capability even though this server doesn't access files.",
inputSchema: {}, inputSchema: {},
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -27,6 +27,12 @@ const config = {
"Returns structured content along with an output schema for client data validation", "Returns structured content along with an output schema for client data validation",
inputSchema: GetStructuredContentInputSchema, inputSchema: GetStructuredContentInputSchema,
outputSchema: GetStructuredContentOutputSchema, outputSchema: GetStructuredContentOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -14,6 +14,12 @@ const config = {
title: "Get Sum Tool", title: "Get Sum Tool",
description: "Returns the sum of two numbers", description: "Returns the sum of two numbers",
inputSchema: GetSumSchema, inputSchema: GetSumSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -11,6 +11,12 @@ const config = {
title: "Get Tiny Image Tool", title: "Get Tiny Image Tool",
description: "Returns a tiny MCP logo image.", description: "Returns a tiny MCP logo image.",
inputSchema: {}, inputSchema: {},
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -47,6 +47,12 @@ const config = {
description: description:
"Compresses a single file using gzip compression. Depending upon the selected output type, returns either the compressed data as a gzipped resource or a resource link, allowing it to be downloaded in a subsequent request during the current session.", "Compresses a single file using gzip compression. Depending upon the selected output type, returns either the compressed data as a gzipped resource or a resource link, allowing it to be downloaded in a subsequent request during the current session.",
inputSchema: GZipFileAsResourceSchema, inputSchema: GZipFileAsResourceSchema,
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: true,
openWorldHint: true,
},
}; };
/** /**

View file

@ -255,6 +255,12 @@ export const registerSimulateResearchQueryTool = (server: McpServer) => {
"If 'ambiguous' is true and client supports elicitation, sends an elicitation request for clarification.", "If 'ambiguous' is true and client supports elicitation, sends an elicitation request for clarification.",
inputSchema: SimulateResearchQuerySchema, inputSchema: SimulateResearchQuerySchema,
execution: { taskSupport: "required" }, execution: { taskSupport: "required" },
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
}, },
{ {
/** /**

View file

@ -11,6 +11,12 @@ const config = {
title: "Toggle Simulated Logging", title: "Toggle Simulated Logging",
description: "Toggles simulated, random-leveled logging on or off.", description: "Toggles simulated, random-leveled logging on or off.",
inputSchema: {}, inputSchema: {},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
}; };
// Track enabled clients by session id // Track enabled clients by session id

View file

@ -11,6 +11,12 @@ const config = {
title: "Toggle Subscriber Updates", title: "Toggle Subscriber Updates",
description: "Toggles simulated resource subscription updates on or off.", description: "Toggles simulated resource subscription updates on or off.",
inputSchema: {}, inputSchema: {},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
}; };
// Track enabled clients by session id // Track enabled clients by session id

View file

@ -11,6 +11,12 @@ const config = {
"Demonstrates bidirectional MCP tasks where the server sends an elicitation request and " + "Demonstrates bidirectional MCP tasks where the server sends an elicitation request and " +
"the client handles user input asynchronously, allowing the server to poll for completion.", "the client handles user input asynchronously, allowing the server to poll for completion.",
inputSchema: {}, inputSchema: {},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
}; };
// Poll interval in milliseconds // Poll interval in milliseconds

View file

@ -10,6 +10,12 @@ const config = {
title: "Trigger Elicitation Request Tool", title: "Trigger Elicitation Request Tool",
description: "Trigger a Request from the Server for User Elicitation", description: "Trigger a Request from the Server for User Elicitation",
inputSchema: {}, inputSchema: {},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
}; };
/** /**

View file

@ -17,6 +17,12 @@ const config = {
title: "Trigger Long Running Operation Tool", title: "Trigger Long Running Operation Tool",
description: "Demonstrates a long running operation with progress updates.", description: "Demonstrates a long running operation with progress updates.",
inputSchema: TriggerLongRunningOperationSchema, inputSchema: TriggerLongRunningOperationSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
}; };
/** /**

View file

@ -23,6 +23,12 @@ const config = {
"Demonstrates bidirectional MCP tasks where the server sends a request and the client " + "Demonstrates bidirectional MCP tasks where the server sends a request and the client " +
"executes it asynchronously, allowing the server to poll for progress and results.", "executes it asynchronously, allowing the server to poll for progress and results.",
inputSchema: TriggerSamplingRequestAsyncSchema, inputSchema: TriggerSamplingRequestAsyncSchema,
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: true,
},
}; };
// Poll interval in milliseconds // Poll interval in milliseconds

View file

@ -21,6 +21,12 @@ const config = {
title: "Trigger Sampling Request Tool", title: "Trigger Sampling Request Tool",
description: "Trigger a Request from the Server for LLM Sampling", description: "Trigger a Request from the Server for LLM Sampling",
inputSchema: TriggerSamplingRequestSchema, inputSchema: TriggerSamplingRequestSchema,
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: true,
},
}; };
/** /**