@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/dist/http.d.ts +9 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +116 -13
- package/dist/http.js.map +1 -1
- package/dist/protocol.d.ts +22 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +106 -22
- package/dist/protocol.js.map +1 -1
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -1
- package/dist/tool.d.ts +4 -1
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +1 -0
- package/dist/tool.js.map +1 -1
- package/package.json +1 -1
- package/src/http.ts +133 -12
- package/src/protocol.ts +166 -42
- package/src/server.ts +7 -0
- package/src/tool.ts +11 -1
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 {
|
|
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>
|