@nifrajs/mcp 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tool.ts CHANGED
@@ -7,7 +7,13 @@
7
7
  * `tools/call` result, so the host knows to render the widget - see {@link ../protocol.ts}.
8
8
  */
9
9
 
10
- import type { McpContentBlock, McpTool, McpToolContext, McpToolResult } from "./protocol.ts"
10
+ import type {
11
+ McpContentBlock,
12
+ McpTool,
13
+ McpToolAnnotations,
14
+ McpToolContext,
15
+ McpToolResult,
16
+ } from "./protocol.ts"
11
17
  import type { InferOutput, StandardSchemaV1 } from "./standard.ts"
12
18
  import { formatIssues, jsonSchemaOf } from "./standard.ts"
13
19
  import type { McpWidget } from "./widget.ts"
@@ -61,6 +67,9 @@ export interface DefineMcpToolOptions<S extends StandardSchemaV1 = UntypedArgs>
61
67
  * whose schemas carry no JSON Schema, so the agent still sees real parameter docs.
62
68
  */
63
69
  readonly inputSchema?: Record<string, unknown>
70
+ /** MCP tool safety hints (`readOnlyHint`/`destructiveHint`/…) surfaced in `tools/list`. Hosts use
71
+ * them to decide confirmation UX, and connector directory reviews expect every tool to carry them. */
72
+ readonly annotations?: McpToolAnnotations
64
73
  /** Link a widget so the tool's result renders as interactive UI in MCP Apps hosts (iframe). */
65
74
  readonly widget?: McpWidget
66
75
  /** Render-intent for generative hosts that build their own themed UI from `structuredContent`. Lands
@@ -115,6 +124,7 @@ export function defineMcpTool<S extends StandardSchemaV1 = UntypedArgs>(
115
124
  opts.inputSchema ??
116
125
  (input !== undefined ? jsonSchemaOf(input) : undefined) ??
117
126
  EMPTY_OBJECT_SCHEMA,
127
+ ...(opts.annotations !== undefined ? { annotations: opts.annotations } : {}),
118
128
  ...(meta !== undefined ? { _meta: meta } : {}),
119
129
  handler: async (args, context) => {
120
130
  let validated = args as InferOutput<S>