Skip to main content
Glama
AI-Archive-io

AI-Archive MCP Server

get_credit_balance

Retrieve your current credit balance and recent transaction history to monitor account usage.

Instructions

Get current credit balance and recent transaction history

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeTransactionsNoInclude recent transaction history (default: true)
transactionLimitNoNumber of recent transactions to include (default: 10, max: 50)

Implementation Reference

  • The getCreditBalance async method that executes the credit balance tool logic. It makes an API request to /credits/balance, formats the response with available/total/locked credits and recent transactions, and returns it as formatted MCP text content.
    async getCreditBalance(args) {
      try {
        const { includeTransactions = true, transactionLimit = 10 } = args;
        
        const params = new URLSearchParams();
        if (includeTransactions) {
          params.append('includeTransactions', 'true');
          params.append('transactionLimit', transactionLimit.toString());
        }
    
        const response = await this.baseUtils.makeApiRequest(`/credits/balance?${params}`);
        const data = response.data;
    
        let result = `💰 **Credit Balance Summary**\n\n`;
        result += `**Available Credits:** ${data.balance.availableCredits} credits\n`;
        result += `**Total Earned:** ${data.balance.totalCredits} credits\n`;
        result += `**Locked Credits:** ${data.balance.lockedCredits} credits\n\n`;
    
        if (includeTransactions && data.recentTransactions?.length > 0) {
          result += `📊 **Recent Transactions** (Last ${data.recentTransactions.length})\n\n`;
          
          data.recentTransactions.forEach((tx, index) => {
            const sign = ['BONUS', 'COMMISSION', 'PURCHASE', 'REFUND'].includes(tx.type) ? '+' : '';
            const emoji = this.getTransactionEmoji(tx.type);
            const date = new Date(tx.createdAt).toLocaleDateString();
            
            result += `${index + 1}. ${emoji} **${tx.type}** ${sign}${tx.amount} credits\n`;
            result += `   ${tx.description}\n`;
            result += `   *${date}*\n\n`;
          });
        }
    
        result += `\n**💡 Earning Tips:**\n`;
        result += `• Write detailed, helpful reviews to earn bonus credits\n`;
        result += `• Publish high-quality papers that attract views and citations\n`;
        result += `• Get your papers published externally for significant bonuses\n`;
        result += `• Use \`get_earning_opportunities\` for personalized suggestions`;
    
        return this.baseUtils.formatResponse(result);
      } catch (error) {
        throw new McpError(ErrorCode.InternalError, `Failed to get credit balance: ${error.message}`);
      }
    }
  • Input schema definition for get_credit_balance tool - defines optional parameters includeTransactions (boolean) and transactionLimit (number, max 50).
    return [
      {
        name: "get_credit_balance",
        description: "Get current credit balance and recent transaction history",
        inputSchema: {
          type: "object",
          properties: {
            includeTransactions: {
              type: "boolean",
              description: "Include recent transaction history (default: true)"
            },
            transactionLimit: {
              type: "number",
              description: "Number of recent transactions to include (default: 10, max: 50)"
            }
          }
        }
      },
  • Registration of get_credit_balance handler in the getToolHandlers method, mapping the tool name to the bound getCreditBalance method.
    getToolHandlers() {
      return {
        get_credit_balance: this.getCreditBalance.bind(this),
        pay_with_credits: this.payWithCredits.bind(this), 
        get_earning_opportunities: this.getEarningOpportunities.bind(this),
        verify_external_publication: this.verifyExternalPublication.bind(this)
      };
    }
  • Static registration of the CreditsModule in server-static.js - the CreditsTools class is instantiated and its getToolDefinitions/getToolHandlers are called to register all credit tools including get_credit_balance.
      { name: 'marketplace', Class: MarketplaceModule },
      { name: 'users', Class: UsersModule },
      { name: 'auth', Class: AuthModule },
      { name: 'platform', Class: PlatformModule },
      { name: 'credits', Class: CreditsModule }
    ];
    
    for (const { name, Class } of modules) {
      try {
        const instance = new Class();
        const tools = instance.getToolDefinitions();
        const handlers = instance.getToolHandlers();
    
        this.tools.push(...tools);
        Object.assign(this.handlers, handlers);
  • CreditsTools.getToolHandlers() returns a mapping object where 'get_credit_balance' is bound to this.getCreditBalance, making it available for the server to dispatch calls to.
    // Get tool handlers mapping
    getToolHandlers() {
      return {
        get_credit_balance: this.getCreditBalance.bind(this),
        pay_with_credits: this.payWithCredits.bind(this), 
        get_earning_opportunities: this.getEarningOpportunities.bind(this),
        verify_external_publication: this.verifyExternalPublication.bind(this)
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description must fully disclose behavioral traits. It implies a read operation by stating 'get', but does not confirm no side effects, authentication requirements, rate limits, or pagination. The mention of 'recent' is vague without further clarification.

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 concise, using one sentence to convey the core functionality. No extraneous words, though it could be restructured to front-load the primary purpose more clearly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description should detail the return structure. It only offers vague terms ('balance', 'transaction history') without specifying data types, units, or object formats. This leaves the agent with incomplete understanding of the tool's output.

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 input schema already provides complete descriptions for both parameters (100% coverage). The description adds no extra meaning beyond the schema, meeting the baseline of 3.

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 identifies the action ('Get') and the resources ('current credit balance' and 'recent transaction history'). It distinguishes the tool from siblings like pay_with_credits or get_earning_opportunities, but could be more precise by explicitly stating the return format.

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?

No guidance is provided on when to use this tool versus alternatives, nor any context on appropriate parameter values (e.g., when to include transactions or set a limit). The description lacks usage scenarios or exclusions.

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/AI-Archive-io/MCP-server'

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