Skip to main content
Glama
CodaLabs-xyz

X402 MCP Template

by CodaLabs-xyz

health_check

Verify X402 API service availability and response status to ensure reliable access for micropayment-based operations.

Instructions

Check if the X402 API service is available and responding

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler logic for the 'health_check' tool. It attempts to GET the /health endpoint using axios (non-payment client) with a 5-second timeout. Returns a JSON-formatted response indicating 'healthy' status with API details if successful, or 'error' status with error message if failed.
    case "health_check": {
      try {
        // Try health endpoint
        const response = await axios.get(`${baseURL}/health`, { timeout: 5000 });
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  status: "healthy",
                  api_url: baseURL,
                  payment_enabled: paymentEnabled,
                  network: network,
                  response: response.data,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  status: "error",
                  api_url: baseURL,
                  payment_enabled: paymentEnabled,
                  network: network,
                  error: error.message,
                  note: "API may be down or health endpoint not available",
                },
                null,
                2
              ),
            },
          ],
        };
      }
    }
  • The tool definition including name, description, and empty input schema (no parameters required) as returned by the listTools handler.
    {
      name: "health_check",
      description: "Check if the X402 API service is available and responding",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • index.ts:106-148 (registration)
    The listTools request handler where the 'health_check' tool is registered in the tools array.
    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: {},
            },
          },
        ],
      };
    });
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 states the tool checks availability and responsiveness, but doesn't describe what 'available' or 'responding' means (e.g., HTTP status codes, timeouts, error handling), or any side effects like rate limits or authentication needs, leaving gaps for a mutation-free tool.

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 any wasted words. It's front-loaded with the core action and resource, making it highly concise and well-structured for quick understanding.

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 adequate but has clear gaps. It covers the basic purpose but lacks details on behavioral aspects like response format or error conditions, making it minimally viable but not fully comprehensive for an API health check tool.

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 schema description coverage is 100%, so there's no need for parameter details in the description. The baseline for such cases is 4, as the description appropriately avoids redundant information while focusing 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 ('Check') and resource ('X402 API service'), specifying availability and responsiveness. However, it doesn't explicitly differentiate from sibling tools like 'example_api_call' or 'service_info', which might offer overlapping functionality, preventing a perfect score.

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 'service_info', nor does it mention any prerequisites or exclusions. It implies usage for checking service status but lacks explicit context for tool selection.

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