nat.plugins.fastmcp.server.tool_converter#
Convert NeMo Agent Toolkit functions to FastMCP tools.
Attributes#
Functions#
|
Return a JSON schema for Pydantic models or dict-like schemas. |
|
Return field default or a sentinel to skip default. |
|
Build a function signature from a Pydantic schema if possible. |
|
Return an input schema for tool registration. |
|
Build function annotations from a Pydantic schema if possible. |
|
Return True when the schema represents a ChatRequest. |
|
Create a wrapper function for MCP that invokes the workflow via |
|
Retrieve a human-readable description for a NAT function or workflow. |
|
Register a NeMo Agent Toolkit function as a FastMCP tool. |
|
Return a pretty JSON schema string for debug endpoints. |
Module Contents#
- logger#
- _USE_PYDANTIC_DEFAULT#
- _safe_json_schema(schema: Any) dict[str, Any]#
Return a JSON schema for Pydantic models or dict-like schemas.
- _get_field_default(field_info: pydantic.fields.FieldInfo) Any#
Return field default or a sentinel to skip default.
- _build_signature_from_schema(schema: Any) inspect.Signature#
Build a function signature from a Pydantic schema if possible.
- _build_input_schema(schema: Any) Any#
Return an input schema for tool registration.
- _build_annotations_from_schema(schema: Any) dict[str, Any]#
Build function annotations from a Pydantic schema if possible.
- create_function_wrapper(
- function_name: str,
- session_manager: nat.runtime.session.SessionManager,
- input_schema: Any,
Create a wrapper function for MCP that invokes the workflow via
SessionManager.- Args:
function_name: The name of the function to register. session_manager: The session manager for the workflow. input_schema: Input schema for the workflow/function.
- get_function_description(
- function: nat.builder.function_base.FunctionBase | None,
Retrieve a human-readable description for a NAT function or workflow.
- register_function_with_mcp(
- mcp: fastmcp.FastMCP,
- function_name: str,
- session_manager: nat.runtime.session.SessionManager,
- function: nat.builder.function_base.FunctionBase | None = None,
Register a NeMo Agent Toolkit function as a FastMCP tool.
Each function is wrapped in a
SessionManagerso that all calls go through the runner, which automatically handles observability.- Args:
mcp: The FastMCP instance. function_name: The name to register the function under. session_manager: SessionManager wrapping the function/workflow. function: Optional function metadata (for description/schema).