Skip to main content
Glama

news

Search for recent news articles to gather current information and data using web search capabilities.

Instructions

Search for recent news articles using SearchClaw. Costs 1 credit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesNews search query

Implementation Reference

  • Handler function for 'news' tool - takes query parameter 'q' and makes POST request to /search/news endpoint, returning JSON-formatted results
    async ({ q }) => jsonResult(await apiPost("/search/news", { q }))
  • Input schema for 'news' tool using Zod - defines single required string parameter 'q' (news search query)
    { q: z.string().describe("News search query") },
  • src/index.ts:86-91 (registration)
    Registration of 'news' tool with McpServer - defines tool name, description, input schema, and handler function
    server.tool(
      "news",
      "Search for recent news articles using SearchClaw. Costs 1 credit.",
      { q: z.string().describe("News search query") },
      async ({ q }) => jsonResult(await apiPost("/search/news", { q }))
    );
  • jsonResult helper function - formats API response data into MCP content format with JSON stringification
    function jsonResult(data: unknown) {
      return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
    }
  • apiPost helper function - makes POST requests to SearchClaw API with 30s timeout, API key authentication, and error handling
    async function apiPost(path: string, body: Record<string, unknown>) {
      const controller = new AbortController();
      const timeout = setTimeout(() => controller.abort(), 30000);
      try {
        const response = await fetch(`${API_BASE}${path}`, {
          method: "POST",
          headers: { ...headers, "Content-Type": "application/json" },
          body: JSON.stringify(body),
          signal: controller.signal,
        });
        if (!response.ok) {
          const text = await response.text();
          throw new Error(`SearchClaw API error ${response.status}: ${text}`);
        }
        return response.json();
      } finally {
        clearTimeout(timeout);
      }
    }

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/CSteenkamp/searchclaw-mcp'

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