search_web
Find up-to-date web content, news, articles, and websites using specific search terms. Apply filters like time, location, and language to retrieve relevant results for research, queries, or resource discovery.
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
| Name | Required | Description | Default |
|---|---|---|---|
| gl | No | Country code, e.g., 'dz' for Algeria | |
| hl | No | Language code, e.g., 'zh-cn' for Simplified Chinese | |
| location | No | Location for search results, e.g., 'London', 'New York', 'Tokyo' | |
| num | No | Maximum number of search results to return, between 1-100 (default: 30) | |
| query | Yes | Search terms or keywords to find relevant web content (e.g., 'climate change news 2024', 'best pizza recipe') | |
| tbs | No | Time-based search parameter, e.g., 'qdr:h' for past hour, can be qdr:h, qdr:d, qdr:w, qdr:m, qdr:y |
Implementation Reference
- src/tools/jina-tools.ts:282-331 (handler)Executes the web search using Jina's search API. Validates bearer token, sends POST request to https://svip.jina.ai/ with query and optional num_results, handles API errors, and returns structured YAML of search results.async ({ query, num = 30 }: { query: string; num?: number }) => { 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, num }), }); if (!response.ok) { return handleApiError(response, "Web search"); } const data = await response.json() as any; return { content: [ { type: "text" as const, text: yamlStringify(data.results), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, );
- src/tools/jina-tools.ts:278-281 (schema)Zod input schema defining 'query' (required string) and 'num' (optional number for result count).{ query: z.string().describe("Search terms or keywords to find relevant web content (e.g., 'climate change news 2024', 'best pizza recipe')"), num: z.number().optional().describe("Maximum number of search results to return, between 1-100 (default: 30)") },
- src/tools/jina-tools.ts:275-331 (registration)Registers the 'search_web' tool on the MCP server using server.tool(), including name, description, schema, and handler within the registerJinaTools function.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. Returns structured search results with URLs, titles, and content snippets.", { query: z.string().describe("Search terms or keywords to find relevant web content (e.g., 'climate change news 2024', 'best pizza recipe')"), num: z.number().optional().describe("Maximum number of search results to return, between 1-100 (default: 30)") }, async ({ query, num = 30 }: { query: string; num?: number }) => { 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, num }), }); if (!response.ok) { return handleApiError(response, "Web search"); } const data = await response.json() as any; return { content: [ { type: "text" as const, text: yamlStringify(data.results), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, );
- src/index.ts:21-21 (registration)Calls registerJinaTools to register all Jina tools, including search_web, on the MCP server during initialization.registerJinaTools(this.server, () => this.props);