Skip to main content
Glama

set_token_authority

Change or revoke authority for Solana token mints and accounts to manage permissions like minting tokens, freezing accounts, or transferring ownership.

Instructions

Set or change authority for a token mint or account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletNameYesName of the wallet with current authority
tokenMintYesToken mint address
authorityTypeYesType of authority to set
newAuthorityNoAddress of new authority (or null to revoke authority)

Implementation Reference

  • The main handler function that implements the set_token_authority tool logic. It retrieves the wallet, ensures Solana connection, maps string authorityType to AuthorityType enum, and calls setAuthority from @solana/spl-token library to change the authority on the token mint.
    async function handleSetTokenAuthority(args: any) { const { walletName, tokenMint, authorityType, newAuthority } = args; const wallet = wallets.get(walletName); if (!wallet) { throw new Error(`Wallet '${walletName}' not found`); } ensureConnection(); const tokenMintPubkey = new PublicKey(tokenMint); const newAuthorityPubkey = newAuthority ? new PublicKey(newAuthority) : null; const authorityTypeMap: { [key: string]: AuthorityType } = { "MintTokens": AuthorityType.MintTokens, "FreezeAccount": AuthorityType.FreezeAccount, "AccountOwner": AuthorityType.AccountOwner, "CloseAccount": AuthorityType.CloseAccount }; const signature = await setAuthority( connection, wallet.keypair, tokenMintPubkey, wallet.keypair, authorityTypeMap[authorityType], newAuthorityPubkey ); return { success: true, signature, authorityType, newAuthority: newAuthority || "revoked", explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
  • Input schema (JSON Schema) for validating tool arguments: requires walletName, tokenMint, authorityType (enum: MintTokens, FreezeAccount, AccountOwner, CloseAccount); optional newAuthority.
    inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet with current authority" }, tokenMint: { type: "string", description: "Token mint address" }, authorityType: { type: "string", enum: ["MintTokens", "FreezeAccount", "AccountOwner", "CloseAccount"], description: "Type of authority to set" }, newAuthority: { type: "string", description: "Address of new authority (or null to revoke authority)" } }, required: ["walletName", "tokenMint", "authorityType"] }
  • src/index.ts:417-443 (registration)
    Tool registration in the global tools array returned by ListToolsRequest handler, defining name, description, and inputSchema.
    { name: "set_token_authority", description: "Set or change authority for a token mint or account", inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet with current authority" }, tokenMint: { type: "string", description: "Token mint address" }, authorityType: { type: "string", enum: ["MintTokens", "FreezeAccount", "AccountOwner", "CloseAccount"], description: "Type of authority to set" }, newAuthority: { type: "string", description: "Address of new authority (or null to revoke authority)" } }, required: ["walletName", "tokenMint", "authorityType"] } },
  • src/index.ts:1345-1347 (registration)
    Runtime dispatch registration in the CallToolRequest switch statement, mapping tool name to the corresponding handler function.
    case "set_token_authority": result = await handleSetTokenAuthority(args); break;

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/ExpertVagabond/solana-mcp-server'

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