Skip to main content
Glama
timolein74

asterpay-mcp-server

ai_sentiment

Analyze text sentiment to classify it as positive, negative, or neutral with confidence scores, using the AsterPay MCP server.

Instructions

Analyze sentiment of text. Returns positive/negative/neutral classification with confidence scores. Cost: $0.004 USDC via x402.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to analyze sentiment for

Implementation Reference

  • The ai_sentiment tool handler - calls the AsterPay API to analyze sentiment of text via POST /v1/ai/sentiment endpoint, passing the text parameter and formatting the response.
    server.tool(
      "ai_sentiment",
      "Analyze sentiment of text. Returns positive/negative/neutral classification with confidence scores. Cost: $0.004 USDC via x402.",
      { text: z.string().describe("The text to analyze sentiment for") },
      async ({ text }) => formatResponse(await callApi("POST", "/v1/ai/sentiment", { text }))
    );
  • Input schema for ai_sentiment tool using Zod - validates that 'text' is a required string parameter with description.
    { text: z.string().describe("The text to analyze sentiment for") },
  • 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 messages with x402 protocol details.
    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),
          },
        ],
      };
    }
Behavior4/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 effectively describes the output format ('positive/negative/neutral classification with confidence scores') and explicitly states the cost ('$0.004 USDC via x402'), which are crucial behavioral traits not evident from the input schema alone. However, it doesn't mention rate limits, error conditions, or processing time.

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 extremely concise and front-loaded, with every sentence earning its place. The first sentence states the core function, the second describes the output, and the third provides cost information—all in just three sentences with zero wasted words.

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 (single parameter, no output schema, no annotations), the description is partially complete. It covers the core function, output format, and cost, but lacks information about error handling, rate limits, or example usage. For a paid service with no output schema, more contextual details would be beneficial.

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?

The schema description coverage is 100%, with the single parameter 'text' fully documented in the schema. The description doesn't add any additional parameter semantics beyond what the schema already provides (e.g., it doesn't specify text length limits, language requirements, or formatting expectations). This meets the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('analyze sentiment of text') and resource ('text'), and distinguishes it from siblings like ai_summarize or ai_translate by focusing on sentiment classification. It provides a precise verb+resource combination that leaves no ambiguity about the tool's function.

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. While it mentions cost, it doesn't specify scenarios where sentiment analysis is appropriate compared to other AI tools like ai_code_review or ai_summarize, nor does it mention prerequisites or exclusions. This leaves the agent without contextual usage direction.

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