Skip to main content
Glama
solanaprox

solanaprox-mcp

by solanaprox

ask_ai

Send prompts to Claude or GPT-4 AI models using Solana USDC payments from your wallet. Process AI inference tasks with automated cost deduction.

Instructions

Send a prompt to an AI model via SolanaProx. Costs are automatically deducted from your Solana wallet balance in USDC. Supports Claude and GPT-4 models. Use this for any AI inference task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe prompt or question to send to the AI model
modelNoAI model to use. Options: claude-sonnet-4-20250514 (default), gpt-4-turboclaude-sonnet-4-20250514
max_tokensNoMaximum tokens in response (default: 1024, max: 4096)
systemNoOptional system prompt to set context for the AI

Implementation Reference

  • The handler for the 'ask_ai' tool - extracts arguments (prompt, model, max_tokens, system), calls the callAI helper function, and returns the AI response with cost information.
    case "ask_ai": {
      const { prompt, model, max_tokens, system } = args as any;
    
      const result = await callAI(
        prompt,
        model || "claude-sonnet-4-20250514",
        max_tokens || 1024,
        system
      );
    
      return {
        content: [
          {
            type: "text",
            text: `${result.response}\n\n---\n⚡ Powered by SolanaProx | Model: ${result.model} | Cost: ~$${result.cost_usd.toFixed(6)} USDC`,
          },
        ],
      };
    }
  • The tool definition/schema for 'ask_ai' including name, description, and inputSchema with properties for prompt (required), model, max_tokens, and system prompt.
    const tools: Tool[] = [
      {
        name: "ask_ai",
        description:
          "Send a prompt to an AI model via SolanaProx. Costs are automatically deducted from your Solana wallet balance in USDC. Supports Claude and GPT-4 models. Use this for any AI inference task.",
        inputSchema: {
          type: "object",
          properties: {
            prompt: {
              type: "string",
              description: "The prompt or question to send to the AI model",
            },
            model: {
              type: "string",
              description:
                "AI model to use. Options: claude-sonnet-4-20250514 (default), gpt-4-turbo",
              default: "claude-sonnet-4-20250514",
            },
            max_tokens: {
              type: "number",
              description: "Maximum tokens in response (default: 1024, max: 4096)",
              default: 1024,
            },
            system: {
              type: "string",
              description: "Optional system prompt to set context for the AI",
            },
          },
          required: ["prompt"],
        },
      },
  • The callAI helper function that makes the actual HTTP POST request to the SolanaProx API endpoint (/v1/messages), handles authentication via X-Wallet-Address header, processes errors including insufficient balance (402), and returns response text with cost estimation.
    async function callAI(
      prompt: string,
      model: string = "claude-sonnet-4-20250514",
      maxTokens: number = 1024,
      system?: string
    ): Promise<{ response: string; cost_usd: number; model: string }> {
      const messages: any[] = [{ role: "user", content: prompt }];
    
      const body: any = {
        model,
        max_tokens: maxTokens,
        messages,
      };
    
      if (system) {
        body.system = system;
      }
    
      const res = await fetch(`${SOLANAPROX_URL}/v1/messages`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "X-Wallet-Address": WALLET_ADDRESS,
        },
        body: JSON.stringify(body),
      });
    
      if (!res.ok) {
        const error = await res.text();
        if (res.status === 402) {
          throw new Error(
            `Insufficient balance. Deposit USDC at ${SOLANAPROX_URL} to continue. Wallet: ${WALLET_ADDRESS}`
          );
        }
        throw new Error(`SolanaProx API error (${res.status}): ${error}`);
      }
    
      const data = await res.json() as any;
    
      const responseText =
        data.content?.[0]?.text ||
        data.choices?.[0]?.message?.content ||
        JSON.stringify(data);
    
      // Estimate cost from usage if available
      const inputTokens = data.usage?.input_tokens || 0;
      const outputTokens = data.usage?.output_tokens || 0;
      const costUSD = estimateCostFromTokens(model, inputTokens, outputTokens);
    
      return {
        response: responseText,
        cost_usd: costUSD,
        model: data.model || model,
      };
    }
  • The estimateCostFromTokens helper function that calculates the cost in USD based on the model, input tokens, and output tokens using predefined pricing rates.
    function estimateCostFromTokens(
      model: string,
      inputTokens: number,
      outputTokens: number
    ): number {
      // Pricing per 1M tokens (with 20% markup)
      const pricing: Record<string, { input: number; output: number }> = {
        "claude-sonnet-4-20250514": { input: 3.6, output: 18.0 },
        "claude-3-5-sonnet-20241022": { input: 3.6, output: 18.0 },
        "gpt-4-turbo": { input: 12.0, output: 36.0 },
      };
    
      const p = pricing[model] || { input: 3.6, output: 18.0 };
      return (inputTokens * p.input + outputTokens * p.output) / 1_000_000;
    }
  • src/index.ts:249-258 (registration)
    The CallToolRequestSchema handler that routes tool calls - this is where 'ask_ai' is registered as a case in the switch statement to dispatch to its handler.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        switch (name) {
          case "ask_ai": {
            const { prompt, model, max_tokens, system } = args as any;
    
            const result = await callAI(
              prompt,
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 effectively describes key behavioral traits: the payment mechanism ('Costs are automatically deducted from your Solana wallet balance in USDC') and supported models ('Supports Claude and GPT-4 models'). However, it lacks information about rate limits, error handling, response format, or authentication requirements, which are important for a paid service 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 perfectly concise with three sentences that each serve a distinct purpose: stating the core function, explaining the payment mechanism, listing supported models, and providing usage guidance. There's no wasted language, and the information is front-loaded with the most critical details first.

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 that this is a paid service tool with 4 parameters, no annotations, and no output schema, the description provides adequate but incomplete context. It covers the payment mechanism and supported models well, but lacks information about response format, error conditions, rate limits, or authentication requirements that would be important for proper tool invocation in a production context.

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%, providing complete parameter documentation in the structured fields. The description doesn't add any parameter-specific information beyond what's already in the schema, so it meets the baseline expectation. No additional semantic context is provided for the parameters beyond what the schema already covers.

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 ('Send a prompt to an AI model'), identifies the resource ('via SolanaProx'), and distinguishes this tool from its siblings (check_balance, estimate_cost, list_models) by focusing on execution rather than querying or listing. It provides a complete purpose statement with both the primary function and the payment mechanism.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Use this for any AI inference task'), which directly addresses its primary use case. However, it doesn't explicitly mention when NOT to use it or provide specific alternatives among the sibling tools (e.g., using estimate_cost first for cost estimation or list_models for model discovery), leaving some room for improvement in comparative guidance.

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

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