Skip to main content
Glama
ukkz

Claude TypeScript MCP Servers

by ukkz

brave_web_search

Access current web information using Brave Search to enhance answers with up-to-date facts, news, or technical details when accuracy or freshness is required.

Instructions

Retrieves up-to-date information from the web using Brave Search. You should proactively use this tool whenever you need current information beyond your knowledge cutoff, when answering questions about recent events, when asked about specific facts you're uncertain about, or when providing comprehensive answers. Search automatically when you suspect information might be outdated or when greater detail would improve your response. Use this for news, technical information, current events, product details, or any topic where fresh, accurate data would enhance your answer quality.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of results (1-20, default 10)
offsetNoPagination offset (max 9, default 0)
queryYesSearch query (max 400 chars, 50 words)

Implementation Reference

  • Handler function registered with MCP server for executing brave_web_search tool. Validates arguments, calls performWebSearch, and returns formatted text results or error response.
    async (args) => {
      try {
        if (!isBraveWebSearchArgs(args)) {
          throw new Error("Invalid arguments for brave_web_search");
        }
        const { query, count = 10 } = args;
        const results = await performWebSearch(query, count);
        return {
          content: [{ type: "text", text: results }],
          isError: false,
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    },
  • Zod-based input schema defining parameters for brave_web_search: required query string and optional count/offset numbers.
    {
      query: z.string().describe("Search query (max 400 chars, 50 words)"),
      count: z.number().optional().describe("Number of results (1-20, default 10)"),
      offset: z.number().optional().describe("Pagination offset (max 9, default 0)"),
    },
  • Registration of the brave_web_search tool with the MCP server, specifying the tool name and description.
    server.tool(
      "brave_web_search",
      "Keyword-based web search returning a list of search results. Each result includes title, description, and URL. Best for quickly scanning multiple web pages or when you need to see diverse sources. Returns up to 20 search results as a list, not synthesized answers.",
  • Core helper function that executes the Brave Search web API request, processes the response, and formats search results as text.
    async function performWebSearch(query: string, count: number = 10, offset: number = 0) {
      checkRateLimit();
      const url = new URL("https://api.search.brave.com/res/v1/web/search");
      url.searchParams.set("q", query);
      url.searchParams.set("count", Math.min(count, 20).toString()); // API limit
      url.searchParams.set("offset", offset.toString());
    
      const response = await fetch(url, {
        headers: {
          Accept: "application/json",
          "Accept-Encoding": "gzip",
          "X-Subscription-Token": BRAVE_API_KEY,
        },
      });
    
      if (!response.ok) {
        throw new Error(
          `Brave API error: ${response.status} ${response.statusText}\n${await response.text()}`,
        );
      }
    
      const data = (await response.json()) as BraveWeb;
    
      // ウェブ検索結果のみを抽出
      const results = (data.web?.results || []).map((result) => ({
        title: result.title || "",
        description: result.description || "",
        url: result.url || "",
      }));
    
      return results
        .map((r) => `Title: ${r.title}\nDescription: ${r.description}\nURL: ${r.url}`)
        .join("\n\n");
    }
  • Type guard helper function to validate the input arguments structure for brave_web_search.
    function isBraveWebSearchArgs(args: unknown): args is { query: string; count?: number } {
      return (
        typeof args === "object" &&
        args !== null &&
        "query" in args &&
        typeof (args as { query: string }).query === "string"
      );
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool retrieves 'up-to-date information' and should be used for 'fresh, accurate data,' which implies real-time capabilities but doesn't detail rate limits, authentication needs, or error handling. It adds some context but lacks comprehensive 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.

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose. However, it includes repetitive phrases like 'when you need current information' and 'when greater detail would improve your response,' which could be more concise without losing clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (web search with three parameters) and no output schema, the description is fairly complete. It covers purpose, usage guidelines, and context, but lacks details on output format or error handling, which would enhance completeness for an agent invoking the tool.

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?

The schema description coverage is 100%, so the schema already documents all parameters (query, count, offset) with their descriptions. The tool description doesn't add any additional meaning or examples beyond what the schema provides, such as search strategy or query formatting tips, resulting in a baseline score of 3.

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 tool's purpose: 'Retrieves up-to-date information from the web using Brave Search.' It specifies the verb ('retrieves'), resource ('information from the web'), and distinguishes it from the sibling tool 'brave_local_search' by emphasizing web-based, current information rather than local data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool, listing specific scenarios such as needing current information beyond knowledge cutoff, answering questions about recent events, or when greater detail would improve responses. It also implicitly distinguishes from alternatives by focusing on web search, though it doesn't explicitly name 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

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/ukkz/claude-ts-mcps'

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