undelegate
Remove staked tokens from a validator on the MantraChain network using the MantraChain MCP Server. Specify the validator address, token amount, and network name to execute the undelegation process.
Instructions
Undelegate/Unstake tokens from a validator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount of tokens to undelegate | |
| denom | No | Optional denomination of the tokens, default is network's default denom | |
| memo | No | Optional memo for the transaction | |
| networkName | Yes | Name of the network to use - must first check what networks are available through the mantrachain-mcp server by accessing the networks resource `networks://all` before you pass this arguments | |
| operatorAddress | Yes | Address of the validator to undelegate from |
Implementation Reference
- src/tools/staking.ts:51-65 (handler)The handler function for the MCP 'undelegate' tool. It initializes the MantraClient for the given network and invokes undelegateTokens with the input parameters, returning the transaction result as JSON.async ({ operatorAddress, amount, denom, networkName, memo }) => { await mantraClient.initialize(networkName); const result = await mantraClient.undelegateTokens({ operatorAddress, amount, denom, memo }); return { content: [{type: "text", text: JSON.stringify(result)}], }; }
- src/tools/staking.ts:42-50 (schema)Input schema for the 'undelegate' tool using Zod validation for parameters: operatorAddress, amount, denom (optional), networkName, and memo (optional).{ operatorAddress: z.string().describe("Address of the validator to undelegate from"), amount: z.string().describe("Amount of tokens to undelegate"), denom: z.string().optional().describe("Optional denomination of the tokens, default is network's default denom"), networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), memo: z.string().optional().describe("Optional memo for the transaction") },
- src/tools/staking.ts:38-66 (registration)Registration of the 'undelegate' MCP tool on the McpServer, including name, description, input schema, and handler function.// Define undelegate tool server.tool( "undelegate", "Undelegate/Unstake tokens from a validator", { operatorAddress: z.string().describe("Address of the validator to undelegate from"), amount: z.string().describe("Amount of tokens to undelegate"), denom: z.string().optional().describe("Optional denomination of the tokens, default is network's default denom"), networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), memo: z.string().optional().describe("Optional memo for the transaction") }, async ({ operatorAddress, amount, denom, networkName, memo }) => { await mantraClient.initialize(networkName); const result = await mantraClient.undelegateTokens({ operatorAddress, amount, denom, memo }); return { content: [{type: "text", text: JSON.stringify(result)}], }; } );