mcp-bocha_search
Search the web with time filters, domain inclusion/exclusion, and summarized results using Bocha AI's API. Ideal for retrieving targeted and relevant information efficiently.
Instructions
Search the web for information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | ||
| exclude | No | ||
| freshness | No | ||
| include | No | ||
| query | Yes | ||
| summary | No |
Implementation Reference
- src/index.ts:26-54 (handler)The execute function that handles the tool logic by making a POST request to the Bocha AI web-search API, processes the response, and returns the web pages as content.execute: async (params) => { const response = await fetch("https://api.bochaai.com/v1/web-search", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ ...params, include: params.include?.join(","), exclude: params.exclude?.join(","), }), }); const { data: { webPages }, } = await response.json(); const result = [ ...webPages.value.map((page: any) => ({ type: "text", text: JSON.stringify(page), })), ]; return { content: result, }; },
- src/index.ts:16-25 (schema)Zod schema defining the input parameters for the mcp-bocha_search tool, including query, freshness, summary, include, exclude, and count.parameters: z.object({ query: z.string(), freshness: z .enum(["oneDay", "oneWeek", "oneMonth", "oneYear", "noLimit"]) .optional(), summary: z.boolean().optional(), include: z.array(z.string()).optional(), exclude: z.array(z.string()).optional(), count: z.number().optional(), }),
- src/index.ts:13-55 (registration)Registration of the mcp-bocha_search tool using server.addTool, including name, description, parameters schema, and execute handler.server.addTool({ name: "mcp-bocha_search", description: "Search the web for information", parameters: z.object({ query: z.string(), freshness: z .enum(["oneDay", "oneWeek", "oneMonth", "oneYear", "noLimit"]) .optional(), summary: z.boolean().optional(), include: z.array(z.string()).optional(), exclude: z.array(z.string()).optional(), count: z.number().optional(), }), execute: async (params) => { const response = await fetch("https://api.bochaai.com/v1/web-search", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ ...params, include: params.include?.join(","), exclude: params.exclude?.join(","), }), }); const { data: { webPages }, } = await response.json(); const result = [ ...webPages.value.map((page: any) => ({ type: "text", text: JSON.stringify(page), })), ]; return { content: result, }; }, });