Skip to main content
Glama

query

Execute blockchain data queries on the NIX system to retrieve blocks, transactions, account information, and network status across multiple blockchain networks using JSON parameters.

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

Implementation Reference

  • Primary MCP tool handler for the 'query' tool. Includes input schema via Pydantic Field validators, registration via @mcp.tool() decorator, and execution logic delegating to internal handle_query function.
    @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
  • Input schema definition for the 'query' tool using Pydantic Fields, specifying required action name, optional params dict, contract, and environment.
    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)")
  • Internal helper function containing the core query execution logic: invokes SimpleNixClient.query() with provided parameters and formats the response as TextContent for MCP.
    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)}" )]

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