Skip to main content
Glama

account_verify_signature

Verify cryptographic signatures against a NEAR account's public key to authenticate signed data.

Instructions

Cryptographically verify a signed piece of data against a NEAR account's public key.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesThe account id to verify the signature against and search for a valid public key.
networkIdNomainnet
dataYesThe data to verify.
signatureArgsYesThe signature arguments to verify.

Implementation Reference

  • The tool 'account_verify_signature' is registered using mcp.tool('account_verify_signature', ...) in the createMcpServer function.
    mcp.tool(
  • The handler function containing the entire implementation of the account_verify_signature tool. It verifies a cryptographic signature against a NEAR account's public keys by looking up the account's access keys.
      'account_verify_signature',
      noLeadingWhitespace`
      Cryptographically verify a signed piece of data against a NEAR account's public key.`,
      {
        accountId: z
          .string()
          .describe(
            'The account id to verify the signature against and search for a valid public key.',
          ),
        networkId: z.enum(['testnet', 'mainnet']).default('mainnet'),
        data: z.string().describe('The data to verify.'),
        signatureArgs: z
          .object({
            curve: z.string().describe('The curve used on the signature.'),
            signatureData: z
              .string()
              .describe(
                'The signature data to verify. Only the encoded signature data is required.',
              ),
            encoding: z
              .enum(['base58', 'base64'])
              .default('base58')
              .describe('The encoding used on the signature.'),
          })
          .describe('The signature arguments to verify.'),
      },
      async (args, _) => {
        const connection = await connect({
          networkId: args.networkId,
          nodeUrl: getEndpointsByNetwork(args.networkId)[0]!,
        });
        const accountResult: Result<Account, Error> = await getAccount(
          args.accountId,
          connection,
        );
        if (!accountResult.ok) {
          return {
            content: [{ type: 'text', text: `Error: ${accountResult.error}` }],
          };
        }
        const accessKeys = await accountResult.value.getAccessKeys();
    
        const message = new TextEncoder().encode(args.data);
        const signatureParsedResult: Result<
          [KeyType, Uint8Array<ArrayBufferLike>],
          Error
        > = (() => {
          try {
            const curveResult = curvePrefixToKeyType(args.signatureArgs.curve);
            if (!curveResult.ok) {
              return curveResult;
            }
            const curve = curveResult.value;
    
            switch (args.signatureArgs.encoding) {
              case 'base64':
                return {
                  ok: true,
                  value: [
                    curve,
                    Buffer.from(args.signatureArgs.signatureData, 'base64'),
                  ],
                };
              case 'base58':
                return {
                  ok: true,
                  value: [curve, base58.decode(args.signatureArgs.signatureData)],
                };
              default:
                throw new Error(
                  `Unsupported encoding: ${String(args.signatureArgs.encoding)}`,
                );
            }
          } catch (e) {
            return { ok: false, error: new Error(e as string) };
          }
        })();
        if (!signatureParsedResult.ok) {
          return {
            content: [
              {
                type: 'text',
                text: `Unable to parse signature: ${signatureParsedResult.error}`,
              },
            ],
          };
        }
        const [curve, signature] = signatureParsedResult.value;
    
        const matchingPublicKeyCurveType = accessKeys.find(
          (key) => PublicKey.fromString(key.public_key).keyType === curve,
        );
        if (!matchingPublicKeyCurveType) {
          return {
            content: [
              {
                type: 'text',
                text: `Error: Unable to find a valid public key for the account ${args.accountId} with curve ${curve}`,
              },
            ],
          };
        }
    
        const matchingPublicKey = accessKeys.find((key) =>
          PublicKey.fromString(key.public_key).verify(message, signature),
        );
        if (!matchingPublicKey) {
          return {
            content: [
              {
                type: 'text',
                text: `Unable to find a valid public key for the account ${args.accountId}`,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: stringify_bigint({
                message: 'Found matching public key for signature verification.',
                publicKey: matchingPublicKey,
              }),
            },
          ],
        };
      },
    );
  • The input schema for account_verify_signature defined using Zod. Accepts accountId, networkId, data (string to verify), and signatureArgs (curve, signatureData, encoding).
    {
      accountId: z
        .string()
        .describe(
          'The account id to verify the signature against and search for a valid public key.',
        ),
      networkId: z.enum(['testnet', 'mainnet']).default('mainnet'),
      data: z.string().describe('The data to verify.'),
      signatureArgs: z
        .object({
          curve: z.string().describe('The curve used on the signature.'),
          signatureData: z
            .string()
            .describe(
              'The signature data to verify. Only the encoded signature data is required.',
            ),
          encoding: z
            .enum(['base58', 'base64'])
            .default('base58')
            .describe('The encoding used on the signature.'),
        })
        .describe('The signature arguments to verify.'),
    },
  • Helper function curvePrefixToKeyType used to convert a curve prefix string (like 'ed25519' or 'secp256k1') to a KeyType enum value, used in parsing the signature curve.
    export const curvePrefixToKeyType = (
      curvePrefix: string,
    ): Result<KeyType, Error> => {
      switch (curvePrefix.toLowerCase()) {
        case 'ed25519':
          return { ok: true, value: KeyType.ED25519 };
        case 'secp256k1':
          return { ok: true, value: KeyType.SECP256K1 };
        default:
          return {
            ok: false,
            error: new Error(`Unsupported curve prefix: ${curvePrefix}`),
          };
      }
    };
Behavior2/5

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

With no annotations, the description must disclose behavioral traits. It only states the operation without mentioning side effects (likely none), return values, or error handling. The agent cannot infer whether this is a read-only call or what happens on failure.

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 a single concise sentence that efficiently communicates the core purpose. However, it could be slightly expanded to include key behavioral details without becoming verbose.

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 lack of output schema and the complexity of a cryptographic verification tool, the description is insufficient. It omits expected return type (e.g., boolean result) and any assumptions about the signature format beyond what's in the schema.

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 75%, so baseline is 3. The description adds no extra information about parameters beyond what the schema already provides, such as constraints or relationships between accountId, data, and signatureArgs.

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 uses a specific verb 'verify' and clearly states the resource 'a signed piece of data against a NEAR account's public key'. It distinctly sets the tool apart from its sibling 'account_sign_data' which performs the opposite operation.

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?

No guidance is provided on when to use this tool versus alternatives, nor are there any preconditions or context for usage. For example, it does not mention that the account's public key must be available or that verification is typically done after signing.

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