Skip to main content
Glama

query

Execute blockchain data queries through the NIX MCP Server to retrieve blocks, transactions, account information, and network status across multiple blockchain networks.

Instructions

Execute a NIX query with JSON parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesQuery action name
paramsNoJSON parameters for the query
contractNoContract namenix.q
environmentNoEnvironment (dev, uat, cdev, perf, simnext, prod, local)dev

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool registration, input schema, and handler for the 'query' tool. Validates parameters and executes via handle_query.
    @mcp.tool()
    async def query(
        action: str = Field(..., description="Query action name"),
        params: Optional[Dict[str, Any]] = Field(default=None, description="JSON parameters for the query"),
        contract: str = Field(default="nix.q", description="Contract name"),
        environment: str = Field(default="dev", description="Environment (dev, uat, cdev, perf, simnext, prod, local)")
    ) -> str:
        """Execute a NIX query with JSON parameters"""
        # Create client with specified environment
        client = SimpleNixClient(environment=environment)
        result = await handle_query(client, action, params, contract, environment)
        return result[0].text
  • Core helper function implementing the query execution logic using SimpleNixClient.query(), handling JSON/text responses and errors.
    async def handle_query(
        client: SimpleNixClient,
        action: str,
        params: Optional[Dict[str, Any]] = None,
        contract: str = "nix.q",
        environment: str = "dev"
    ) -> List[TextContent]:
        """
        Execute a NIX query with JSON parameters
        
        Args:
            client: SimpleNixClient instance
            action: Query action name
            params: JSON parameters for the query
            contract: Contract name (default: nix.q)
            environment: Environment name
        
        Returns:
            List containing TextContent with query result
        """
        try:
            # Execute the query
            result = await client.query(
                contract=contract,
                action=action,
                params=params or {}
            )
            
            # Handle both JSON and raw text responses
            if isinstance(result, dict):
                # Add environment info to result if it's a dict
                result["environment"] = environment
                return [TextContent(
                    type="text",
                    text=json.dumps(result, indent=2)
                )]
            else:
                # Return raw text response
                return [TextContent(
                    type="text",
                    text=str(result)
                )]
        except Exception as e:
            logger.error(f"Error executing query: {e}")
            return [TextContent(
                type="text",
                text=f"Error: {str(e)}"
            )]
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions execution with JSON parameters but doesn't describe what the tool does behaviorally—whether it's read-only or mutative, what permissions are needed, what happens on success/failure, or any rate limits. This leaves significant gaps for a tool that appears to execute queries.

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 that directly states the tool's function without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 has an output schema (which reduces the need to describe return values) and 100% schema coverage, the description is somewhat complete. However, for a query execution tool with no annotations, it lacks critical behavioral context like safety, permissions, or error handling, making it minimally adequate but with clear gaps.

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 schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond implying JSON parameters are used, which is already covered in the schema. This meets the baseline for high schema coverage without adding value.

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

Purpose3/5

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

The description states the tool 'Execute[s] a NIX query with JSON parameters', which provides a basic verb+resource combination. However, it doesn't specify what a 'NIX query' is or how it differs from the sibling tools 'get_query_abi' and 'list_queries', leaving the purpose somewhat vague and undifferentiated.

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 the sibling tools 'get_query_abi' or 'list_queries'. There's no mention of prerequisites, alternatives, or specific contexts for execution, leaving the agent with no usage direction beyond the basic purpose.

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