Skip to main content
Glama
jina-ai

Jina AI Remote MCP Server

Official
by jina-ai

expand_query

Generates multiple expanded search queries from an initial query to enable broader and deeper research by diversifying search terms.

Instructions

Expand and rewrite search queries based on an up-to-date query expansion model. This tool takes an initial query and returns multiple expanded queries that can be used for more diversed and deeper searches. Useful for improving deep research results by searching broader and deeper.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to expand (e.g., 'machine learning', 'climate change')

Implementation Reference

  • The core handler function that implements the expand_query tool logic. It fetches expanded queries from the Jina AI API endpoint 'https://svip.jina.ai/' using the provided query, processes the results into text content items, and handles errors.
    async ({ query }: { query: string }) => {
    	try {
    		const props = getProps();
    
    		const tokenError = checkBearerToken(props.bearerToken);
    		if (tokenError) {
    			return tokenError;
    		}
    
    		const response = await fetch('https://svip.jina.ai/', {
    			method: 'POST',
    			headers: {
    				'Accept': 'application/json',
    				'Content-Type': 'application/json',
    				'Authorization': `Bearer ${props.bearerToken}`,
    			},
    			body: JSON.stringify({
    				q: query,
    				query_expansion: true
    			}),
    		});
    
    		if (!response.ok) {
    			return handleApiError(response, "Query expansion");
    		}
    
    		const data = await response.json() as any;
    
    		// Return each result as individual text items for consistency
    		const contentItems: Array<{ type: 'text'; text: string }> = [];
    
    		if (data.results && Array.isArray(data.results)) {
    			for (const result of data.results) {
    				contentItems.push({
    					type: "text" as const,
    					text: result,
    				});
    			}
    		}
    
    		return {
    			content: contentItems,
    		};
    	} catch (error) {
    		return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`);
    	}
    },
  • Zod schema defining the input parameters for the expand_query tool: a required 'query' string.
    {
    	query: z.string().describe("The search query to expand (e.g., 'machine learning', 'climate change')")
    },
  • Registers the 'expand_query' tool with the MCP server using server.tool(), conditionally based on isToolEnabled, including description, schema, and handler.
    if (isToolEnabled("expand_query")) {
    	server.tool(
    		"expand_query",
    		"Expand and rewrite search queries based on an up-to-date query expansion model. This tool takes an initial query and returns multiple expanded queries that can be used for more diversed and deeper searches. Useful for improving deep research results by searching broader and deeper.",
    		{
    			query: z.string().describe("The search query to expand (e.g., 'machine learning', 'climate change')")
    		},
    		async ({ query }: { query: string }) => {
    			try {
    				const props = getProps();
    
    				const tokenError = checkBearerToken(props.bearerToken);
    				if (tokenError) {
    					return tokenError;
    				}
    
    				const response = await fetch('https://svip.jina.ai/', {
    					method: 'POST',
    					headers: {
    						'Accept': 'application/json',
    						'Content-Type': 'application/json',
    						'Authorization': `Bearer ${props.bearerToken}`,
    					},
    					body: JSON.stringify({
    						q: query,
    						query_expansion: true
    					}),
    				});
    
    				if (!response.ok) {
    					return handleApiError(response, "Query expansion");
    				}
    
    				const data = await response.json() as any;
    
    				// Return each result as individual text items for consistency
    				const contentItems: Array<{ type: 'text'; text: string }> = [];
    
    				if (data.results && Array.isArray(data.results)) {
    					for (const result of data.results) {
    						contentItems.push({
    							type: "text" as const,
    							text: result,
    						});
    					}
    				}
    
    				return {
    					content: contentItems,
    				};
    			} catch (error) {
    				return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`);
    			}
    		},
    	);
    }
  • src/index.ts:22-24 (registration)
    'expand_query' is listed in the ALL_TOOLS array used for tool filtering and enabling.
    "search_web", "search_arxiv", "search_ssrn", "search_images", "search_jina_blog", "expand_query",
    "parallel_search_web", "parallel_search_arxiv", "parallel_search_ssrn", "parallel_read_url",
    "sort_by_relevance", "deduplicate_strings", "deduplicate_images", "extract_pdf"
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool 'returns multiple expanded queries' but lacks details on behavioral traits such as rate limits, authentication needs, response format, or potential side effects. For a tool with no annotation coverage, this leaves significant gaps in understanding its operation.

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, with the core purpose stated first. However, the second sentence could be more concise (e.g., 'diversed' is misspelled as 'diversed'), and some phrasing is slightly redundant, though overall it avoids unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (1 parameter, no output schema, no annotations), the description is partially complete. It covers the purpose and usage context but lacks details on behavioral aspects and output format. Without annotations or output schema, more information on what 'multiple expanded queries' entails would improve completeness.

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%, with the parameter 'query' well-documented in the schema. The description adds minimal value beyond the schema by implying the query is 'initial' and used for expansion, but does not provide additional syntax, format, or constraints. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 with specific verbs ('expand and rewrite search queries') and resource ('search queries'), distinguishing it from sibling tools like search_web or search_arxiv by focusing on query expansion rather than direct searching. It explicitly mentions using 'an up-to-date query expansion model' for transformation.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool ('useful for improving deep research results by searching broader and deeper'), but does not explicitly state when not to use it or name specific alternatives among siblings. It implies usage for enhancing search effectiveness without direct exclusions.

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/jina-ai/MCP'

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