Skip to main content
Glama
wlmwwx

Jina AI Remote MCP Server

by wlmwwx

expand_query

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

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

  • Full implementation of the 'expand_query' tool handler: registers the tool with Zod schema, fetches expanded queries from Jina's svip.jina.ai API using POST with query_expansion: true, and returns array of expanded queries as text content items.
    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)}`);
    		}
    	},
    );
  • Zod input schema for expand_query tool: requires a single 'query' string parameter.
    	query: z.string().describe("The search query to expand (e.g., 'machine learning', 'climate change')")
    },
  • Registration of the expand_query tool using server.tool() within registerJinaTools function.
    	"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:21-22 (registration)
    Calls registerJinaTools which registers the expand_query tool among others in the MCP server initialization.
    	registerJinaTools(this.server, () => this.props);
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool 'returns multiple expanded queries' and uses 'an up-to-date query expansion model,' which gives some context on output and methodology. However, it doesn't cover critical aspects like rate limits, error handling, or whether this is a read-only operation (implied but not stated). For a tool with no annotations, this leaves significant gaps in behavioral understanding.

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 with two sentences that efficiently convey the tool's function and utility. It's front-loaded with the core purpose and avoids unnecessary details. However, the second sentence could be slightly more concise (e.g., 'Useful for deeper research by broadening search scope.'), but overall, it's well-structured with minimal waste.

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 (single parameter, no output schema, no annotations), the description is somewhat complete but has gaps. It explains what the tool does and its use case but lacks details on output format (e.g., structure of expanded queries), behavioral constraints, or integration with sibling tools. Without an output schema, more information on return values would be beneficial, making it adequate but not fully comprehensive.

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 input schema has 100% description coverage, with the 'query' parameter well-documented as 'The search query to expand (e.g., 'machine learning', 'climate change').' The description adds minimal value beyond this, only reiterating that it takes 'an initial query.' According to the rules, with high schema coverage (>80%), the baseline is 3 even without additional param info in the description.

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

Purpose4/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: 'Expand and rewrite search queries based on an up-to-date query expansion model.' It specifies the verb (expand/rewrite) and resource (search queries), making it understandable. However, it doesn't explicitly differentiate from sibling tools like 'parallel_search_web' or 'search_web', which might also involve query processing, so it misses the highest score.

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 implied usage context: 'Useful for improving deep research results by searching broader and deeper.' This suggests when to use it (for deeper research) but doesn't explicitly state when not to use it or name alternatives among the many sibling search tools. It offers some guidance but lacks clear exclusions or comparisons.

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/wlmwwx/jina-mcp'

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