Add ToolAnnotations support to McpServer.tool() method
This commit is contained in:
parent
f41769184d
commit
0096be432f
1 changed files with 338 additions and 16 deletions
61
src/types.ts
61
src/types.ts
|
|
@ -752,6 +752,62 @@ export const PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|||
});
|
||||
|
||||
/* Tools */
|
||||
/**
|
||||
* Additional properties describing a Tool to clients.
|
||||
*
|
||||
* NOTE: all properties in ToolAnnotations are **hints**.
|
||||
* They are not guaranteed to provide a faithful description of
|
||||
* tool behavior (including descriptive properties like `title`).
|
||||
*
|
||||
* Clients should never make tool use decisions based on ToolAnnotations
|
||||
* received from untrusted servers.
|
||||
*/
|
||||
export const ToolAnnotationsSchema = z
|
||||
.object({
|
||||
/**
|
||||
* A human-readable title for the tool.
|
||||
*/
|
||||
title: z.optional(z.string()),
|
||||
|
||||
/**
|
||||
* If true, the tool does not modify its environment.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
readOnlyHint: z.optional(z.boolean()),
|
||||
|
||||
/**
|
||||
* If true, the tool may perform destructive updates to its environment.
|
||||
* If false, the tool performs only additive updates.
|
||||
*
|
||||
* (This property is meaningful only when `readOnlyHint == false`)
|
||||
*
|
||||
* Default: true
|
||||
*/
|
||||
destructiveHint: z.optional(z.boolean()),
|
||||
|
||||
/**
|
||||
* If true, calling the tool repeatedly with the same arguments
|
||||
* will have no additional effect on the its environment.
|
||||
*
|
||||
* (This property is meaningful only when `readOnlyHint == false`)
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
idempotentHint: z.optional(z.boolean()),
|
||||
|
||||
/**
|
||||
* If true, this tool may interact with an "open world" of external
|
||||
* entities. If false, the tool's domain of interaction is closed.
|
||||
* For example, the world of a web search tool is open, whereas that
|
||||
* of a memory tool is not.
|
||||
*
|
||||
* Default: true
|
||||
*/
|
||||
openWorldHint: z.optional(z.boolean()),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
/**
|
||||
* Definition for a tool the client can call.
|
||||
*/
|
||||
|
|
@ -774,6 +830,10 @@ export const ToolSchema = z
|
|||
properties: z.optional(z.object({}).passthrough()),
|
||||
})
|
||||
.passthrough(),
|
||||
/**
|
||||
* Optional additional tool information.
|
||||
*/
|
||||
annotations: z.optional(ToolAnnotationsSchema),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
|
|
@ -1246,6 +1306,7 @@ export type GetPromptResult = Infer<typeof GetPromptResultSchema>;
|
|||
export type PromptListChangedNotification = Infer<typeof PromptListChangedNotificationSchema>;
|
||||
|
||||
/* Tools */
|
||||
export type ToolAnnotations = Infer<typeof ToolAnnotationsSchema>;
|
||||
export type Tool = Infer<typeof ToolSchema>;
|
||||
export type ListToolsRequest = Infer<typeof ListToolsRequestSchema>;
|
||||
export type ListToolsResult = Infer<typeof ListToolsResultSchema>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue