Skip to main content
Glama

approve_token

Authorize a spender to transfer tokens from your wallet by setting approval amounts for specific tokens on supported networks.

Instructions

Approve a spender to transfer tokens on your behalf. Requires APPROVED_SPENDERS policy.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spenderYesSpender address
tokenYesToken info. Provide full metadata (address/decimals/symbol) OR assetId alone for auto-resolve.
amountYesApproval amount in smallest units (wei for EVM, lamports for Solana). Example: "1000000" = 1 USDC (6 decimals). Use max uint256 for unlimited: "115792089237316195423570985008687907853269984665640564039457584007913129639935"
networkNoTarget network (e.g., "polygon-mainnet" or CAIP-2 "eip155:137"). Required for EVM wallets; auto-resolved for Solana.
wallet_idNoTarget wallet ID. Required for multi-wallet sessions; auto-resolved when session has a single wallet.
gas_conditionNoGas price condition for deferred execution. At least one of max_gas_price or max_priority_fee required.

Implementation Reference

  • The handler function for the 'approve_token' tool, which constructs the payload and calls the API to create the transaction.
    async (args) => {
      const body: Record<string, unknown> = {
        type: 'APPROVE',
        spender: args.spender,
        token: args.token,
        amount: args.amount,
      };
      if (args.network !== undefined) body.network = args.network;
      if (args.wallet_id) body.walletId = args.wallet_id;
      if (args.gas_condition) {
        body.gasCondition = {
          maxGasPrice: args.gas_condition.max_gas_price,
          maxPriorityFee: args.gas_condition.max_priority_fee,
          timeout: args.gas_condition.timeout,
        };
      }
      const result = await apiClient.post('/v1/transactions/send', body);
      return toToolResult(result);
    },
  • The Zod schema definition for the 'approve_token' tool input parameters.
    {
      spender: z.string().describe('Spender address'),
      token: z.object({
        address: z.string().optional().describe('Token mint (SPL) or contract address (ERC-20). Optional when assetId is provided.'),
        decimals: z.number().optional().describe('Token decimals (e.g., 6 for USDC). Optional when assetId is provided.'),
        symbol: z.string().optional().describe('Token symbol (e.g., USDC). Optional when assetId is provided.'),
        assetId: z.string().optional().describe(
          'CAIP-19 asset identifier. When provided alone (without address/decimals/symbol), the daemon auto-resolves from the token registry.',
        ),
      }).describe('Token info. Provide full metadata (address/decimals/symbol) OR assetId alone for auto-resolve.'),
      amount: z.string().describe('Approval amount in smallest units (wei for EVM, lamports for Solana). Example: "1000000" = 1 USDC (6 decimals). Use max uint256 for unlimited: "115792089237316195423570985008687907853269984665640564039457584007913129639935"'),
      network: z.string().optional().describe('Target network (e.g., "polygon-mainnet" or CAIP-2 "eip155:137"). Required for EVM wallets; auto-resolved for Solana.'),
      wallet_id: z.string().optional().describe('Target wallet ID. Required for multi-wallet sessions; auto-resolved when session has a single wallet.'),
      gas_condition: z.object({
        max_gas_price: z.string().optional().describe('Max gas price in wei (EVM baseFee+priorityFee)'),
        max_priority_fee: z.string().optional().describe('Max priority fee in wei (EVM) or micro-lamports (Solana)'),
        timeout: z.number().optional().describe('Max wait time in seconds (60-86400)'),
      }).optional().describe('Gas price condition for deferred execution. At least one of max_gas_price or max_priority_fee required.'),
    },
  • Registration function 'registerApproveToken' that adds the 'approve_token' tool to the McpServer.
    export function registerApproveToken(server: McpServer, apiClient: ApiClient, walletContext?: WalletContext): void {
      server.tool(
        'approve_token',
        withWalletPrefix('Approve a spender to transfer tokens on your behalf. Requires APPROVED_SPENDERS policy.', walletContext?.walletName),
        {
          spender: z.string().describe('Spender address'),
          token: z.object({
            address: z.string().optional().describe('Token mint (SPL) or contract address (ERC-20). Optional when assetId is provided.'),
            decimals: z.number().optional().describe('Token decimals (e.g., 6 for USDC). Optional when assetId is provided.'),
            symbol: z.string().optional().describe('Token symbol (e.g., USDC). Optional when assetId is provided.'),
            assetId: z.string().optional().describe(
              'CAIP-19 asset identifier. When provided alone (without address/decimals/symbol), the daemon auto-resolves from the token registry.',
            ),
          }).describe('Token info. Provide full metadata (address/decimals/symbol) OR assetId alone for auto-resolve.'),
          amount: z.string().describe('Approval amount in smallest units (wei for EVM, lamports for Solana). Example: "1000000" = 1 USDC (6 decimals). Use max uint256 for unlimited: "115792089237316195423570985008687907853269984665640564039457584007913129639935"'),
          network: z.string().optional().describe('Target network (e.g., "polygon-mainnet" or CAIP-2 "eip155:137"). Required for EVM wallets; auto-resolved for Solana.'),
          wallet_id: z.string().optional().describe('Target wallet ID. Required for multi-wallet sessions; auto-resolved when session has a single wallet.'),
          gas_condition: z.object({
            max_gas_price: z.string().optional().describe('Max gas price in wei (EVM baseFee+priorityFee)'),
            max_priority_fee: z.string().optional().describe('Max priority fee in wei (EVM) or micro-lamports (Solana)'),
            timeout: z.number().optional().describe('Max wait time in seconds (60-86400)'),
          }).optional().describe('Gas price condition for deferred execution. At least one of max_gas_price or max_priority_fee required.'),
        },
        async (args) => {
          const body: Record<string, unknown> = {
            type: 'APPROVE',
            spender: args.spender,
            token: args.token,
            amount: args.amount,
          };
          if (args.network !== undefined) body.network = args.network;
          if (args.wallet_id) body.walletId = args.wallet_id;
          if (args.gas_condition) {
            body.gasCondition = {
              maxGasPrice: args.gas_condition.max_gas_price,
              maxPriorityFee: args.gas_condition.max_priority_fee,
              timeout: args.gas_condition.timeout,
            };
          }
          const result = await apiClient.post('/v1/transactions/send', body);
          return toToolResult(result);
        },
      );
    }
Behavior3/5

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

No annotations provided, so description carries full burden. It discloses the authorization requirement (policy) but omits critical behavioral traits: that this creates an on-chain state-changing transaction, grants potentially unlimited spending rights, and carries security risks. 'Approve' implies mutation but explicit confirmation is absent.

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?

Two sentences with zero redundancy. First sentence establishes the core action and delegation relationship; second states the policy prerequisite. Appropriately brief for a well-documented schema.

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 100% schema coverage, the description meets minimum viability. However, for a high-stakes financial authorization tool, it lacks warnings about irreversible grants, transaction confirmation delays, or chain-specific behaviors implied by the schema (EVM vs Solana).

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%, establishing baseline 3. Description adds high-level semantic context ('on your behalf') but does not augment parameter-specific guidance beyond the comprehensive schema (e.g., no additional clarity on the max uint256 unlimited pattern or token object construction).

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 specific action ('Approve a spender') and scope ('to transfer tokens on your behalf'), distinguishing it from sibling tools like send_token (direct transfer) and transfer_nft. The language precisely targets the ERC-20/SPL approval pattern.

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?

States the prerequisite 'Requires APPROVED_SPENDERS policy' but lacks explicit guidance on when to use this versus direct transfer tools (send_token) or whether approvals can be revoked via sibling tools. The policy requirement provides some constraint but not full usage context.

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/minhoyoo-iotrust/WAIaaS'

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