Skip to main content
Glama
timolein74

asterpay-mcp-server

ai_summarize

Generate concise AI summaries of text documents with adjustable length. Pay per use via USDC on Base network.

Instructions

Summarize any text using AI. Returns a concise summary of the input. Cost: $0.004 USDC via x402.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to summarize
maxLengthNoMaximum summary length in words

Implementation Reference

  • Registration of the 'ai_summarize' tool with server.tool(), including name, description, input schema (text and maxLength), and handler function
    server.tool(
      "ai_summarize",
      "Summarize any text using AI. Returns a concise summary of the input. Cost: $0.004 USDC via x402.",
      {
        text: z.string().describe("The text to summarize"),
        maxLength: z.number().optional().describe("Maximum summary length in words"),
      },
      async ({ text, maxLength }) => formatResponse(await callApi("POST", "/v1/ai/summarize", { text, maxLength }))
    );
  • Handler function for ai_summarize tool - async arrow function that calls the AsterPay API POST /v1/ai/summarize endpoint with text and maxLength parameters
    async ({ text, maxLength }) => formatResponse(await callApi("POST", "/v1/ai/summarize", { text, maxLength }))
  • Zod schema definition for ai_summarize tool inputs: 'text' (required string to summarize) and 'maxLength' (optional number for max summary length in words)
    {
      text: z.string().describe("The text to summarize"),
      maxLength: z.number().optional().describe("Maximum summary length in words"),
    },
  • callApi helper function that makes HTTP requests to the AsterPay API, handles 402 payment-required responses, and returns status/data
    async function callApi(
      method: "GET" | "POST",
      path: string,
      body?: Record<string, unknown>
    ): Promise<{ status: number; data: unknown; paymentRequired?: unknown }> {
      const url = `${API_BASE}${path}`;
      const headers: Record<string, string> = { "Content-Type": "application/json" };
    
      const res = await fetch(url, {
        method,
        headers,
        ...(body ? { body: JSON.stringify(body) } : {}),
      });
    
      const data = await res.json();
    
      if (res.status === 402) {
        return {
          status: 402,
          data: null,
          paymentRequired: data,
        };
      }
    
      return { status: res.status, data };
    }
  • formatResponse helper function that formats API responses for MCP tool output, including payment-required instructions for 402 responses
    function formatResponse(result: { status: number; data: unknown; paymentRequired?: unknown }): {
      content: Array<{ type: "text"; text: string }>;
    } {
      if (result.status === 402) {
        const pr = result.paymentRequired as Record<string, unknown>;
        const accepts = (pr?.accepts as Array<Record<string, unknown>>)?.[0];
        const amount = accepts?.amount
          ? `${(parseInt(accepts.amount as string) / 1e6).toFixed(6)} USDC`
          : "unknown";
        const network = (accepts?.network as string) || "unknown";
    
        return {
          content: [
            {
              type: "text",
              text: [
                "Payment required to access this endpoint.",
                "",
                `Amount: ${amount}`,
                `Network: ${network}`,
                `Asset: USDC`,
                `Pay to: ${(accepts?.payTo as string) || "unknown"}`,
                "",
                "To use this endpoint, send an x402 payment via @x402/fetch or the AsterPay SDK.",
                "Install: npm install @x402/fetch",
                "",
                "Example:",
                "```",
                'import { wrapFetch } from "@x402/fetch";',
                'const fetchWithPay = wrapFetch(fetch, wallet);',
                `const res = await fetchWithPay("${API_BASE}${(pr?.resource as Record<string, unknown>)?.url || ""}");`,
                "```",
                "",
                "Docs: https://x402-api-production-ba87.up.railway.app/docs",
                "Discovery: https://x402-api-production-ba87.up.railway.app/discovery/resources",
              ].join("\n"),
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result.data, null, 2),
          },
        ],
      };
    }
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 adds context beyond basic functionality by mentioning the cost ('Cost: $0.004 USDC via x402'), which is a useful behavioral trait (monetary implication). However, it lacks details on other behaviors like rate limits, error handling, or output format (e.g., summary structure), leaving gaps for a tool with no output schema.

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 and front-loaded: the first sentence states the core purpose, the second adds return value context, and the third provides cost information. Each sentence earns its place, but it could be slightly more structured (e.g., separating functional and non-functional details). No wasted words, but minor room for improvement in flow.

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 moderate complexity (AI-based summarization with cost), no annotations, and no output schema, the description is partially complete. It covers purpose and cost but lacks details on behavioral aspects like error cases, performance, or output format. For a tool with no structured output, more context on what the summary looks like would enhance completeness, but it's minimally adequate.

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 both parameters (text and maxLength) adequately. The description adds no additional meaning beyond what the schema provides (e.g., it doesn't explain how maxLength interacts with summarization quality or default values). Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate with extra insights.

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: 'Summarize any text using AI' specifies the verb (summarize) and resource (text). It distinguishes from siblings like ai_sentiment or ai_translate by focusing on summarization rather than sentiment analysis or translation. However, it doesn't explicitly differentiate from all AI siblings (e.g., ai_code_review could also involve text processing).

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. It mentions a cost implication ('Cost: $0.004 USDC via x402'), which might hint at usage considerations, but doesn't specify scenarios where summarization is preferred over other AI tools like ai_sentiment or when not to use it (e.g., for non-text inputs). No explicit alternatives or exclusions are mentioned.

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/timolein74/asterpay-mcp-server'

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