meta_mcp.utils#
Classes#
Output model for schema reasoning. |
Functions#
|
Load MCP configuration from a JSON file. |
|
Create a message dictionary for LLM API calls. |
|
Get a structured response from LiteLLM using JSON schema validation. |
|
Convert a LiteLLM Response to a Pydantic model instance. |
|
Download and parse a JSON file from URL or load from file path. |
|
Recursively fix arrays with prefixItems but no items by converting prefixItems to items. |
|
Convert registry JSON (list of dicts) to a pandas DataFrame. |
Module Contents#
- meta_mcp.utils.to_message(content: str, role: str = 'user', content_type: str = 'input_text')#
Create a message dictionary for LLM API calls.
- meta_mcp.utils.get_structured_response_litellm(input: str, system_prompt: str, output_model: type[pydantic.BaseModel], model: str = 'openai/gpt-5-nano', temperature: float = 1.0) pydantic.BaseModel#
Get a structured response from LiteLLM using JSON schema validation.
- Parameters:
input (str) – The user input text.
system_prompt (str) – The system prompt to guide the model.
output_model (type) – Pydantic model class defining the expected output schema.
model (str) – The model name to use (default: “openai/gpt-5-nano”).
temperature (float) – Sampling temperature (default: 1.0).
- Returns:
LiteLLM response object containing the structured output.
- Return type:
- Raises:
RuntimeError – If the LLM call fails:
- meta_mcp.utils.structured_response_to_output_model(response: litellm.Response, output_model: type[pydantic.BaseModel]) pydantic.BaseModel#
Convert a LiteLLM Response to a Pydantic model instance.
- Parameters:
- Returns:
Instance of the output_model populated with data from the response.
- Return type:
- Raises:
ValueError – If the response is invalid or cannot be parsed into the model:
- class meta_mcp.utils.SchemaReasoningOutput(/, **data: Any)#
Bases:
pydantic.BaseModelOutput model for schema reasoning.
- meta_mcp.utils.load_json_from_url(url_or_path: str, timeout: float = 10.0)#
Download and parse a JSON file from URL or load from file path.
- meta_mcp.utils.fix_schema(schema: dict) dict#
Recursively fix arrays with prefixItems but no items by converting prefixItems to items.