Skip to main content
Glama

Search the web. Providers: tavily (factual/citations), brave (privacy/operators), kagi (quality/operators), exa (AI-semantic). Brave/Kagi support query operators like site:, filetype:, lang:, etc.

web_search

Search the web using multiple providers for factual, privacy-focused, or AI-enhanced results with query operators and domain filtering.

Instructions

Search the web. Providers: tavily (factual/citations), brave (privacy/operators), kagi (quality/operators), exa (AI-semantic). Brave/Kagi support query operators like site:, filetype:, lang:, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesQuery
providerYesSearch provider
limitNoResult limit
include_domainsNoDomains to include
exclude_domainsNoDomains to exclude

Implementation Reference

  • MCP tool registration including schema, description, and handler function for 'web_search'. The handler delegates to the registered web_search_provider's search method, handles large results, and formats the response as JSON text or error.
    if (this.web_search_provider) {
    	server.tool(
    		{
    			name: 'web_search',
    			description: this.web_search_provider.description,
    			schema: v.object({
    				query: v.pipe(v.string(), v.description('Query')),
    				provider: v.pipe(
    					v.union([
    						v.literal('tavily'),
    						v.literal('brave'),
    						v.literal('kagi'),
    						v.literal('exa'),
    					]),
    					v.description('Search provider'),
    				),
    				limit: v.optional(
    					v.pipe(v.number(), v.description('Result limit')),
    				),
    				include_domains: v.optional(
    					v.pipe(
    						v.array(v.string()),
    						v.description('Domains to include'),
    					),
    				),
    				exclude_domains: v.optional(
    					v.pipe(
    						v.array(v.string()),
    						v.description('Domains to exclude'),
    					),
    				),
    			}),
    		},
    		async ({
    			query,
    			provider,
    			limit,
    			include_domains,
    			exclude_domains,
    		}) => {
    			try {
    				const results = await this.web_search_provider!.search({
    					query,
    					provider,
    					limit,
    					include_domains,
    					exclude_domains,
    				} as any);
    				const safe_results = handle_large_result(
    					results,
    					'web_search',
    				);
    				return {
    					content: [
    						{
    							type: 'text' as const,
    							text: JSON.stringify(safe_results, null, 2),
    						},
    					],
    				};
    			} catch (error) {
    				const error_response = create_error_response(
    					error as Error,
    				);
    				return {
    					content: [
    						{
    							type: 'text' as const,
    							text: error_response.error,
    						},
    					],
    					isError: true,
    				};
    			}
    		},
    	);
    }
  • Valibot input schema for the web_search tool defining parameters: query (required), provider (tavily|brave|kagi|exa), optional limit, include_domains, exclude_domains.
    schema: v.object({
    	query: v.pipe(v.string(), v.description('Query')),
    	provider: v.pipe(
    		v.union([
    			v.literal('tavily'),
    			v.literal('brave'),
    			v.literal('kagi'),
    			v.literal('exa'),
    		]),
    		v.description('Search provider'),
    	),
    	limit: v.optional(
    		v.pipe(v.number(), v.description('Result limit')),
    	),
    	include_domains: v.optional(
    		v.pipe(
    			v.array(v.string()),
    			v.description('Domains to include'),
    		),
    	),
    	exclude_domains: v.optional(
    		v.pipe(
    			v.array(v.string()),
    			v.description('Domains to exclude'),
    		),
    	),
    }),
  • Conditional registration of the UnifiedWebSearchProvider instance to the tool registry if any web search API key is valid.
    if (has_web_search) {
    	register_web_search_provider(new UnifiedWebSearchProvider());
    }
  • UnifiedWebSearchProvider class implementing SearchProvider. Instantiates sub-providers (Tavily, Brave, Kagi, Exa) and delegates search calls to the selected provider based on input.
    export class UnifiedWebSearchProvider implements SearchProvider {
    	name = 'web_search';
    	description =
    		'Search the web. Providers: tavily (factual/citations), brave (privacy/operators), kagi (quality/operators), exa (AI-semantic). Brave/Kagi support query operators like site:, filetype:, lang:, etc.';
    
    	private providers: Map<WebSearchProvider, SearchProvider> =
    		new Map();
    
    	constructor() {
    		this.providers.set('tavily', new TavilySearchProvider());
    		this.providers.set('brave', new BraveSearchProvider());
    		this.providers.set('kagi', new KagiSearchProvider());
    		this.providers.set('exa', new ExaSearchProvider());
    	}
    
    	async search(
    		params: UnifiedWebSearchParams,
    	): Promise<SearchResult[]> {
    		const { provider, ...searchParams } = params;
    
    		if (!provider) {
    			throw new ProviderError(
    				ErrorType.INVALID_INPUT,
    				'Provider parameter is required',
    				this.name,
    			);
    		}
    
    		const selectedProvider = this.providers.get(provider);
    
    		if (!selectedProvider) {
    			throw new ProviderError(
    				ErrorType.INVALID_INPUT,
    				`Invalid provider: ${provider}. Valid options: ${Array.from(this.providers.keys()).join(', ')}`,
    				this.name,
    			);
    		}
    
    		return selectedProvider.search(searchParams);
    	}
    }
  • Function to register a SearchProvider instance (e.g., UnifiedWebSearchProvider) with the ToolRegistry for use in the web_search tool.
    export const register_web_search_provider = (
    	provider: SearchProvider,
    ) => {
    	registry.register_web_search_provider(provider);
    };
Behavior2/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 'Brave/Kagi support query operators like site:, filetype:, lang:, etc.' which adds some behavioral context about query capabilities. However, it doesn't describe what the tool returns (search results format), whether it performs web scraping, rate limits, authentication needs, or any other operational characteristics. For a web search tool with no annotations, this leaves significant behavioral gaps.

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 extremely concise - just two sentences that pack information efficiently. It's front-loaded with the core purpose and immediately follows with provider details. There's no wasted space or redundant information. However, it could be slightly more structured by separating provider characteristics from operational notes about query operators.

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 this is a 5-parameter tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (search results format, structure, or content), doesn't mention error conditions, rate limits, or authentication requirements. For a web search tool that likely returns complex results, the description should provide more context about the operation and expected outcomes.

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 all 5 parameters with basic descriptions. The description adds minimal value beyond the schema - it mentions query operators for Brave/Kagi providers (relevant to the 'query' parameter) and lists provider characteristics (relevant to the 'provider' parameter). However, it doesn't explain parameter interactions, default values, or provide examples of proper usage. The baseline of 3 is appropriate given the comprehensive schema coverage.

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

Purpose2/5

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

Tautological: description restates name/title.

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

Usage Guidelines3/5

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

The description provides some implied usage guidance by listing provider characteristics (tavily for factual/citations, brave for privacy/operators, etc.), which suggests when to choose each provider. However, it doesn't explicitly state when to use this tool versus its siblings like 'ai_search' or 'firecrawl_process', nor does it provide any exclusion criteria or prerequisites. The guidance is limited to provider selection within the tool itself.

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/spences10/mcp-omnisearch'

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