Skip to main content
Glama
fatwang2

Search1API MCP Server

trending

Fetch trending topics from GitHub or HackerNews. Specify the platform and maximum results to retrieve.

Instructions

Get trending topics from popular platforms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_serviceYesSpecify the platform to get trending topics fromgithub
max_resultsNoMaximum number of trending items to return

Implementation Reference

  • Handler function that validates trending arguments, makes API request to the /trending endpoint, and returns results (or error)
    export async function handleTrending(args: unknown, apiKey?: string) {
      if (!isValidTrendingArgs(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Invalid trending arguments"
        );
      }
    
      try {
        const response = await makeRequest<TrendingResponse>(
          API_CONFIG.ENDPOINTS.TRENDING,
          args,
          apiKey
        );
    
        return {
          content: [{
            type: "text",
            mimeType: "application/json",
            text: JSON.stringify(response.results, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            mimeType: "text/plain",
            text: `Trending API error: ${formatError(error)}`
          }],
          isError: true
        };
      }
    } 
  • TrendingArgs interface with search_service and optional max_results
    export interface TrendingArgs {
      search_service: TrendingService;
      max_results?: number;
    }
  • Validation function for trending arguments
    export function isValidTrendingArgs(args: unknown): args is TrendingArgs {
      if (typeof args !== 'object' || args === null) {
        return false;
      }
    
      const { search_service, max_results } = args as TrendingArgs;
    
      if (search_service === undefined) {
        return false;
      }
    
      const validServices = Object.values(TrendingService);
      if (!validServices.includes(search_service)) {
        return false;
      }
    
      if (max_results !== undefined && (typeof max_results !== 'number' || max_results < 1 || max_results > 50)) {
        return false;
      }
    
      return true;
    }
  • Tool definition registration with name 'trending', description, and input schema
    // Trending tool definition
    export const TRENDING_TOOL: Tool = {
      name: "trending",
      description: "Get trending topics from popular platforms",
      inputSchema: {
        type: "object",
        properties: {
          search_service: {
            type: "string",
            description: "Specify the platform to get trending topics from",
            enum: ["github", "hackernews"],
            default: "github"
          },
          max_results: {
            type: "number",
            description: "Maximum number of trending items to return",
            default: 10
          }
        },
        required: ["search_service"]
      }
    };
  • Handler dispatch that routes trending tool calls to handleTrending function
    import { handleTrending } from './trending.js';
    import { SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, REASONING_TOOL, TRENDING_TOOL } from './index.js';
    
    /**
     * Dispatch request based on tool name
     * @param toolName Name of the tool
     * @param args Tool parameters
     * @param apiKey Optional per-session API key
     * @returns Tool processing result
     */
    export async function handleToolCall(toolName: string, args: unknown, apiKey?: string) {
      log(`Handling tool call: ${toolName}`);
    
      switch (toolName) {
        case SEARCH_TOOL.name:
          return await handleSearch(args, apiKey);
    
        case CRAWL_TOOL.name:
          return await handleCrawl(args, apiKey);
    
        case SITEMAP_TOOL.name:
          return await handleSitemap(args, apiKey);
    
        case NEWS_TOOL.name:
          return await handleNews(args, apiKey);
    
        case REASONING_TOOL.name:
          return await handleReasoning(args, apiKey);
    
        case TRENDING_TOOL.name:
          return await handleTrending(args, apiKey);
    
        default:
          log(`Unknown tool: ${toolName}`);
          throw new McpError(
            ErrorCode.InvalidParams,
            `Unknown tool: ${toolName}`
          );
      }
    }
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as rate limits, data freshness, authentication needs, or whether the operation is read-only. The description simply states it gets trending topics.

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, efficient sentence that conveys the core purpose. It is front-loaded and avoids unnecessary words, though it lacks some detail.

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?

For a simple tool with two parameters and no output schema, the description is moderately complete. It misses usage context and behavioral details, but the schema provides parameter info.

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 the schema already documents parameters. The description adds no extra meaning beyond what's in the schema, resulting in baseline score.

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 uses a specific verb 'get' and resource 'trending topics', and mentions 'popular platforms', which combined with the schema clarifies the scope. However, it does not explicitly list the platforms (GitHub, Hacker News), but the schema covers that.

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 alternatives like 'news' or 'search'. It does not state prerequisites or exclude any contexts.

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/fatwang2/search1api-mcp'

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