Skip to main content
Glama

AI-powered search with reasoning. Supports perplexity (real-time + reasoning), kagi_fastgpt (quick answers), exa_answer (semantic AI).

ai_search

Search with AI reasoning across multiple providers to find answers, analyze information, and process content through a unified interface.

Instructions

AI-powered search with reasoning. Supports perplexity (real-time + reasoning), kagi_fastgpt (quick answers), exa_answer (semantic AI).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesQuery
providerYesAI provider
limitNoResult limit

Implementation Reference

  • Registration of the MCP 'ai_search' tool, including schema (query, provider: perplexity/kagi_fastgpt/exa_answer, limit) and handler that calls ai_search_provider.search() and returns JSON results or error.
    if (this.ai_search_provider) {
    	server.tool(
    		{
    			name: 'ai_search',
    			description: this.ai_search_provider.description,
    			schema: v.object({
    				query: v.pipe(v.string(), v.description('Query')),
    				provider: v.pipe(
    					v.union([
    						v.literal('perplexity'),
    						v.literal('kagi_fastgpt'),
    						v.literal('exa_answer'),
    					]),
    					v.description('AI provider'),
    				),
    				limit: v.optional(
    					v.pipe(v.number(), v.description('Result limit')),
    				),
    			}),
    		},
    		async ({ query, provider, limit }) => {
    			try {
    				const results = await this.ai_search_provider!.search({
    					query,
    					provider,
    					limit,
    				} as any);
    				const safe_results = handle_large_result(
    					results,
    					'ai_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,
    				};
    			}
    		},
    	);
    }
  • Handler function for the 'ai_search' MCP tool. Delegates to ai_search_provider.search(), stringifies results as JSON, handles large results and errors.
    async ({ query, provider, limit }) => {
    	try {
    		const results = await this.ai_search_provider!.search({
    			query,
    			provider,
    			limit,
    		} as any);
    		const safe_results = handle_large_result(
    			results,
    			'ai_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 'ai_search' tool defining parameters: query (string), provider (union of 'perplexity', 'kagi_fastgpt', 'exa_answer'), optional limit (number).
    schema: v.object({
    	query: v.pipe(v.string(), v.description('Query')),
    	provider: v.pipe(
    		v.union([
    			v.literal('perplexity'),
    			v.literal('kagi_fastgpt'),
    			v.literal('exa_answer'),
    		]),
    		v.description('AI provider'),
    	),
    	limit: v.optional(
    		v.pipe(v.number(), v.description('Result limit')),
    	),
    }),
  • Conditional registration of UnifiedAISearchProvider as the ai_search_provider during provider initialization if relevant API keys are present.
    	register_ai_search_provider(new UnifiedAISearchProvider());
    }
  • UnifiedAISearchProvider class that implements the SearchProvider interface for 'ai_search'. Instantiates and routes to sub-providers (PerplexityProvider, KagiFastGPTProvider, ExaAnswerProvider) based on the provider parameter.
    export class UnifiedAISearchProvider implements SearchProvider {
    	name = 'ai_search';
    	description =
    		'AI-powered search with reasoning. Supports perplexity (real-time + reasoning), kagi_fastgpt (quick answers), exa_answer (semantic AI).';
    
    	private providers: Map<AISearchProvider, SearchProvider> =
    		new Map();
    
    	constructor() {
    		this.providers.set('perplexity', new PerplexityProvider());
    		this.providers.set('kagi_fastgpt', new KagiFastGPTProvider());
    		this.providers.set('exa_answer', new ExaAnswerProvider());
    	}
    
    	async search(
    		params: UnifiedAISearchParams,
    	): 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);
    	}
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral information. It mentions 'AI-powered search with reasoning' and lists provider names with brief characteristics, but doesn't disclose rate limits, authentication needs, cost implications, response formats, or what 'reasoning' entails. The description doesn't contradict annotations (none exist), but fails to provide adequate behavioral context.

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 concise with two sentences. The first sentence states the core function, and the second lists supported providers. However, the second sentence could be more structured - it mixes provider names with parenthetical characteristics in a somewhat cluttered format.

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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, how results are formatted, whether there are rate limits or costs, or how it differs from sibling search tools. The provider characteristics are mentioned but not explained in practical terms.

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 three parameters. The description adds no additional parameter semantics beyond what's in the schema - it mentions the three provider options but doesn't explain their differences or when to choose each. Baseline 3 is appropriate when schema does the heavy lifting.

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 Guidelines2/5

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

No guidance on when to use this tool versus alternatives. The description mentions three providers but doesn't explain when to choose perplexity (real-time + reasoning) vs kagi_fastgpt (quick answers) vs exa_answer (semantic AI), nor does it differentiate this from sibling tools like 'web_search' or 'tavily_extract_process'.

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