Skip to main content
Glama

search_near_fungible_tokens

Search for NEAR fungible token contracts by account ID, symbol, or name. Use specific terms to avoid excessive results.

Instructions

Search for fungible token contract information for the NEAR blockchain, based on search terms. This tool works by 'grepping' through a list of contract information JSON objects. Be careful with this tool, it can return a lot of results. Ensure that your query is specific.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIDSearchTermNoThe grep-like search term to use for finding fungible token contract information by account ID.
symbolSearchTermNoThe grep-like search term to use for finding fungible token contract information by symbol.
nameSearchTermNoThe grep-like search term to use for finding fungible token contract information by name.
maxNumberOfResultsNoThe maximum number of results to return. This is a limit to the number of results returned by the API. Keep this number low to avoid overwhelming the API.

Implementation Reference

  • Registration and handler for the 'search_near_fungible_tokens' MCP tool. Defined via mcp.tool() with schema for accountIDSearchTerm, symbolSearchTerm, nameSearchTerm, and maxNumberOfResults. The handler calls searchFungibleTokens() then enriches results with getFungibleTokenContractInfo().
      'search_near_fungible_tokens',
      noLeadingWhitespace`
      Search for fungible token contract information for the NEAR blockchain, based on search terms.
      This tool works by 'grepping' through a list of contract information JSON objects. Be careful
      with this tool, it can return a lot of results. Ensure that your query is specific.`,
      {
        accountIDSearchTerm: z
          .string()
          .optional()
          .describe(
            'The grep-like search term to use for finding fungible token contract information by account ID.',
          ),
        symbolSearchTerm: z
          .string()
          .optional()
          .describe(
            'The grep-like search term to use for finding fungible token contract information by symbol.',
          ),
        nameSearchTerm: z
          .string()
          .optional()
          .describe(
            'The grep-like search term to use for finding fungible token contract information by name.',
          ),
        maxNumberOfResults: z
          .number()
          .min(1)
          .max(8)
          .default(4)
          .describe(
            'The maximum number of results to return. This is a limit to the number of results returned by the API. Keep this number low to avoid overwhelming the API.',
          ),
      },
      async (args, __) => {
        const tokenContractsSearchResult = await searchFungibleTokens(
          args.accountIDSearchTerm,
          args.symbolSearchTerm,
          args.nameSearchTerm,
          args.maxNumberOfResults,
        );
        if (!tokenContractsSearchResult.ok) {
          return {
            content: [
              {
                type: 'text',
                text: `Error: ${tokenContractsSearchResult.error}`,
              },
            ],
          };
        }
        const tokenContracts = tokenContractsSearchResult.value;
    
        // get the contract info for each contract
        const contractInfoResults = await mapSemaphore(
          tokenContracts,
          4,
          async (
            contract,
          ): Promise<[string, FungibleTokenContract, Result<object, Error>]> => {
            return [
              contract.contract,
              contract,
              await getFungibleTokenContractInfo(contract.contract),
            ];
          },
        );
    
        const contractInfos = contractInfoResults.map(
          ([_, contract, contractInfoResult]) => {
            if (contractInfoResult.ok) {
              return contractInfoResult.value;
            } else {
              return contract;
            }
          },
        );
    
        return {
          content: [
            {
              type: 'text',
              text: stringify_bigint(contractInfos),
            },
          ],
        };
      },
    );
  • The searchFungibleTokens helper function that fetches token list from https://api.ref.finance/list-token, filters by accountID, symbol, and name using case-insensitive regex, and returns up to maxNumberOfResults matching FungibleTokenContract entries.
    export const searchFungibleTokens = async (
      accountIDSearchTerm: string | undefined,
      symbolSearchTerm: string | undefined,
      nameSearchTerm: string | undefined,
      maxNumberOfResults: number,
    ): Promise<Result<FungibleTokenContract[], Error>> => {
      try {
        const url = 'https://api.ref.finance/list-token';
        const response = await fetch(url);
        const data = (await response.json()) as Record<
          string,
          {
            spec: string;
            name: string;
            symbol: string;
            icon: string;
            reference: string;
            reference_hash: string;
            decimals: number;
          }
        >;
        if (!Object.keys(data).length) {
          return {
            ok: false,
            error: new Error('No tokens found'),
          };
        }
    
        // Filter tokens based on search term
        const filteredTokens = Object.entries(data)
          .filter(([contractId, tokenInfo]) => {
            // filter by account ID
            if (
              accountIDSearchTerm &&
              !new RegExp(accountIDSearchTerm, 'i').test(contractId)
            ) {
              return false;
            }
    
            // filter by symbol
            if (
              symbolSearchTerm &&
              !new RegExp(symbolSearchTerm, 'i').test(tokenInfo.symbol)
            ) {
              return false;
            }
    
            // filter by name
            if (
              nameSearchTerm &&
              !new RegExp(nameSearchTerm, 'i').test(tokenInfo.name)
            ) {
              return false;
            }
    
            return true;
          })
          .slice(0, maxNumberOfResults)
          .map(([contractId, tokenInfo]) => ({
            contract: contractId,
            ...tokenInfo,
          }));
    
        if (filteredTokens.length === 0) {
          return {
            ok: false,
            error: new Error('No matching tokens found'),
          };
        }
    
        return {
          ok: true,
          value: filteredTokens,
        };
      } catch (error) {
        return { ok: false, error: error as Error };
      }
    };
  • Zod schema for the tool's input parameters: optional accountIDSearchTerm, symbolSearchTerm, nameSearchTerm strings, and maxNumberOfResults number (min 1, max 8, default 4).
      accountIDSearchTerm: z
        .string()
        .optional()
        .describe(
          'The grep-like search term to use for finding fungible token contract information by account ID.',
        ),
      symbolSearchTerm: z
        .string()
        .optional()
        .describe(
          'The grep-like search term to use for finding fungible token contract information by symbol.',
        ),
      nameSearchTerm: z
        .string()
        .optional()
        .describe(
          'The grep-like search term to use for finding fungible token contract information by name.',
        ),
      maxNumberOfResults: z
        .number()
        .min(1)
        .max(8)
        .default(4)
        .describe(
          'The maximum number of results to return. This is a limit to the number of results returned by the API. Keep this number low to avoid overwhelming the API.',
        ),
    },
Behavior3/5

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

Discloses that the tool uses 'grepping' and can return many results, which is helpful. However, no annotations exist, and the description omits whether it is read-only, idempotent, or requires authentication.

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?

Two sentences with no fluff. First sentence states purpose; second adds critical usage advice. Front-loaded and efficient.

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?

Lacks output schema explanation; does not describe return format or that results are a list. For a search tool, this omission reduces completeness. Also does not clarify if it is read-only.

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 coverage is 100% with clear parameter descriptions. The description adds the 'grepping' analogy and a warning about query specificity, but does not significantly enhance understanding beyond the schema.

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?

Clearly states verb (search), resource (fungible token contract info), and context (NEAR blockchain). Distinguishes from siblings like tokens_send_ft or ref_finance_* by focusing on searching contract metadata.

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?

Implies that users should be specific to avoid too many results, but does not give explicit when-to-use or alternatives. No mention of when not to use compared to other tools.

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