Skip to main content
Glama

sweep_agent

Transfer funds from an agent's Lightning wallet back to the operator's balance using the agent ID and amount in satoshis.

Instructions

Sweep funds from agent back to operator balance. REQUIRES OPERATOR KEY.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesAgent ID to sweep funds from
amount_satsYesAmount in sats (use large number for full balance)

Implementation Reference

  • The handler implementation for the "sweep_agent" tool, which calls the client's sweepAgent method.
    case 'sweep_agent': {
      const parsed = SweepAgentSchema.parse(args);
      const amount = typeof parsed.amount_sats === 'string' ? 999999999 : parsed.amount_sats;
      const result = await session.requireClient().sweepAgent(parsed.agent_id, amount);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              message: `Swept ${result.amountTransferred} sats from agent`,
              amount_transferred: result.amountTransferred,
              new_operator_balance: result.newOperatorBalance,
              new_agent_balance: result.newAgentBalance,
            }, null, 2),
          },
        ],
      };
    }
  • The underlying API client method that performs the sweep operation.
    /**
     * Sweep funds from agent back to operator
     */
    async sweepAgent(agentId: number, amountSats: number): Promise<{
      amountTransferred: number;
      newOperatorBalance: number;
      newAgentBalance: number;
      rawResponse: ApiResponse;
    }> {
      const result = await this.request<ApiResponse & {
        amount_transferred?: number;
        new_operator_balance?: number;
        new_agent_balance?: number;
      }>('withdraw_from_agent', {
        agent_id: agentId,
        amount_sats: amountSats,
        sweep: true,
      });
    
      return {
        amountTransferred: result.amount_transferred || amountSats,
        newOperatorBalance: result.new_operator_balance || 0,
        newAgentBalance: result.new_agent_balance || 0,
        rawResponse: result,
      };
    }
  • The input validation schema for the sweep_agent tool.
    const SweepAgentSchema = z.object({
      agent_id: z.number().int().positive().describe('Agent ID to sweep funds from'),
      amount_sats: z.union([z.number().int().positive(), z.literal('all')]).describe('Amount in sats or "all" for full balance'),
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the operator key requirement, which is crucial for authentication. However, it doesn't describe what 'sweep' entails operationally (e.g., whether it's irreversible, if it affects agent status, rate limits, or error conditions). For a financial operation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 extremely concise (two short sentences) with zero wasted words. It's front-loaded with the core purpose and follows with a critical requirement. Every sentence earns its place by providing essential information without redundancy.

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

Completeness3/5

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

Given the tool's financial nature and lack of both annotations and output schema, the description is minimally complete. It covers the purpose and a key requirement but lacks details on behavioral outcomes, error handling, or return values. For a fund transfer tool with no structured safety or output information, this leaves the agent with incomplete operational context.

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 the schema already documents both parameters thoroughly. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., it doesn't clarify 'amount_sats' behavior beyond the schema's 'use large number for full balance'). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

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?

The description clearly states the specific action ('sweep funds') and the resources involved ('from agent back to operator balance'), using precise terminology. It distinguishes this tool from sibling tools like 'transfer_to_agent' or 'fund_agent' by specifying the direction (agent to operator) and purpose (sweeping rather than transferring between agents or funding).

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('sweep funds from agent back to operator balance') and includes an important prerequisite ('REQUIRES OPERATOR KEY'). However, it doesn't explicitly state when not to use it or mention specific alternatives among the sibling tools (e.g., 'transfer_to_agent' for agent-to-agent transfers).

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/lightningfaucet/lightning-wallet-mcp'

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