Skip to main content
Glama

tokens_send_near

Transfer NEAR tokens between accounts on the NEAR blockchain. Specify sender, receiver, and amount, ensuring both accounts are on the same network (mainnet or testnet).

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
amountNoThe amount of NEAR to send in NEAR. e.g. 1.5
networkIdNomainnet
receiverAccountIdYes
signerAccountIdYes

Implementation Reference

  • Handler function that connects to the NEAR network, retrieves the signer account, converts the amount to yoctoNEAR if necessary, calls account.sendMoney to transfer NEAR tokens to the receiver, and returns the transaction outcome or error.
    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)}`,
          },
        ],
      };
    },
  • Input schema using Zod for validating parameters: signerAccountId (string), receiverAccountId (string), amount (union of number in NEAR or bigint in yoctoNEAR, default 1 yoctoNEAR), networkId (enum testnet/mainnet, default mainnet).
      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'),
    },
  • Registration of the 'tokens_send_near' tool on the MCP server with name, description, input schema, and handler function.
    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)}`,
            },
          ],
        };
      },
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clarifies that this is a transactional send operation (implying mutation and potential costs), mentions network constraints, and specifies the signer as the sender. However, it omits critical details like authentication requirements, rate limits, error conditions, or whether the operation is irreversible, which are important for a token transfer tool.

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 appropriately sized and front-loaded, starting with the core purpose. Sentences are efficient, with no redundant information, though it could be slightly more structured (e.g., bullet points for constraints). Overall, it conveys key points without unnecessary elaboration.

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 the complexity of a token transfer tool with no annotations and no output schema, the description is moderately complete. It covers the basic operation, network constraints, and parameter roles, but lacks details on authentication, error handling, return values, or security implications, which are crucial for safe invocation by an AI agent.

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 low at 25%, with only the 'amount' parameter documented in the schema. The description adds some context by explaining that 'signerAccountId' is the sender and 'receiverAccountId' is the recipient, and it hints at 'networkId' usage through suffix examples. However, it doesn't fully compensate for the coverage gap, as parameters like exact formats or validation rules remain unclear.

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 ('Send NEAR tokens') and the resource ('to an account'), making the purpose evident. It distinguishes this tool from sibling 'tokens_send_ft' by specifying NEAR tokens rather than fungible tokens, though it doesn't explicitly contrast them. The description avoids tautology by elaborating beyond the tool name.

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 implies usage context by mentioning network consistency ('same network') and account suffixes ('.near' for mainnet, '.testnet' for testnet), which helps guide when to use this tool. However, it lacks explicit guidance on alternatives (e.g., when to use 'tokens_send_ft' instead) or prerequisites, leaving some ambiguity for the agent.

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

Related 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