Skip to main content
Glama

Check budget status

l402_set_budget
Read-onlyIdempotent

Check the hard spending limit set for the session at startup. Use this to confirm the budget cap before making any API calls.

Instructions

Returns the session budget cap configured at startup (via BUDGET_SATS env var). Use this to confirm what hard spending limit is in effect — useful at the start of a session before making any API calls. Read-only: this tool CANNOT set or change the budget at runtime. To raise or lower the cap, stop and restart the MCP server with a different BUDGET_SATS value. For remaining balance during a session, use l402_balance instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • mcp/server.ts:248-276 (registration)
    Registration of the 'l402_set_budget' tool on the MCP server with its schema (title, description, inputSchema, annotations) and the async handler callback.
    // Tool: l402_set_budget
    server.registerTool(
      "l402_set_budget",
      {
        title: "Check budget status",
        description:
          "Returns the session budget cap configured at startup (via BUDGET_SATS env var). " +
          "Use this to confirm what hard spending limit is in effect — useful at the start of a session before making any API calls. " +
          "Read-only: this tool CANNOT set or change the budget at runtime. " +
          "To raise or lower the cap, stop and restart the MCP server with a different BUDGET_SATS value. " +
          "For remaining balance during a session, use l402_balance instead.",
        inputSchema: {},
        annotations: {
          readOnlyHint: true,
          idempotentHint: true,
        },
      },
      async () => {
        const report = requireClient().spendingReport();
        return {
          content: [{
            type: "text" as const,
            text: report
              ? `Budget: ${budgetSats} sats total, ${report.remaining} remaining.`
              : `No budget configured (BUDGET_SATS not set).`,
          }],
        };
      }
    );
  • The handler function for l402_set_budget. Calls client.spendingReport() and returns the budget cap (budgetSats) and remaining balance, or a message if no budget is configured.
    async () => {
      const report = requireClient().spendingReport();
      return {
        content: [{
          type: "text" as const,
          text: report
            ? `Budget: ${budgetSats} sats total, ${report.remaining} remaining.`
            : `No budget configured (BUDGET_SATS not set).`,
        }],
      };
    }
  • Schema definition for l402_set_budget: title='Check budget status', description explaining it's read-only and returns the BUDGET_SATS cap, empty inputSchema, and readOnlyHint/idempotentHint annotations.
    {
      title: "Check budget status",
      description:
        "Returns the session budget cap configured at startup (via BUDGET_SATS env var). " +
        "Use this to confirm what hard spending limit is in effect — useful at the start of a session before making any API calls. " +
        "Read-only: this tool CANNOT set or change the budget at runtime. " +
        "To raise or lower the cap, stop and restart the MCP server with a different BUDGET_SATS value. " +
        "For remaining balance during a session, use l402_balance instead.",
      inputSchema: {},
      annotations: {
        readOnlyHint: true,
        idempotentHint: true,
      },
  • The spendingReport() method on L402Client that delegates to BudgetTracker.report() to produce the SpendingReport object.
    /** Returns a spending report. Only available when budgetSats is configured. */
    spendingReport() {
      if (!this.budget) return null;
      return this.budget.report();
    }
  • The BudgetTracker.report() method that compiles the SpendingReport (total spent, remaining, byDomain breakdown, transaction list) used by the l402_set_budget handler.
    report(): SpendingReport {
      return {
        total: this.spent,
        remaining: Math.max(0, this.limitSats - this.spent),
        byDomain: { ...this.byDomain },
        transactions: [...this.transactions],
      };
    }
Behavior5/5

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

Description reinforces readOnlyHint and idempotentHint by stating it is read-only and cannot change budget. It adds context about the budget being configured at startup via env var and explains how to change it (restart server). No contradictions with annotations.

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?

Three sentences, front-loaded with purpose, no redundant words. Each sentence adds value: what it does, when to use, what it cannot do, and alternative for balance.

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?

No output schema, no parameters, annotations present. Description fully explains the tool's single action, its limitations, and relationship to siblings. Complete for a simple read-only status tool.

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?

Input schema has no parameters (schema coverage 100%). Baseline for 0 params is 4. Description adds no parameter information because none is needed; it correctly focuses on the tool's behavior.

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 'Returns the session budget cap configured at startup (via BUDGET_SATS env var)', using specific verb and resource. It distinguishes from sibling l402_balance by noting the latter is for remaining balance during a session.

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

Usage Guidelines5/5

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

Explicitly says 'Use this to confirm what hard spending limit is in effect — useful at the start of a session before making any API calls.' Also specifies when not to use: 'this tool CANNOT set or change the budget at runtime' and directs to l402_balance for remaining balance.

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/ShinyDapps/l402-kit'

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