Skip to main content
Glama
jina-ai

Jina AI Remote MCP Server

Official
by jina-ai

search_web

Search the web for current information, news, articles, and websites to find up-to-date content, research topics, or answer questions about recent events.

Instructions

Search the entire web for current information, news, articles, and websites. Use this when you need up-to-date information, want to find specific websites, research topics, or get the latest news. Ideal for answering questions about recent events, finding resources, or discovering relevant content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch terms or keywords to find relevant web content (e.g., 'climate change news 2024', 'best pizza recipe'). Can be a single query string or an array of queries for parallel search.
numNoMaximum number of search results to return, between 1-100
tbsNoTime-based search parameter, e.g., 'qdr:h' for past hour, can be qdr:h, qdr:d, qdr:w, qdr:m, qdr:y
locationNoLocation for search results, e.g., 'London', 'New York', 'Tokyo'
glNoCountry code, e.g., 'dz' for Algeria
hlNoLanguage code, e.g., 'zh-cn' for Simplified Chinese

Implementation Reference

  • Primary handler function for the 'search_web' MCP tool. Processes input parameters, supports single or multiple queries (parallel execution), validates bearer token, delegates to executeWebSearch utility, and formats results as MCP content items.
    async ({ query, num, tbs, location, gl, hl }: { query: string | string[]; num: number; tbs?: string; location?: string; gl?: string; hl?: string }) => {
    	try {
    		const props = getProps();
    
    		const tokenError = checkBearerToken(props.bearerToken);
    		if (tokenError) {
    			return tokenError;
    		}
    
    		// Handle single query or single-element array
    		if (typeof query === 'string' || (Array.isArray(query) && query.length === 1)) {
    			const singleQuery = typeof query === 'string' ? query : query[0];
    			const searchResult = await executeWebSearch({ query: singleQuery, num, tbs, location, gl, hl }, props.bearerToken);
    
    			return {
    				content: formatSingleSearchResultToContentItems(searchResult),
    			};
    		}
    
    		// Handle multiple queries with parallel search
    		if (Array.isArray(query) && query.length > 1) {
    			const searches = query.map(q => ({ query: q, num, tbs, location, gl, hl }));
    
    			const uniqueSearches = searches.filter((search, index, self) =>
    				index === self.findIndex(s => s.query === search.query)
    			);
    
    			const webSearchFunction = async (searchArgs: SearchWebArgs) => {
    				return executeWebSearch(searchArgs, props.bearerToken);
    			};
    
    			const results = await executeParallelSearches(uniqueSearches, webSearchFunction, { timeout: 30000 });
    
    			return {
    				content: formatParallelSearchResultsToContentItems(results),
    			};
    		}
    
    		return createErrorResponse("Invalid query format");
    	} catch (error) {
    		return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`);
    	}
    },
  • Registers the 'search_web' tool with the MCP server using server.tool(), including name, description, Zod input schema, and handler function, conditional on tool being enabled.
    if (isToolEnabled("search_web")) {
    	server.tool(
    		"search_web",
    		"Search the entire web for current information, news, articles, and websites. Use this when you need up-to-date information, want to find specific websites, research topics, or get the latest news. Ideal for answering questions about recent events, finding resources, or discovering relevant content.",
    		{
    			query: z.union([z.string(), z.array(z.string())]).describe("Search terms or keywords to find relevant web content (e.g., 'climate change news 2024', 'best pizza recipe'). Can be a single query string or an array of queries for parallel search."),
    			num: z.number().default(30).describe("Maximum number of search results to return, between 1-100"),
    			tbs: z.string().optional().describe("Time-based search parameter, e.g., 'qdr:h' for past hour, can be qdr:h, qdr:d, qdr:w, qdr:m, qdr:y"),
    			location: z.string().optional().describe("Location for search results, e.g., 'London', 'New York', 'Tokyo'"),
    			gl: z.string().optional().describe("Country code, e.g., 'dz' for Algeria"),
    			hl: z.string().optional().describe("Language code, e.g., 'zh-cn' for Simplified Chinese")
    		},
    		async ({ query, num, tbs, location, gl, hl }: { query: string | string[]; num: number; tbs?: string; location?: string; gl?: string; hl?: string }) => {
    			try {
    				const props = getProps();
    
    				const tokenError = checkBearerToken(props.bearerToken);
    				if (tokenError) {
    					return tokenError;
    				}
    
    				// Handle single query or single-element array
    				if (typeof query === 'string' || (Array.isArray(query) && query.length === 1)) {
    					const singleQuery = typeof query === 'string' ? query : query[0];
    					const searchResult = await executeWebSearch({ query: singleQuery, num, tbs, location, gl, hl }, props.bearerToken);
    
    					return {
    						content: formatSingleSearchResultToContentItems(searchResult),
    					};
    				}
    
    				// Handle multiple queries with parallel search
    				if (Array.isArray(query) && query.length > 1) {
    					const searches = query.map(q => ({ query: q, num, tbs, location, gl, hl }));
    
    					const uniqueSearches = searches.filter((search, index, self) =>
    						index === self.findIndex(s => s.query === search.query)
    					);
    
    					const webSearchFunction = async (searchArgs: SearchWebArgs) => {
    						return executeWebSearch(searchArgs, props.bearerToken);
    					};
    
    					const results = await executeParallelSearches(uniqueSearches, webSearchFunction, { timeout: 30000 });
    
    					return {
    						content: formatParallelSearchResultsToContentItems(results),
    					};
    				}
    
    				return createErrorResponse("Invalid query format");
    			} catch (error) {
    				return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`);
    			}
    		},
    	);
    }
  • TypeScript interface SearchWebArgs defining the input parameters for web search operations, used for typing in handlers and utilities.
    export interface SearchWebArgs {
        query: string;
        num?: number;
        tbs?: string;
        location?: string;
        gl?: string;
        hl?: string;
    }
  • Core utility function that executes the actual web search API call to Jina's svip.jina.ai endpoint, handles parameters, authentication, and returns formatted results or errors.
    export async function executeWebSearch(
        searchArgs: SearchWebArgs,
        bearerToken: string
    ): Promise<SearchResultOrError> {
        try {
            const response = await fetch('https://svip.jina.ai/', {
                method: 'POST',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer ${bearerToken}`,
                },
                body: JSON.stringify({
                    q: searchArgs.query,
                    num: searchArgs.num || 30,
                    ...(searchArgs.tbs && { tbs: searchArgs.tbs }),
                    ...(searchArgs.location && { location: searchArgs.location }),
                    ...(searchArgs.gl && { gl: searchArgs.gl }),
                    ...(searchArgs.hl && { hl: searchArgs.hl })
                }),
            });
    
            if (!response.ok) {
                return { error: `Search failed for query "${searchArgs.query}": ${response.statusText}` };
            }
    
            const data = await response.json() as any;
            return { query: searchArgs.query, results: data.results || [] };
        } catch (error) {
            return { error: `Search failed for query "${searchArgs.query}": ${error instanceof Error ? error.message : String(error)}` };
        }
    }
  • src/index.ts:99-102 (registration)
    Calls registerJinaTools to register all tools including 'search_web' on the MCP server instance, passing props getter and enabled tools filter.
    // Register all Jina AI tools with optional filtering
    registerJinaTools(server, () => currentProps, enabledTools);
    
    return server;
Behavior3/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. It mentions the tool provides 'current information' and 'up-to-date information,' which implies freshness but doesn't disclose rate limits, authentication needs, or result format. The description adds some behavioral context (e.g., 'ideal for answering questions about recent events') but lacks details on pagination, error handling, or performance characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by usage guidelines. Every sentence earns its place by providing specific guidance (e.g., 'Ideal for answering questions about recent events') without redundancy or fluff.

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 complexity (6 parameters, no output schema, no annotations), the description is moderately complete. It covers purpose and usage well but lacks details on behavioral traits like rate limits or result structure. Without annotations or output schema, more context on what the tool returns or its limitations 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%, so the schema already documents all 6 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema (e.g., it doesn't explain 'query' syntax or 'tbs' usage). With high schema coverage, the baseline is 3, as the description doesn't compensate with additional param semantics.

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: 'Search the entire web for current information, news, articles, and websites.' It specifies the verb ('Search') and resource ('the entire web'), and distinguishes from siblings like search_arxiv, search_ssrn, and search_images by emphasizing web content rather than academic papers or images.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'Use this when you need up-to-date information, want to find specific websites, research topics, or get the latest news.' It provides clear alternatives by naming specific use cases (e.g., 'answering questions about recent events') and implicitly distinguishes from siblings like search_arxiv for academic content.

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