Skip to main content
Glama
Jake-loranger

Algorand MCP Server

opt_in_to_asset

Enable an Algorand account to receive a specific blockchain asset by providing the account mnemonic and asset ID. This tool facilitates asset management on the Algorand network.

Instructions

Opt into an Algorand Standard Asset

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountMnemonicYesAccount mnemonic phrase (25 words)
assetIdYesAsset ID to opt into

Implementation Reference

  • The core handler function `optInToAsset` in the AlgorandService class that implements the asset opt-in by creating a zero-amount asset transfer transaction from the account to itself, signing it, sending it, and waiting for confirmation.
    async optInToAsset(accountMnemonic: string, assetId: number) {
        try {
            const account = this.importAccountFromMnemonic(accountMnemonic);
            const suggestedParams = await this.algodClient.getTransactionParams().do();
    
            const txn = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({
                sender: account.addr,
                receiver: account.addr,
                amount: 0,
                assetIndex: assetId,
                suggestedParams,
            });
    
            const signedTxn = txn.signTxn(account.sk);
            const response = await this.algodClient.sendRawTransaction(signedTxn).do();
            const txId = response.txid || txn.txID();
    
            // Wait for confirmation
            const result = await algosdk.waitForConfirmation(this.algodClient, txId, 4);
    
            return {
                txId,
                confirmedRound: result.confirmedRound,
            };
        } catch (error) {
            throw new Error(`Asset opt-in failed: ${error}`);
        }
    }
  • Zod schema for input validation of the tool arguments: accountMnemonic (string) and assetId (number).
    const OptInToAssetArgsSchema = z.object({
        accountMnemonic: z.string(),
        assetId: z.number(),
    });
  • src/index.ts:247-264 (registration)
    MCP tool registration in the TOOLS array, defining the name, description, and JSON inputSchema for the opt_in_to_asset tool.
    {
        name: 'opt_in_to_asset',
        description: 'Opt into an Algorand Standard Asset',
        inputSchema: {
            type: 'object',
            properties: {
                accountMnemonic: {
                    type: 'string',
                    description: 'Account mnemonic phrase (25 words)',
                },
                assetId: {
                    type: 'number',
                    description: 'Asset ID to opt into',
                },
            },
            required: ['accountMnemonic', 'assetId'],
        },
    },
  • Top-level MCP server handler for the tool: parses args with schema, calls the service handler, formats success/error response.
    case 'opt_in_to_asset': {
        const parsed = OptInToAssetArgsSchema.parse(args);
        try {
            const result = await algorandService.optInToAsset(
                parsed.accountMnemonic,
                parsed.assetId
            );
            return {
                content: [
                    {
                        type: 'text',
                        text: `Asset Opt-in Successful!\nAsset ID: ${parsed.assetId}\nTransaction ID: ${result.txId}\nConfirmed in Round: ${result.confirmedRound}`,
                    },
                ],
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Asset opt-in failed: ${error}`,
                    },
                ],
                isError: true,
            };
        }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but lacks critical details: it doesn't specify if this is a read-only or destructive operation, what permissions or authentication are needed (beyond the mnemonic parameter), potential side effects (e.g., transaction fees, account state changes), or error conditions. This leaves significant gaps for safe tool invocation.

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 a single, direct sentence with zero wasted words. It's appropriately sized for a simple tool and front-loaded with the core purpose, making it highly efficient and easy to parse.

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

Completeness2/5

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

Given the complexity (a financial/blockchain operation with no annotations and no output schema), the description is incomplete. It doesn't explain what 'opting in' entails behaviorally (e.g., a blockchain transaction), what the expected output or success indicators are, or error handling. For a tool that likely modifies account state, this lack of context is a significant gap.

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 input schema fully documents both parameters (accountMnemonic and assetId). The description adds no additional parameter semantics beyond what's in the schema, such as format examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Opt into') and resource ('an Algorand Standard Asset'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'transfer_asset' or 'create_asset' by specifying this is specifically for adding an asset to an account's holdings rather than creating or transferring assets.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing asset and account), exclusions, or comparisons to siblings like 'transfer_asset' or 'get_asset_info'. The agent must infer usage from context alone.

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/Jake-loranger/algorand-mcp-server'

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