Add tool requirements to MCPTool meta field (#612)
Enables MCP Clients to discover requirements of a tool.
This commit is contained in:
parent
20ea8cbddd
commit
b5c68baa05
3 changed files with 14 additions and 1 deletions
|
|
@ -68,6 +68,11 @@ def create_mcp_tool(tool: MaterializedTool) -> MCPTool | None:
|
|||
openWorldHint=requirements.authorization is not None,
|
||||
)
|
||||
|
||||
# Build meta with requirements if any exist
|
||||
meta = None
|
||||
if requirements.authorization or requirements.secrets or requirements.metadata:
|
||||
meta = {"requirements": requirements.model_dump()}
|
||||
|
||||
# Instantiate MCPTool model to ensure shape correctness
|
||||
return MCPTool(
|
||||
name=name,
|
||||
|
|
@ -76,6 +81,7 @@ def create_mcp_tool(tool: MaterializedTool) -> MCPTool | None:
|
|||
inputSchema=input_schema,
|
||||
outputSchema=output_schema if output_schema else None,
|
||||
annotations=annotations,
|
||||
_meta=meta,
|
||||
)
|
||||
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -36,11 +36,18 @@ class ToolManager(ComponentManager[Key, ManagedTool]):
|
|||
return name.replace(".", "_")
|
||||
|
||||
def _to_dto(self, tool: MaterializedTool) -> MCPTool:
|
||||
# Extract requirements and build meta if needed
|
||||
requirements = tool.definition.requirements
|
||||
meta = None
|
||||
if requirements.authorization or requirements.secrets or requirements.metadata:
|
||||
meta = {"requirements": requirements.model_dump()}
|
||||
|
||||
return MCPTool(
|
||||
name=self._sanitize_name(tool.definition.fully_qualified_name),
|
||||
title=f"{tool.definition.toolkit.name}_{tool.definition.name}",
|
||||
description=tool.definition.description,
|
||||
inputSchema=build_input_schema_from_definition(tool.definition),
|
||||
_meta=meta,
|
||||
)
|
||||
|
||||
async def load_from_catalog(self, catalog: ToolCatalog) -> None:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||
|
||||
[project]
|
||||
name = "arcade-mcp-server"
|
||||
version = "1.1.1"
|
||||
version = "1.2.0"
|
||||
description = "Model Context Protocol (MCP) server framework for Arcade.dev"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "Arcade.dev" }]
|
||||
|
|
|
|||
Loading…
Reference in a new issue