Skip to main content
Glama

get_account_usage

View per-endpoint usage for your TensorFeed token, showing the last 100 calls aggregated. Free with TENSORFEED_TOKEN.

Instructions

Show per-endpoint usage for the configured TensorFeed token (last 100 calls aggregated). Free, but requires TENSORFEED_TOKEN.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'get_account_usage' tool with the MCP server on the 'tensorfeed' server instance.
    server.tool(
      'get_account_usage',
      'Show per-endpoint usage for the configured TensorFeed token (last 100 calls aggregated). Free, but requires TENSORFEED_TOKEN.',
      {},
      async () => {
        const data = (await fetchJSON('/payment/usage', { auth: true })) as {
          total_calls: number;
          total_credits_spent: number;
          by_endpoint: Record<string, { calls: number; credits: number; last_seen: string }>;
        };
        if (data.total_calls === 0) {
          return { content: [{ type: 'text' as const, text: 'No premium API calls on this token yet.' }] };
        }
        const rows = Object.entries(data.by_endpoint)
          .sort(([, a], [, b]) => b.calls - a.calls)
          .map(([ep, info]) => `  ${ep}: ${info.calls} calls, ${info.credits} credits, last ${info.last_seen}`)
          .join('\n');
        return {
          content: [
            {
              type: 'text' as const,
              text: `Total: ${data.total_calls} calls, ${data.total_credits_spent} credits\n\n${rows}`,
            },
          ],
        };
      },
    );
  • Handler function that fetches usage data from /payment/usage endpoint, formats it, and returns it as text content.
      async () => {
        const data = (await fetchJSON('/payment/usage', { auth: true })) as {
          total_calls: number;
          total_credits_spent: number;
          by_endpoint: Record<string, { calls: number; credits: number; last_seen: string }>;
        };
        if (data.total_calls === 0) {
          return { content: [{ type: 'text' as const, text: 'No premium API calls on this token yet.' }] };
        }
        const rows = Object.entries(data.by_endpoint)
          .sort(([, a], [, b]) => b.calls - a.calls)
          .map(([ep, info]) => `  ${ep}: ${info.calls} calls, ${info.credits} credits, last ${info.last_seen}`)
          .join('\n');
        return {
          content: [
            {
              type: 'text' as const,
              text: `Total: ${data.total_calls} calls, ${data.total_credits_spent} credits\n\n${rows}`,
            },
          ],
        };
      },
    );
  • Helper function fetchJSON used by the tool handler to make authenticated API calls to tensorfeed.ai.
    async function fetchJSON(path: string, opts: FetchOptions = {}): Promise<unknown> {
      const headers: Record<string, string> = {
        'User-Agent': `TensorFeed-MCP/${SDK_VERSION}`,
      };
      if (opts.body !== undefined) headers['Content-Type'] = 'application/json';
      if (opts.auth) {
        const token = process.env.TENSORFEED_TOKEN;
        if (!token) {
          throw new Error(
            'TENSORFEED_TOKEN env var is not set. Premium MCP tools require a bearer token. ' +
              'Buy credits at https://tensorfeed.ai/developers/agent-payments and pass the returned tf_live_... token via the TENSORFEED_TOKEN env var in your MCP client config.',
          );
        }
        headers['Authorization'] = `Bearer ${token}`;
      }
      const res = await fetch(`${API_BASE}${path}`, {
        method: opts.method ?? 'GET',
        headers,
        ...(opts.body !== undefined ? { body: JSON.stringify(opts.body) } : {}),
      });
      if (!res.ok) {
        let errPayload: unknown;
        try {
          errPayload = await res.json();
        } catch {
          errPayload = await res.text().catch(() => '');
        }
        if (res.status === 402) {
          throw new Error(
            `Payment required (402). Your token may be out of credits. Top up at https://tensorfeed.ai/developers/agent-payments. Detail: ${JSON.stringify(errPayload)}`,
          );
        }
        if (res.status === 401) {
          throw new Error(
            `Token rejected (401). Check that TENSORFEED_TOKEN is set to a valid tf_live_... token. Detail: ${JSON.stringify(errPayload)}`,
          );
        }
        throw new Error(`API error ${res.status}: ${JSON.stringify(errPayload)}`);
      }
      return res.json();
    }
  • Empty schema object — this tool takes no input parameters.
    {},
Behavior2/5

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

No annotations provided; description carries full burden. It notes token requirement but lacks disclosure on error behavior, side effects, or rate limits. Minimal behavioral insight.

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?

Single sentence front-loads purpose and key requirement. No redundancy, every word adds value.

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

Completeness5/5

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

Simple tool with no parameters or output schema; description sufficiently covers purpose, scope (last 100 calls), and prerequisite (token). Complete for intended use.

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?

No parameters in input schema, so baseline is 4. Description adds context about token requirement, which is relevant for usage.

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?

Description clearly states the tool shows per-endpoint usage for a TensorFeed token, with specific scope (last 100 calls). Distinguishes from sibling tools like get_account_balance or get_agent_activity.

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

Usage Guidelines3/5

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

Mentions prerequisite (requires TENSORFEED_TOKEN) and that it's free, but does not provide when-to-use or when-not-to-use guidance relative to alternatives.

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/RipperMercs/tensorfeed'

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