Skip to main content
Glama
allthatjazzleo

MantraChain MCP Server

query-network

Execute custom network queries against chain APIs using gRPC Gateway when standard tools fail. Verify available queries via OpenAPI specification before sending requests with specified HTTP methods, paths, and parameters.

Instructions

Execute a generic network gRPC Gateway query against chain APIs when you cannot find the required information from other tools. You MUST first check the available query/service by reading the openapi specification from the resource openapi://{networkName} to understand available query/service, methods, required parameters and body structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNoRequest body for POST/PUT requests
methodYesHTTP method to use for the request
networkNameYesName of the network to use - must first check what networks are available through the mantrachain-mcp server by accessing the networks resource `networks://all` before you pass this arguments
pathYesAPI endpoint path from the OpenAPI spec, e.g., '/cosmos/bank/v1beta1/balances/{address}'
pathParamsNoPath parameters to substitute in the URL path
queryParamsNoQuery parameters to add to the request

Implementation Reference

  • Handler function that executes the 'query-network' tool logic: initializes the Mantra client, builds the gRPC Gateway API URL with path/query parameters, performs an HTTP fetch request, and returns the JSON response.
    async ({ networkName, path, method, pathParams, queryParams, body }) => {
      try {
        await mantraClient.initialize(networkName);
        
        // Build the URL with path parameters
        let url = networks[networkName].apiEndpoint;
        
        // Remove trailing slash from base URL if present
        if (url.endsWith('/')) {
          url = url.slice(0, -1);
        }
        
        // Add path (substitute path parameters if provided)
        if (pathParams) {
          let substitutedPath = path;
          Object.entries(pathParams).forEach(([key, value]) => {
            substitutedPath = substitutedPath.replace(`{${key}}`, encodeURIComponent(String(value)));
          });
          url += substitutedPath;
        } else {
          url += path;
        }
        
        // Add query parameters
        if (queryParams && Object.keys(queryParams).length > 0) {
          const params = new URLSearchParams();
          Object.entries(queryParams).forEach(([key, value]) => {
            params.append(key, String(value));
          });
          url += `?${params.toString()}`;
        }
        
        // Execute request
        const response = await fetch(url, {
          method,
          headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
          },
          body: body ? JSON.stringify(body) : undefined,
        });
        
        const data = await response.json();
        
        return {
          content: [
            {type: "text", text: JSON.stringify(data)}
          ],
        };
      } catch (error) {
        throw new Error(`Failed to execute network query: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Zod input schema defining parameters for the 'query-network' tool: networkName, path, method, pathParams, queryParams, body.
    {
      networkName: z.string().refine(val => Object.keys(networks).includes(val), {
        message: "Must be a valid network name"
      }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."),
      path: z.string().describe("API endpoint path from the OpenAPI spec, e.g., '/cosmos/bank/v1beta1/balances/{address}'"),
      method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method to use for the request"),
      pathParams: z.record(z.string()).optional().describe("Path parameters to substitute in the URL path"),
      queryParams: z.record(z.string()).optional().describe("Query parameters to add to the request"),
      body: z.any().optional().describe("Request body for POST/PUT requests"),
    },
  • Registration of the 'query-network' MCP tool using server.tool(), including description, input schema, and handler function.
    server.tool(
      "query-network",
      "Execute a generic network gRPC Gateway query against chain APIs when you cannot find the required information from other tools. You MUST first check the available query/service by reading the openapi specification from the resource `openapi://{networkName}` to understand available query/service, methods, required parameters and body structure.",
      {
        networkName: z.string().refine(val => Object.keys(networks).includes(val), {
          message: "Must be a valid network name"
        }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."),
        path: z.string().describe("API endpoint path from the OpenAPI spec, e.g., '/cosmos/bank/v1beta1/balances/{address}'"),
        method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method to use for the request"),
        pathParams: z.record(z.string()).optional().describe("Path parameters to substitute in the URL path"),
        queryParams: z.record(z.string()).optional().describe("Query parameters to add to the request"),
        body: z.any().optional().describe("Request body for POST/PUT requests"),
      },
      async ({ networkName, path, method, pathParams, queryParams, body }) => {
        try {
          await mantraClient.initialize(networkName);
          
          // Build the URL with path parameters
          let url = networks[networkName].apiEndpoint;
          
          // Remove trailing slash from base URL if present
          if (url.endsWith('/')) {
            url = url.slice(0, -1);
          }
          
          // Add path (substitute path parameters if provided)
          if (pathParams) {
            let substitutedPath = path;
            Object.entries(pathParams).forEach(([key, value]) => {
              substitutedPath = substitutedPath.replace(`{${key}}`, encodeURIComponent(String(value)));
            });
            url += substitutedPath;
          } else {
            url += path;
          }
          
          // Add query parameters
          if (queryParams && Object.keys(queryParams).length > 0) {
            const params = new URLSearchParams();
            Object.entries(queryParams).forEach(([key, value]) => {
              params.append(key, String(value));
            });
            url += `?${params.toString()}`;
          }
          
          // Execute request
          const response = await fetch(url, {
            method,
            headers: {
              'Content-Type': 'application/json',
              'Accept': 'application/json',
            },
            body: body ? JSON.stringify(body) : undefined,
          });
          
          const data = await response.json();
          
          return {
            content: [
              {type: "text", text: JSON.stringify(data)}
            ],
          };
        } catch (error) {
          throw new Error(`Failed to execute network query: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );
Behavior3/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. It discloses that this is a generic query execution tool requiring pre-checks of OpenAPI specs and network availability, which adds useful behavioral context. However, it doesn't mention error handling, rate limits, authentication needs, or response formats, leaving gaps for a tool with 6 parameters.

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

Conciseness4/5

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

The description is appropriately sized with two sentences that are front-loaded: the first states the purpose and usage condition, the second provides prerequisites. Every sentence adds value, though it could be slightly more streamlined by integrating the prerequisites more seamlessly.

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 complexity (6 parameters, no output schema, no annotations), the description is partially complete. It covers usage context and prerequisites well but lacks details on behavioral traits like error handling or response structure. For a generic query tool with many siblings, more guidance on typical use cases would enhance completeness.

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?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds minimal parameter semantics beyond the schema, only implying that 'networkName' and 'path' relate to OpenAPI specs. It doesn't explain how parameters interact or provide examples, meeting the baseline for high schema coverage.

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: 'Execute a generic network gRPC Gateway query against chain APIs.' It specifies the action (execute query) and target (chain APIs via gRPC Gateway). However, it doesn't explicitly differentiate from sibling tools like 'contract-query' or 'get-balance' beyond being a fallback option.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'when you cannot find the required information from other tools.' It instructs to first check available queries via the OpenAPI spec and networks via the networks resource, establishing clear prerequisites and when to use this tool versus alternatives.

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

Related 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/allthatjazzleo/mantrachain-mcp'

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