meta_mcp.utils#

Classes#

SchemaReasoningOutput

Output model for schema reasoning.

Functions#

load_config(→ dict)

Load MCP configuration from a JSON file.

to_message(content[, role, content_type])

Create a message dictionary for LLM API calls.

get_structured_response_litellm(→ pydantic.BaseModel)

Get a structured response from LiteLLM using JSON schema validation.

structured_response_to_output_model(→ pydantic.BaseModel)

Convert a LiteLLM Response to a Pydantic model instance.

load_json_from_url(url_or_path[, timeout])

Download and parse a JSON file from URL or load from file path.

fix_schema(→ dict)

Recursively fix arrays with prefixItems but no items by converting prefixItems to items.

registry_json_to_df(→ pandas.DataFrame)

Convert registry JSON (list of dicts) to a pandas DataFrame.

Module Contents#

meta_mcp.utils.load_config(mcp_json_path: str) dict#

Load MCP configuration from a JSON file.

Parameters:

mcp_json_path (str) – Path to the MCP configuration JSON file.

Returns:

MCP configuration data.

Return type:

dict

meta_mcp.utils.to_message(content: str, role: str = 'user', content_type: str = 'input_text')#

Create a message dictionary for LLM API calls.

Parameters:
  • content (str) – The message content text.

  • role (str) – The role of the message sender (default: “user”).

  • content_type (str) – The type of content (default: “input_text”).

Returns:

Message payload for LLM API calls.

Return type:

dict

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:

object

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:
  • response (object) – LiteLLM response object containing the structured output.

  • output_model (type) – Pydantic model class to instantiate.

Returns:

Instance of the output_model populated with data from the response.

Return type:

object

Raises:

ValueError – If the response is invalid or cannot be parsed into the model:

class meta_mcp.utils.SchemaReasoningOutput(/, **data: Any)#

Bases: pydantic.BaseModel

Output model for schema reasoning.

biocontextai_schema_reasoning: Annotated[str, Field(description='Any reasoning that might help to arrive at an answer that matches the given schema.')]#
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.

Parameters:
  • url_or_path (str) – URL to download JSON from or local file path.

  • timeout (float) – Timeout in seconds for URL requests (default: 10.0).

Returns:

Parsed JSON data.

Return type:

dict

meta_mcp.utils.fix_schema(schema: dict) dict#

Recursively fix arrays with prefixItems but no items by converting prefixItems to items.

meta_mcp.utils.registry_json_to_df(registry_json: list[dict]) pandas.DataFrame#

Convert registry JSON (list of dicts) to a pandas DataFrame.

Collects all possible columns from all elements, handling missing keys. Nested JSON structures are converted to JSON strings.

Parameters:

registry_json (list[dict]) – List of dictionaries representing registry entries.

Returns:

DataFrame with all columns from all registry entries.

Return type:

pd.DataFrame