nat.plugins.mcp.client.fastapi_routes#

FastAPI routes for MCP client tool listing.

Attributes#

Classes#

MCPToolInfo

Information about a single MCP tool.

MCPClientToolListResponse

Response model for the MCP client tool list endpoint.

Functions#

_collect_mcp_client_tool_list(→ list[dict[str, Any]])

Collect MCP client tool information from all function groups.

add_mcp_client_tool_list_route(→ None)

Add MCP client tool list endpoints to the FastAPI app.

Module Contents#

logger#
class MCPToolInfo(/, **data: Any)#

Bases: pydantic.BaseModel

Information about a single MCP tool.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

name: str#
description: str#
server: str#
available: bool#
class MCPClientToolListResponse(/, **data: Any)#

Bases: pydantic.BaseModel

Response model for the MCP client tool list endpoint.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

mcp_clients: list[dict[str, Any]]#
async _collect_mcp_client_tool_list(
function_groups: dict[str, nat.builder.function.FunctionGroup],
) list[dict[str, Any]]#

Collect MCP client tool information from all function groups.

Iterates over function groups, identifies MCP client groups, checks session health, and builds a list of tool information including availability status.

async add_mcp_client_tool_list_route(
app: fastapi.FastAPI,
builder: nat.builder.workflow_builder.WorkflowBuilder,
session_managers: list[nat.runtime.session.SessionManager],
) None#

Add MCP client tool list endpoints to the FastAPI app.

Registers two GET routes: - /mcp/client/tool/list for shared workflows. - /mcp/client/tool/list/per_user for per-user workflows.