Skip to main content
Glama

Zen Budget

ultra-budget

Set and monitor conversation budgets to control costs, tokens, and duration for AI sessions. Manage spending limits and track usage across multiple AI providers.

Instructions

Set and monitor conversation budgets for cost and token control

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform
sessionIdYesSession ID to manage budget for
maxTokensNoMaximum tokens allowed for the session
maxCostUsdNoMaximum cost in USD allowed for the session
maxDurationMsNoMaximum duration in milliseconds allowed for the session

Implementation Reference

  • src/server.ts:994-1000 (registration)
    Registration of the ultra-budget tool using server.registerTool, specifying title, description, ZenBudgetSchema for input validation, and delegating to handleBudget function.
    server.registerTool("ultra-budget", {
      title: "Zen Budget",
      description: "Set and monitor conversation budgets for cost and token control",
      inputSchema: ZenBudgetSchema.shape,
    }, async (args) => {
      return await handleBudget(args) as any;
    });
  • ZenBudgetSchema: Zod schema defining the input structure and validation for the ultra-budget tool, including actions (set/get/check), sessionId, and optional budget limits.
    const ZenBudgetSchema = z.object({
      action: z.enum(["set", "get", "check"]).describe("Action to perform"),
      sessionId: z.string().describe("Session ID to manage budget for"),
      maxTokens: z.number().optional().describe("Maximum tokens allowed for the session"),
      maxCostUsd: z.number().optional().describe("Maximum cost in USD allowed for the session"),
      maxDurationMs: z.number().optional().describe("Maximum duration in milliseconds allowed for the session"),
    });
  • Core handler function for ultra-budget tool. Processes 'set', 'get', and 'check' actions using conversationMemory to manage session budgets for tokens, cost (USD), and duration (ms). Returns formatted text responses with status and limits.
    export async function handleBudget(args: any) {
      const { action, sessionId, maxTokens, maxCostUsd, maxDurationMs } = args;
    
      switch (action) {
        case 'set': {
          const budget = await conversationMemory.setBudget(sessionId, maxTokens, maxCostUsd, maxDurationMs);
          return {
            content: [
              {
                type: 'text',
                text: `## Budget Set\n\nSession: ${sessionId}\nMax Tokens: ${maxTokens || 'None'}\nMax Cost: $${maxCostUsd || 'None'}\nMax Duration: ${maxDurationMs || 'None'}ms`
              }
            ]
          };
        }
    
        case 'get': {
          const context = await conversationMemory.getConversationContext(sessionId);
          const budget = context.budget;
          
          return {
            content: [
              {
                type: 'text',
                text: `## Budget Status\n\nSession: ${sessionId}\n\n**Limits:**\n- Max Tokens: ${budget?.maxTokens || 'None'}\n- Max Cost: $${budget?.maxCostUsd || 'None'}\n- Max Duration: ${budget?.maxDurationMs || 'None'}ms\n\n**Usage:**\n- Used Tokens: ${budget?.usedTokens || 0}\n- Used Cost: $${budget?.usedCostUsd || 0}\n- Used Duration: ${budget?.usedDurationMs || 0}ms`
              }
            ]
          };
        }
    
        case 'check': {
          const limits = await conversationMemory.checkBudgetLimits(sessionId);
          const status = limits.withinLimits ? '✅ Within Limits' : '⚠️ Limits Exceeded';
          const details = [
            `Token Limit: ${limits.tokenLimitExceeded ? '❌ Exceeded' : '✅ OK'}`,
            `Cost Limit: ${limits.costLimitExceeded ? '❌ Exceeded' : '✅ OK'}`,
            `Duration Limit: ${limits.durationLimitExceeded ? '❌ Exceeded' : '✅ OK'}`
          ].join('\n');
    
          return {
            content: [
              {
                type: 'text',
                text: `## Budget Check\n\nSession: ${sessionId}\nStatus: ${status}\n\n${details}`
              }
            ]
          };
        }
    
        default:
          throw new Error(`Unknown action: ${action}`);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions 'set and monitor' but doesn't explain what happens when budgets are exceeded (e.g., whether sessions are terminated, warnings issued), whether changes are persistent, what permissions are required, or rate limits. For a tool that controls critical resources (cost, tokens), this lack of operational detail is a significant gap.

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 a single, efficient sentence that immediately conveys the core function. Every word earns its place with no redundancy or fluff. It's appropriately sized for the tool's complexity and front-loaded with essential information.

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?

For a tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects (what monitoring entails, consequences of exceeding budgets), return values, or error conditions. Given the potential impact of budget controls, more context about how the tool operates is needed for safe and effective use.

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?

Schema description coverage is 100%, so parameters are well-documented in the schema itself. The description adds no additional parameter semantics beyond implying budget management involves tokens, cost, and duration. It doesn't explain parameter relationships (e.g., how 'action' values affect other parameters) or provide usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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 states the tool's purpose as 'Set and monitor conversation budgets for cost and token control', which includes specific verbs ('set', 'monitor') and resources ('budgets', 'cost', 'tokens'). It distinguishes from sibling tools by focusing on budget management rather than code analysis, debugging, or other functions. However, it doesn't explicitly differentiate from all siblings beyond the general domain difference.

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. It doesn't mention prerequisites, appropriate contexts, or exclusions. With many sibling tools available (e.g., ultra-session, ultra-plan), there's no indication of when budget management should be prioritized over other operations.

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/RealMikeChong/ultra-mcp'

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