Skip to main content
Glama

search_intent_analysis

Analyze search query intent to identify user behavior, categorize topics, and generate related suggestions for SEO insights and content optimization.

Instructions

A tool for analyzing search intent and user behavior.

Features:

  • Analyze search query intent

  • Identify relevant topic categories

  • Provide search suggestions

  • Offer reference links

Examples: "iphone 15" → Product research/purchase intent "python tutorial" → Learning intent

Response format:

  • query: Original search term

  • intent: Search intention

  • categories: Related categories

  • suggestions: Related search terms

  • references: Reference links

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesEnter a search term to analyze

Implementation Reference

  • The handler function that performs the search intent analysis by calling the external API, processing the response, and returning formatted content or error.
    async ({ query }) => {
      try {
        const response = await fetch(
          "https://aisearchintent.com/api/search-intent",
          {
            method: "POST",
            headers: {
              "Content-Type": "application/json",
              Authorization: `Bearer ${getApiKey()}`,
            },
            body: JSON.stringify({ query }),
          }
        );
    
        if (!response.ok) {
          throw new Error(`API request failed: ${response.statusText}`);
        }
    
        // 解析完整的响应结构
        const apiResponse = (await response.json()) as SearchIntentApiResponse;
    
        // 验证响应状态
        if (apiResponse.code !== 0) {
          throw new Error(`API error: ${apiResponse.message}`);
        }
    
        // 直接返回数据部分的 JSON
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(apiResponse.data, null, 2),
            },
          ],
          isError: false,
          _meta: {
            latency: Date.now(),
            version: "1.0.0",
          },
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error analyzing search intent: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
          isError: true,
          _meta: {
            errorType: error instanceof Error ? error.name : "Unknown",
            timestamp: new Date().toISOString(),
          },
        };
      }
    }
  • src/index.ts:50-131 (registration)
    Registration of the 'search_intent_analysis' tool with MCP server, including description, input schema, and handler reference.
    server.tool(
      "search_intent_analysis",
      `A tool for analyzing search intent and user behavior.
    
    Features:
    - Analyze search query intent
    - Identify relevant topic categories
    - Provide search suggestions
    - Offer reference links
    
    Examples:
    "iphone 15" → Product research/purchase intent
    "python tutorial" → Learning intent
    
    Response format:
    - query: Original search term
    - intent: Search intention
    - categories: Related categories
    - suggestions: Related search terms
    - references: Reference links`,
      {
        query: z.string().describe("Enter a search term to analyze"),
      },
      async ({ query }) => {
        try {
          const response = await fetch(
            "https://aisearchintent.com/api/search-intent",
            {
              method: "POST",
              headers: {
                "Content-Type": "application/json",
                Authorization: `Bearer ${getApiKey()}`,
              },
              body: JSON.stringify({ query }),
            }
          );
    
          if (!response.ok) {
            throw new Error(`API request failed: ${response.statusText}`);
          }
    
          // 解析完整的响应结构
          const apiResponse = (await response.json()) as SearchIntentApiResponse;
    
          // 验证响应状态
          if (apiResponse.code !== 0) {
            throw new Error(`API error: ${apiResponse.message}`);
          }
    
          // 直接返回数据部分的 JSON
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(apiResponse.data, null, 2),
              },
            ],
            isError: false,
            _meta: {
              latency: Date.now(),
              version: "1.0.0",
            },
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error analyzing search intent: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
            isError: true,
            _meta: {
              errorType: error instanceof Error ? error.name : "Unknown",
              timestamp: new Date().toISOString(),
            },
          };
        }
      }
    );
  • Input schema for the tool using Zod validation for the 'query' parameter.
    {
      query: z.string().describe("Enter a search term to analyze"),
    },
  • TypeScript interface defining the structure of the API response for search intent analysis.
    interface SearchIntentApiResponse {
      code: number;
      message: string;
      data: {
        query: string;
        intent: string;
        possibleCategories: string[];
        reasoning: string;
        references: Array<{
          url: string;
          title: string;
        }>;
        groundingMetadata: {
          searchSuggestions: string[];
        };
      };
    }
  • Helper function to retrieve the API key from environment variables, used in the handler.
    function getApiKey(): string {
      const apiKey = process.env.SEARCH_INTENT_API_KEY;
      if (!apiKey) {
        console.error("SEARCH_INTENT_API_KEY environment variable is not set");
        process.exit(1);
      }
      return apiKey;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions features like analyzing intent and providing suggestions, but doesn't disclose behavioral traits such as rate limits, authentication needs, response time, or error handling. The examples and response format hint at output structure, but lack operational context.

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

Conciseness3/5

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

The description is structured with sections like Features, Examples, and Response format, but includes redundant information (e.g., listing features that are somewhat repetitive). It could be more front-loaded; the core purpose is stated upfront, but subsequent details could be streamlined to avoid duplication.

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 no annotations, no output schema, and a single parameter with full schema coverage, the description is incomplete. It lacks details on behavioral aspects, error cases, and practical usage scenarios. The response format section partially compensates, but overall, it doesn't provide enough context for reliable tool invocation.

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%, with one parameter 'query' documented as 'Enter a search term to analyze'. The description adds no additional meaning beyond this, as it doesn't elaborate on parameter constraints, formats, or examples. Baseline score of 3 is appropriate since the schema adequately covers the parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool analyzes search intent and user behavior, which provides a general purpose. However, it lacks specificity about what resources it operates on (e.g., search queries, logs) and doesn't differentiate from siblings (though none exist). The phrase 'analyzing search intent' is somewhat vague without concrete examples of what analysis entails.

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 explicit guidance is provided on when to use this tool versus alternatives. The description lists features and examples, but these don't constitute usage instructions. Without sibling tools, there's no need for differentiation, but it still fails to specify prerequisites, constraints, or ideal scenarios for invocation.

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/captainChaozi/search-intent-mcp'

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