aiq.front_ends.mcp.tool_converter#

Attributes#

Functions#

create_function_wrapper(function_name, function, schema)

Create a wrapper function that exposes the actual parameters of an AIQ Function as an MCP tool.

get_function_description(→ str)

Retrieve a human-readable description for an AIQ function or workflow.

register_function_with_mcp(→ None)

Register an AIQ Function as an MCP tool.

Module Contents#

logger#
create_function_wrapper(
function_name: str,
function: aiq.builder.function_base.FunctionBase,
schema: type[pydantic.BaseModel],
is_workflow: bool = False,
)#

Create a wrapper function that exposes the actual parameters of an AIQ Function as an MCP tool.

Args:

function_name: The name of the function/tool function: The AIQ Function object schema: The input schema of the function is_workflow: Whether the function is a Workflow

Returns:

A wrapper function suitable for registration with MCP

get_function_description(
function: aiq.builder.function_base.FunctionBase,
) str#

Retrieve a human-readable description for an AIQ function or workflow.

The description is determined using the following precedence:
  1. If the function is a Workflow and has a ‘description’ attribute, use it.

  2. If the Workflow’s config has a ‘topic’, use it.

  3. If the Workflow’s config has a ‘description’, use it.

  4. If the function is a regular Function, use its ‘description’ attribute.

Args:

function: The AIQ FunctionBase instance (Function or Workflow).

Returns:

The best available description string for the function.

register_function_with_mcp(
mcp: mcp.server.fastmcp.FastMCP,
function_name: str,
function: aiq.builder.function_base.FunctionBase,
) None#

Register an AIQ Function as an MCP tool.

Args:

mcp: The FastMCP instance function_name: The name to register the function under function: The AIQ Function to register