Skip to main content
Glama

get_model_variables

Retrieve currently bound variables and their individual IDs for a GO-CAM model to understand available model context after batch operations.

Instructions

Get the currently bound variables for a GO-CAM model.

Returns a mapping of variable names to their actual individual IDs. This is useful for understanding what variables are available in the current model context, especially after batch operations.

Args: model_id: The GO-CAM model identifier

Returns: Dictionary with variable mappings and model information

Examples: # Get variables after creating individuals vars = get_model_variables("gomodel:12345") # Returns: # { # "model_id": "gomodel:12345", # "variables": { # "mf1": "gomodel:12345/68dee4d300000481", # "gp1": "gomodel:12345/68dee4d300000482", # "cc1": "gomodel:12345/68dee4d300000483" # }, # "individual_count": 3 # }

# Use the variables in subsequent operations vars = get_model_variables("gomodel:12345") mf_id = vars["variables"]["mf1"] add_fact("gomodel:12345", mf_id, vars["variables"]["gp1"], "RO:0002333")

Notes: - Variables are only valid within the same batch operation - This tool helps identify actual IDs for cross-batch operations - If the model has no tracked variables, returns empty dict

Input Schema

NameRequiredDescriptionDefault
model_idYes

Input Schema (JSON Schema)

{ "properties": { "model_id": { "type": "string" } }, "required": [ "model_id" ], "type": "object" }

Implementation Reference

  • The handler function for the 'get_model_variables' MCP tool. It fetches the currently bound variables (variable name to individual ID mappings) for a given GO-CAM model using the BaristaClient, enabling reference to model elements across operations.
    @mcp.tool() async def get_model_variables(model_id: str) -> Dict[str, Any]: """ Get the currently bound variables for a GO-CAM model. Returns a mapping of variable names to their actual individual IDs. This is useful for understanding what variables are available in the current model context, especially after batch operations. Args: model_id: The GO-CAM model identifier Returns: Dictionary with variable mappings and model information Examples: # Get variables after creating individuals vars = get_model_variables("gomodel:12345") # Returns: # { # "model_id": "gomodel:12345", # "variables": { # "mf1": "gomodel:12345/68dee4d300000481", # "gp1": "gomodel:12345/68dee4d300000482", # "cc1": "gomodel:12345/68dee4d300000483" # }, # "individual_count": 3 # } # Use the variables in subsequent operations vars = get_model_variables("gomodel:12345") mf_id = vars["variables"]["mf1"] add_fact("gomodel:12345", mf_id, vars["variables"]["gp1"], "RO:0002333") Notes: - Variables are only valid within the same batch operation - This tool helps identify actual IDs for cross-batch operations - If the model has no tracked variables, returns empty dict """ client = get_client() # Check if the client has variable tracking enabled if not hasattr(client, 'track_variables') or not client.track_variables: client.track_variables = True # Get the model to see current state resp = client.get_model(model_id) if resp.error: return { "success": False, "error": resp.error, "model_id": model_id } # Get variables from the client's registry variables = {} if hasattr(client, '_variable_registry') and client._variable_registry: # The registry is keyed by (model_id, variable_name) -> actual_id # We need to extract variables for this specific model variables = client.get_variables(model_id) # Also check if the last response has model_vars if hasattr(resp, 'model_vars') and resp.model_vars: variables.update(resp.model_vars) # Count individuals individual_count = len(resp.individuals) if resp.individuals else 0 return { "success": True, "model_id": model_id, "variables": variables, "individual_count": individual_count, }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/geneontology/noctua-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server