Skip to main content
Glama
CodaLabs-xyz

X402 MCP Template

by CodaLabs-xyz

service_info

Retrieve X402 API service details including endpoints, pricing, and payment requirements to understand available functionality and costs.

Instructions

Get information about the X402 API service including available endpoints, pricing, and payment requirements

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler for the 'service_info' tool. Fetches X402 service discovery metadata from the /.well-known/x402 endpoint using axios, falls back to basic connection info if unavailable, and returns formatted JSON response.
    case "service_info": {
      // Fetch service discovery metadata from /.well-known/x402
      try {
        const response = await axios.get(`${baseURL}/.well-known/x402`);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  service_discovery: true,
                  ...response.data,
                  connection_info: {
                    base_url: baseURL,
                    payment_enabled: paymentEnabled,
                    network: network,
                  },
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error: any) {
        // If service discovery not available, return basic info
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  service_discovery: false,
                  message: "Service discovery endpoint not available",
                  connection_info: {
                    base_url: baseURL,
                    payment_enabled: paymentEnabled,
                    network: network,
                  },
                  note: "API may not support X402 protocol or /.well-known/x402 endpoint",
                },
                null,
                2
              ),
            },
          ],
        };
      }
    }
  • Tool schema definition for 'service_info', including name, description, and empty input schema (no parameters required). This is part of the tools list returned by listTools.
    {
      name: "service_info",
      description: "Get information about the X402 API service including available endpoints, pricing, and payment requirements",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • index.ts:106-148 (registration)
    Registration of the 'service_info' tool via the listTools handler, which returns the list of available tools including their schemas.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "example_api_call",
            description: "Example tool for making X402-protected API calls. Replace with your actual API endpoints.",
            inputSchema: {
              type: "object",
              properties: {
                query: {
                  type: "string",
                  description: "Example query parameter - customize for your API",
                },
                limit: {
                  type: "number",
                  description: "Optional: Maximum number of results to return",
                  minimum: 1,
                  maximum: 100,
                  default: 10,
                },
              },
              required: ["query"],
            },
          },
          {
            name: "service_info",
            description: "Get information about the X402 API service including available endpoints, pricing, and payment requirements",
            inputSchema: {
              type: "object",
              properties: {},
            },
          },
          {
            name: "health_check",
            description: "Check if the X402 API service is available and responding",
            inputSchema: {
              type: "object",
              properties: {},
            },
          },
        ],
      };
    });
Behavior3/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 implies a read-only operation ('Get information'), which is straightforward, but doesn't add details like rate limits, authentication needs, or response format. The description is adequate for a simple info tool but lacks richer behavioral context.

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 front-loads the purpose and specifies the types of information retrieved. Every word earns its place, with no wasted text or unnecessary elaboration, making it highly concise and well-structured.

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 simplicity (0 parameters, no output schema, no annotations), the description is complete enough for basic understanding. However, it could be more comprehensive by addressing usage relative to siblings or providing more behavioral details, which would enhance contextual completeness for an agent.

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

Parameters4/5

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

The tool has 0 parameters, and the schema description coverage is 100%, so there's no need for parameter documentation in the description. The baseline for this scenario is 4, as the description appropriately avoids redundant parameter information and focuses on the tool's purpose.

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 with a specific verb ('Get information') and resource ('X402 API service'), including what information is retrieved (endpoints, pricing, payment requirements). However, it doesn't explicitly distinguish this from sibling tools like 'example_api_call' or 'health_check', which might also provide service-related information.

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 like 'example_api_call' or 'health_check'. It doesn't mention prerequisites, context for usage, or exclusions, leaving the agent to infer appropriate scenarios based solely on the purpose statement.

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/CodaLabs-xyz/Template-x402-Mcp'

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