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"

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