feat: Replace usage of mcp_core Tools/ToolAnnotations in openapi schema (#3649)

This commit is contained in:
Alex Hancock
2025-07-25 10:21:59 -04:00
committed by GitHub
parent 1bccd2613f
commit 858d4062bc
3 changed files with 26 additions and 86 deletions
+8 -5
View File
@@ -11,9 +11,10 @@ use goose::permission::permission_confirmation::PrincipalType;
use goose::providers::base::{ConfigKey, ModelInfo, ProviderMetadata}; use goose::providers::base::{ConfigKey, ModelInfo, ProviderMetadata};
use goose::session::info::SessionInfo; use goose::session::info::SessionInfo;
use goose::session::SessionMetadata; use goose::session::SessionMetadata;
use mcp_core::tool::{Tool, ToolAnnotations}; use rmcp::model::{
use rmcp::model::ResourceContents; Annotations, Content, EmbeddedResource, ImageContent, ResourceContents, Role, TextContent,
use rmcp::model::{Annotations, Content, EmbeddedResource, ImageContent, Role, TextContent}; Tool, ToolAnnotations,
};
use utoipa::{OpenApi, ToSchema}; use utoipa::{OpenApi, ToSchema};
use rmcp::schemars::schema::{InstanceType, SchemaObject, SingleOrVec}; use rmcp::schemars::schema::{InstanceType, SchemaObject, SingleOrVec};
@@ -284,6 +285,8 @@ derive_utoipa!(Content as ContentSchema);
derive_utoipa!(EmbeddedResource as EmbeddedResourceSchema); derive_utoipa!(EmbeddedResource as EmbeddedResourceSchema);
derive_utoipa!(ImageContent as ImageContentSchema); derive_utoipa!(ImageContent as ImageContentSchema);
derive_utoipa!(TextContent as TextContentSchema); derive_utoipa!(TextContent as TextContentSchema);
derive_utoipa!(Tool as ToolSchema);
derive_utoipa!(ToolAnnotations as ToolAnnotationsSchema);
derive_utoipa!(Annotations as AnnotationsSchema); derive_utoipa!(Annotations as AnnotationsSchema);
derive_utoipa!(ResourceContents as ResourceContentsSchema); derive_utoipa!(ResourceContents as ResourceContentsSchema);
@@ -361,8 +364,8 @@ derive_utoipa!(ResourceContents as ResourceContentsSchema);
ExtensionConfig, ExtensionConfig,
ConfigKey, ConfigKey,
Envs, Envs,
Tool, ToolSchema,
ToolAnnotations, ToolAnnotationsSchema,
ToolInfo, ToolInfo,
PermissionLevel, PermissionLevel,
PrincipalType, PrincipalType,
+12 -23
View File
@@ -2881,11 +2881,9 @@
}, },
"Tool": { "Tool": {
"type": "object", "type": "object",
"description": "A tool that can be used by a model.",
"required": [ "required": [
"name", "inputSchema",
"description", "name"
"inputSchema"
], ],
"properties": { "properties": {
"annotations": { "annotations": {
@@ -2893,46 +2891,37 @@
{ {
"$ref": "#/components/schemas/ToolAnnotations" "$ref": "#/components/schemas/ToolAnnotations"
} }
], ]
"nullable": true
}, },
"description": { "description": {
"type": "string", "type": "string"
"description": "A description of what the tool does"
}, },
"inputSchema": { "inputSchema": {
"description": "A JSON Schema object defining the expected parameters for the tool" "type": "object",
"additionalProperties": true
}, },
"name": { "name": {
"type": "string", "type": "string"
"description": "The name of the tool"
} }
} }
}, },
"ToolAnnotations": { "ToolAnnotations": {
"type": "object", "type": "object",
"description": "Additional properties describing a tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**.\nThey are not guaranteed to provide a faithful description of\ntool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on ToolAnnotations\nreceived from untrusted servers.",
"properties": { "properties": {
"destructiveHint": { "destructiveHint": {
"type": "boolean", "type": "boolean"
"description": "If true, the tool may perform destructive updates to its environment.\nIf false, the tool performs only additive updates.\n\n(This property is meaningful only when `read_only_hint == false`)\n\nDefault: true"
}, },
"idempotentHint": { "idempotentHint": {
"type": "boolean", "type": "boolean"
"description": "If true, calling the tool repeatedly with the same arguments\nwill have no additional effect on its environment.\n\n(This property is meaningful only when `read_only_hint == false`)\n\nDefault: false"
}, },
"openWorldHint": { "openWorldHint": {
"type": "boolean", "type": "boolean"
"description": "If true, this tool may interact with an \"open world\" of external\nentities. If false, the tool's domain of interaction is closed.\nFor example, the world of a web search tool is open, whereas that\nof a memory tool is not.\n\nDefault: true"
}, },
"readOnlyHint": { "readOnlyHint": {
"type": "boolean", "type": "boolean"
"description": "If true, the tool does not modify its environment.\n\nDefault: false"
}, },
"title": { "title": {
"type": "string", "type": "string"
"description": "A human-readable title for the tool.",
"nullable": true
} }
} }
}, },
+6 -58
View File
@@ -666,73 +666,21 @@ export type ThinkingContent = {
thinking: string; thinking: string;
}; };
/**
* A tool that can be used by a model.
*/
export type Tool = { export type Tool = {
annotations?: ToolAnnotations | null; annotations?: ToolAnnotations;
/** description?: string;
* A description of what the tool does inputSchema: {
*/ [key: string]: unknown;
description: string; };
/**
* A JSON Schema object defining the expected parameters for the tool
*/
inputSchema: unknown;
/**
* The name of the tool
*/
name: string; name: string;
}; };
/**
* 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 type ToolAnnotations = { export type ToolAnnotations = {
/**
* 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 `read_only_hint == false`)
*
* Default: true
*/
destructiveHint?: boolean; destructiveHint?: boolean;
/**
* If true, calling the tool repeatedly with the same arguments
* will have no additional effect on its environment.
*
* (This property is meaningful only when `read_only_hint == false`)
*
* Default: false
*/
idempotentHint?: boolean; idempotentHint?: 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?: boolean; openWorldHint?: boolean;
/**
* If true, the tool does not modify its environment.
*
* Default: false
*/
readOnlyHint?: boolean; readOnlyHint?: boolean;
/** title?: string;
* A human-readable title for the tool.
*/
title?: string | null;
}; };
export type ToolConfirmationRequest = { export type ToolConfirmationRequest = {