get_query_abi
Retrieve the ABI structure and JSON template for specific blockchain queries to understand required parameters and data formats.
Instructions
Get ABI structure and JSON template for a specific query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query_name | Yes | Name of the query action | |
| contract | No | Contract name | nix.q |
| include_example | No | Include JSON example | |
| environment | No | Environment (dev, uat, cdev, perf, simnext, prod, local) | dev |
Implementation Reference
- src/nix_mcp/tools.py:61-113 (handler)Core handler function that executes the tool logic: fetches the action schema using ABIFetcher, constructs the result dictionary, and returns it as TextContent.async def handle_get_query_abi( client: SimpleNixClient, query_name: str, contract: str = "nix.q", include_example: bool = True, environment: str = "dev" ) -> List[TextContent]: """ Get ABI structure and JSON template for a specific query Args: client: SimpleNixClient instance query_name: Name of the query action contract: Contract name (default: nix.q) include_example: Include JSON example based on common patterns environment: Environment name Returns: List containing TextContent with query ABI and example """ try: fetcher = ABIFetcher(nodeos_api=client.nodeos_api, environment=environment) # Get complete resolved schema using the new resolver action_info = fetcher.get_action_schema(contract, query_name) if not action_info: raise ValueError(f"Query '{query_name}' not found in contract '{contract}'") result = { "query": query_name, "contract": contract, "environment": environment, "action_type": action_info.get("type", "unknown"), "template": action_info.get("template", {}), "schema": action_info.get("schema", {}), "description": action_info.get("description", "") } # Add example if requested if include_example: result["example"] = action_info.get("example", {}) return [TextContent( type="text", text=json.dumps(result, indent=2) )] except Exception as e: logger.error(f"Error getting query ABI: {e}") return [TextContent( type="text", text=f"Error: {str(e)}" )]
- src/nix_mcp/server_fastmcp.py:75-86 (registration)Registers the 'get_query_abi' tool with FastMCP decorator, defines input schema using Pydantic Field descriptions, creates a client, calls the core handler, and returns the result.@mcp.tool() async def get_query_abi( query_name: str = Field(..., description="Name of the query action"), contract: str = Field(default="nix.q", description="Contract name"), include_example: bool = Field(default=True, description="Include JSON example"), environment: str = Field(default="dev", description="Environment (dev, uat, cdev, perf, simnext, prod, local)") ) -> str: """Get ABI structure and JSON template for a specific query""" # Create client with specified environment client = SimpleNixClient(environment=environment) result = await handle_get_query_abi(client, query_name, contract, include_example, environment) return result[0].text
- src/nix_mcp/server_fastmcp.py:76-86 (schema)Input schema definition via Pydantic Fields for the tool parameters.async def get_query_abi( query_name: str = Field(..., description="Name of the query action"), contract: str = Field(default="nix.q", description="Contract name"), include_example: bool = Field(default=True, description="Include JSON example"), environment: str = Field(default="dev", description="Environment (dev, uat, cdev, perf, simnext, prod, local)") ) -> str: """Get ABI structure and JSON template for a specific query""" # Create client with specified environment client = SimpleNixClient(environment=environment) result = await handle_get_query_abi(client, query_name, contract, include_example, environment) return result[0].text