Skip to main content
Glama

brave_answers

Get AI-generated answers grounded in current web search results using Brave Search for accurate, up-to-date information.

Instructions

Returns direct AI answers grounded in Brave Search using Brave AI Grounding. Uses an OpenAI-compatible chat completions endpoint and is best for concise answer generation with live web grounding.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesQuestion or prompt to answer
modelNoModel name for Brave AI Grounding (default: brave)brave

Implementation Reference

  • The handler function that processes the 'brave_answers' tool, validates its arguments, and performs the search.
    export async function braveAnswersHandler(args: unknown) {
      if (!isBraveAnswersArgs(args)) {
        throw new Error("Invalid arguments for brave_answers");
      }
    
      const { query, model = "brave" } = args;
      const answer = await performBraveAnswers(query, model);
    
      return {
        content: [{ type: "text", text: answer }],
        isError: false,
      };
    }
  • The definition of the 'brave_answers' tool including its schema and description.
    export const BRAVE_ANSWERS_TOOL: Tool = {
      name: "brave_answers",
      description:
        "Returns direct AI answers grounded in Brave Search using Brave AI Grounding. " +
        "Uses an OpenAI-compatible chat completions endpoint and is best for concise answer generation with live web grounding.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Question or prompt to answer",
          },
          model: {
            type: "string",
            description: "Model name for Brave AI Grounding (default: brave)",
            default: "brave",
          },
        },
        required: ["query"],
      },
    };
  • The type guard function used to validate the input arguments for the 'brave_answers' tool.
    export function isBraveAnswersArgs(
      args: unknown
    ): args is { query: string; model?: string } {
      return (
        typeof args === "object" &&
        args !== null &&
        "query" in args &&
        typeof (args as { query: string }).query === "string"
      );
    }

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/dcostenco/BCBA'

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