Skip to main content
Glama

tokens_send_near

Send NEAR tokens from a signer account to a receiver account. Specify the amount in NEAR and choose between testnet or mainnet.

Instructions

Send NEAR tokens to an account (in NEAR). The signer account is the sender of the tokens, and the receiver account is the recipient of the tokens. Remember mainnet accounts are created with a .near suffix, and testnet accounts are created with a .testnet suffix. The user is sending tokens as the signer account. Please ensure that the sender and receiver accounts are in the same network.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
signerAccountIdYes
receiverAccountIdYes
amountNoThe amount of NEAR to send in NEAR. e.g. 1.5
networkIdNomainnet

Implementation Reference

  • The 'tokens_send_near' tool registration and handler implementation. This tool sends NEAR tokens from a signer account to a receiver account. It uses mcp.tool() to register with name 'tokens_send_near', defines a Zod schema for signerAccountId, receiverAccountId, amount (union of number/bigint), and networkId. The handler connects to the NEAR network, converts the amount to yoctoNEAR using NearToken, and calls account.sendMoney() to execute the transfer.
    mcp.tool(
      'tokens_send_near',
      noLeadingWhitespace`
      Send NEAR tokens to an account (in NEAR). The signer account
      is the sender of the tokens, and the receiver account is the
      recipient of the tokens. Remember mainnet accounts are
      created with a .near suffix, and testnet accounts are created
      with a .testnet suffix. The user is sending tokens as the signer
      account. Please ensure that the sender and receiver accounts
      are in the same network.`,
      {
        signerAccountId: z.string(),
        receiverAccountId: z.string(),
        amount: z
          .union([
            z.number().describe('The amount of NEAR tokens (in NEAR)'),
            z.bigint().describe('The amount in yoctoNEAR'),
          ])
          .default(NearToken.parse_yocto_near('1').as_near())
          .describe('The amount of NEAR to send in NEAR. e.g. 1.5'),
        networkId: z.enum(['testnet', 'mainnet']).default('mainnet'),
      },
      async (args, _) => {
        const connection = await connect({
          networkId: args.networkId,
          keyStore: keystore,
          nodeUrl: getEndpointsByNetwork(args.networkId)[0]!,
        });
        const sendResult: Result<FinalExecutionOutcome, Error> =
          await (async () => {
            try {
              const account = await connection.account(args.signerAccountId);
              const amount =
                typeof args.amount === 'number'
                  ? NearToken.parse_near(args.amount.toString()).as_yocto_near()
                  : args.amount;
              const sendMoneyResult = await account.sendMoney(
                args.receiverAccountId,
                amount,
              );
              return {
                ok: true,
                value: sendMoneyResult,
              };
            } catch (e) {
              return { ok: false, error: new Error(e as string) };
            }
          })();
        if (!sendResult.ok) {
          return {
            content: [{ type: 'text', text: `Error: ${sendResult.error}` }],
          };
        }
        return {
          content: [
            {
              type: 'text',
              text: `Transaction sent: ${stringify_bigint(sendResult.value)}`,
            },
          ],
        };
      },
    );
  • Schema definition for the 'tokens_send_near' tool: requires signerAccountId (string), receiverAccountId (string), amount (union of number for NEAR or bigint for yoctoNEAR, defaulting to 1 NEAR), and networkId (enum testnet/mainnet, default mainnet).
    mcp.tool(
      'tokens_send_near',
      noLeadingWhitespace`
      Send NEAR tokens to an account (in NEAR). The signer account
      is the sender of the tokens, and the receiver account is the
      recipient of the tokens. Remember mainnet accounts are
      created with a .near suffix, and testnet accounts are created
      with a .testnet suffix. The user is sending tokens as the signer
      account. Please ensure that the sender and receiver accounts
      are in the same network.`,
      {
        signerAccountId: z.string(),
        receiverAccountId: z.string(),
        amount: z
          .union([
            z.number().describe('The amount of NEAR tokens (in NEAR)'),
            z.bigint().describe('The amount in yoctoNEAR'),
          ])
          .default(NearToken.parse_yocto_near('1').as_near())
          .describe('The amount of NEAR to send in NEAR. e.g. 1.5'),
        networkId: z.enum(['testnet', 'mainnet']).default('mainnet'),
      },
  • The createMcpServer function is where all MCP tools including 'tokens_send_near' are registered via mcp.tool() calls. It's defined on line 411 and returns the mcp object with registered tools. The tokens_send_near registration is specifically at line 1619-1681.
    export const createMcpServer = async (keyDir: string) => {
      const keystore = new UnencryptedFileSystemKeyStore(keyDir);
      const mcp = new McpServer(
        {
          name: MCP_SERVER_NAME,
          version: '1.0.0',
        },
        {
          capabilities: {
            logging: {},
          },
          instructions: noLeadingWhitespace`
          # NEAR MCP Server
    
          Welcome to the NEAR Model Context Protocol (MCP) Server. This server provides a bridge
          between AI models and the NEAR blockchain ecosystem.
    
          ## What is NEAR?
    
          [NEAR](https://near.org/) is a layer-1 blockchain designed for usability and scalability. It features a
          proof-of-stake consensus mechanism, sharding for scalability, and developer-friendly
          tools for building decentralized applications.
    
          ## What this MCP server does:
    
          This server provides a way to interact with the NEAR blockchain through natural language interfaces. It enables:
          - Account management: Import, export, and manage NEAR accounts
          - Token operations: Send and receive NEAR tokens and NEAR Fungible Tokens (FTs)
          - Contract interactions: Query and interact with smart contracts on the NEAR blockchain
    
          ## Use cases:
    
          - Wallet management through conversational interfaces
          - Token transfers via natural language commands
          - Smart contract interactions without requiring technical blockchain knowledge
          - Blockchain data querying and analysis
          - Educational tool for learning about NEAR blockchain operations
    
          ## Guidelines
    
          - When a user refers to the USDC token, they commonly refer to the USDC native token.
          - When a user refers to the USDT token, they commonly refer to the USDT native token.
    
          ## Extra information
    
          This server is powered by the NEAR API SDK and serves as a bridge between AI assistants and the NEAR blockchain ecosystem.
        `,
        },
      );
Behavior2/5

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

With no annotations provided, the description carries full burden. It mentions signer as sender and network constraints, but lacks disclosure on destructive nature, required permissions, return value, or error cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise at 4 sentences with no redundancy, though structure could be improved with bullet points for clarity.

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?

For a tool with 4 parameters, no output schema, and no annotations, the description is adequate but missing guidance on error handling, preconditions (balance), and return values.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite only 25% schema description coverage, the description adds meaning for signerAccountId, receiverAccountId, and networkId by explaining roles and network suffixes, compensating for the schema gap.

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 action ('Send NEAR tokens'), the resource (NEAR tokens in NEAR), and distinguishes from sibling tools like tokens_send_ft which sends fungible tokens.

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?

The description provides context on account network consistency and suffixes, but does not explicitly state when to use this tool versus alternatives or when not to use it.

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/nearai/near-mcp'

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