Skip to main content
Glama

get_query_abi

Retrieve the ABI structure and JSON template for blockchain queries to understand required parameters and data formats for interacting with smart contracts.

Instructions

Get ABI structure and JSON template for a specific query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
query_nameYesName of the query action
contractNoContract namenix.q
include_exampleNoInclude JSON example
environmentNoEnvironment (dev, uat, cdev, perf, simnext, prod, local)dev

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the core logic for fetching the ABI schema of a specific query using ABIFetcher.get_action_schema and formatting the result as JSON.
    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)}"
            )]
  • Registers the 'get_query_abi' tool with FastMCP using @mcp.tool(), defines input parameters with Pydantic Field validation and descriptions (serving as schema), creates a client, calls the 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
  • The Pydantic Field definitions in the tool function signature provide input schema validation, descriptions, defaults, and required fields for the get_query_abi tool.
    @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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves information ('Get'), implying a read-only operation, but doesn't disclose other traits like authentication needs, rate limits, error handling, or what the output contains beyond 'ABI structure and JSON template.' For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Get ABI structure and JSON template for a specific query.' It is front-loaded with the core purpose, has zero wasted words, and is appropriately sized for the tool's complexity. Every part of the sentence earns its place by conveying essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 parameters, 1 required), 100% schema coverage, and the presence of an output schema, the description is minimally adequate. It covers the purpose but lacks usage guidelines and behavioral details. The output schema likely explains return values, so the description doesn't need to detail them, but overall completeness is limited to the basic function.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already documents all parameters (query_name, contract, include_example, environment) with details like defaults and allowed values. The description adds no additional meaning beyond what the schema provides, such as explaining parameter interactions or usage examples. With high schema coverage, the baseline is 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get ABI structure and JSON template for a specific query.' It specifies the verb ('Get') and resource ('ABI structure and JSON template'), distinguishing it from sibling tools like 'list_queries' (which lists queries) and 'query' (which likely executes queries). However, it doesn't explicitly differentiate from siblings beyond the inherent action, so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, compare to sibling tools like 'list_queries' or 'query', or specify scenarios where this tool is appropriate. Usage is implied by the purpose but lacks explicit context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/haiqiubullish/nix-mcp'

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