Skip to main content
Glama
acchuang

Jina AI Remote MCP Server

by acchuang

search_web

Search the web for current information, news, articles, and websites to answer questions about recent events or find specific resources.

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

  • The core handler function for the 'search_web' tool. It authenticates using bearer token, performs a POST request to Jina's web search API (https://svip.jina.ai/), handles API errors, parses the JSON response, and returns the search results formatted as YAML.
    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, }; } },
  • Input schema using Zod for validating the 'query' (required string) and 'num' (optional number, default 30) parameters of the search_web tool.
    { 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)") },
  • Registers the 'search_web' tool on the MCP server by calling server.tool with the tool name, description, Zod input schema, and the handler 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:19-22 (registration)
    During MCP agent initialization, calls registerJinaTools which registers the search_web tool (among others) on the server.
    async init() { // Register all Jina AI tools registerJinaTools(this.server, () => this.props); }

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

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