Skip to main content
Glama
metrxbots

Metrx MCP Server

by metrxbots

metrx_update_budget_mode

Modify budget enforcement modes to switch between alert-only monitoring, overridable soft blocks, or strict hard blocks, or pause/resume existing budgets.

Instructions

Change the enforcement mode of an existing budget or pause/resume it. Use "alert_only" for monitoring, "soft_block" for overridable limits, or "hard_block" for strict enforcement. Do NOT use to create new budgets — use set_budget for that.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
budget_idYesThe budget configuration ID to update
enforcement_modeNoNew enforcement mode
pausedNoSet to true to pause the budget, false to resume

Implementation Reference

  • The handler function that executes the update_budget_mode tool logic. It validates input, constructs the request body with enforcement_mode and/or paused fields, calls the PATCH API endpoint to update the budget configuration, and returns a formatted success message.
    async ({ budget_id, enforcement_mode, paused }) => {
      const body: Record<string, unknown> = {};
      if (enforcement_mode !== undefined) body.enforcement_mode = enforcement_mode;
      if (paused !== undefined) body.paused = paused;
    
      if (Object.keys(body).length === 0) {
        return {
          content: [
            { type: 'text', text: 'No changes specified. Provide enforcement_mode or paused.' },
          ],
          isError: true,
        };
      }
    
      const result = await client.patch<BudgetConfig>(`/budgets/${budget_id}`, body);
    
      if (result.error) {
        return {
          content: [{ type: 'text', text: `Error updating budget: ${result.error}` }],
          isError: true,
        };
      }
    
      const _b = result.data!;
      const parts: string[] = ['✅ Budget updated:'];
      if (enforcement_mode) parts.push(`enforcement → ${enforcement_mode}`);
      if (paused !== undefined) parts.push(paused ? 'status → paused' : 'status → active');
    
      return {
        content: [{ type: 'text', text: parts.join(', ') }],
      };
    }
  • Input schema definition for the update_budget_mode tool using zod validation. Defines the required budget_id (UUID) and optional enforcement_mode (enum: alert_only, soft_block, hard_block) and paused (boolean) parameters.
    inputSchema: {
      budget_id: z.string().uuid().describe('The budget configuration ID to update'),
      enforcement_mode: z
        .enum(['alert_only', 'soft_block', 'hard_block'])
        .optional()
        .describe('New enforcement mode'),
      paused: z.boolean().optional().describe('Set to true to pause the budget, false to resume'),
    },
  • Full tool registration for update_budget_mode including metadata (title, description), annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint), input schema, and the handler function.
    server.registerTool(
      'update_budget_mode',
      {
        title: 'Update Budget Mode',
        description:
          'Change the enforcement mode of an existing budget or pause/resume it. ' +
          'Use "alert_only" for monitoring, "soft_block" for overridable limits, ' +
          'or "hard_block" for strict enforcement. ' +
          'Do NOT use to create new budgets — use set_budget for that.',
        inputSchema: {
          budget_id: z.string().uuid().describe('The budget configuration ID to update'),
          enforcement_mode: z
            .enum(['alert_only', 'soft_block', 'hard_block'])
            .optional()
            .describe('New enforcement mode'),
          paused: z.boolean().optional().describe('Set to true to pause the budget, false to resume'),
        },
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ budget_id, enforcement_mode, paused }) => {
        const body: Record<string, unknown> = {};
        if (enforcement_mode !== undefined) body.enforcement_mode = enforcement_mode;
        if (paused !== undefined) body.paused = paused;
    
        if (Object.keys(body).length === 0) {
          return {
            content: [
              { type: 'text', text: 'No changes specified. Provide enforcement_mode or paused.' },
            ],
            isError: true,
          };
        }
    
        const result = await client.patch<BudgetConfig>(`/budgets/${budget_id}`, body);
    
        if (result.error) {
          return {
            content: [{ type: 'text', text: `Error updating budget: ${result.error}` }],
            isError: true,
          };
        }
    
        const _b = result.data!;
        const parts: string[] = ['✅ Budget updated:'];
        if (enforcement_mode) parts.push(`enforcement → ${enforcement_mode}`);
        if (paused !== undefined) parts.push(paused ? 'status → paused' : 'status → active');
    
        return {
          content: [{ type: 'text', text: parts.join(', ') }],
        };
      }
    );

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

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