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

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

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