Skip to main content
Glama
shufl9dka

yandex-searchapi-mcp

by shufl9dka

wordstat_get_top

Retrieve top popular and related search queries for any keyword using Yandex Wordstat data. Filter by region and device to target specific audiences.

Instructions

Get popular and related search queries for a keyword using Yandex Wordstat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
phraseYesKeyword/phrase to analyze in Wordstat.
numPhrasesNoHow many top phrases to return. Default is 20.
regionsNoOptional list of region IDs to filter statistics.
devicesNoOptional device filter: all/desktop/phone/tablet.

Implementation Reference

  • Registration of the 'wordstat_get_top' tool with input schema and handler on the MCP server.
    server.registerTool(
      "wordstat_get_top",
      {
        description:
          "Get popular and related search queries for a keyword using Yandex Wordstat.",
        inputSchema: {
          phrase: z
            .string()
            .min(1)
            .max(400)
            .describe("Keyword/phrase to analyze in Wordstat."),
          numPhrases: z
            .number()
            .int()
            .min(1)
            .max(2000)
            .optional()
            .describe("How many top phrases to return. Default is 20."),
          regions: z
            .array(z.string().min(1))
            .max(100)
            .optional()
            .describe("Optional list of region IDs to filter statistics."),
          devices: z
            .array(WordstatDeviceSchema)
            .max(3)
            .optional()
            .describe("Optional device filter: all/desktop/phone/tablet."),
        },
      },
      async ({ phrase, numPhrases, regions, devices }) => {
        return withToolErrorHandling(async () => {
          const response = await client.post<Record<string, unknown>>("/v2/wordstat/topRequests", {
            phrase,
            numPhrases: numPhrases ?? 20,
            ...(regions !== undefined ? { regions } : {}),
            ...(devices !== undefined ? { devices } : {}),
          });
    
          const structuredContent = {
            totalCount: response.totalCount,
            results: response.results,
            associations: response.associations,
          };
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(structuredContent, null, 2),
              },
            ],
            structuredContent,
          };
        });
      },
    );
  • Handler function for wordstat_get_top that calls the Yandex API endpoint /v2/wordstat/topRequests and returns structured content with totalCount, results, and associations.
    async ({ phrase, numPhrases, regions, devices }) => {
      return withToolErrorHandling(async () => {
        const response = await client.post<Record<string, unknown>>("/v2/wordstat/topRequests", {
          phrase,
          numPhrases: numPhrases ?? 20,
          ...(regions !== undefined ? { regions } : {}),
          ...(devices !== undefined ? { devices } : {}),
        });
    
        const structuredContent = {
          totalCount: response.totalCount,
          results: response.results,
          associations: response.associations,
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(structuredContent, null, 2),
            },
          ],
          structuredContent,
        };
      });
    },
  • Input schema for wordstat_get_top: phrase (required), numPhrases (optional, default 20), regions (optional array of region IDs), devices (optional array of device filters).
        phrase: z
          .string()
          .min(1)
          .max(400)
          .describe("Keyword/phrase to analyze in Wordstat."),
        numPhrases: z
          .number()
          .int()
          .min(1)
          .max(2000)
          .optional()
          .describe("How many top phrases to return. Default is 20."),
        regions: z
          .array(z.string().min(1))
          .max(100)
          .optional()
          .describe("Optional list of region IDs to filter statistics."),
        devices: z
          .array(WordstatDeviceSchema)
          .max(3)
          .optional()
          .describe("Optional device filter: all/desktop/phone/tablet."),
      },
    },
  • withToolErrorHandling helper function that wraps handler logic and converts YandexApiError to user-friendly error messages.
    async function withToolErrorHandling<T>(action: () => Promise<T>): Promise<T> {
      try {
        return await action();
      } catch (error) {
        if (error instanceof YandexApiError) {
          const detailsText =
            error.details == null ? "" : ` Details: ${JSON.stringify(error.details, null, 2)}`;
          throw new Error(`Yandex Search API error (${error.status}).${detailsText}`);
        }
        throw new Error(`Unhandled error: ${toErrorMessage(error)}`);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It only says 'get popular and related search queries', but does not disclose whether it is a read-only operation, any authentication requirements, rate limits, or other behavioral traits.

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 one short sentence, front-loaded with the key purpose. Every word is necessary and no waste.

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?

With no output schema and no annotations, the description fails to explain the return format, pagination, or what 'popular and related' means. For a tool with 4 parameters, this is insufficient.

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 all parameters are already documented in the schema. The description adds no extra meaning beyond what the schema provides. Baseline of 3 is appropriate as the schema does the heavy lifting.

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 verb 'Get', the resource 'popular and related search queries for a keyword', and the system 'Yandex Wordstat'. It distinguishes from sibling tools like wordstat_get_dynamics or web_search by specifying it returns top queries for a keyword.

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 its siblings or alternatives. There is no mention of prerequisites, use cases, 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/shufl9dka/yandex-searchapi-mcp'

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