deepsearch-web
Perform targeted web searches across specific sites or time periods to retrieve more relevant results than standard AI search, with configurable filters for precision.
Instructions
针对站点或时间范围的 DeepSearch 定向检索,拥有比AI Agent内置搜索更好的搜索效果但更耗时,需要平衡需求
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filters | Yes | ||
| locale | No | ||
| query | Yes | ||
| top_k | No |
Implementation Reference
- main.ts:102-132 (registration)Registration of the 'deepsearch-web' MCP tool, including title, description, input/output schemas, and the handler function that logs the call, invokes DeepSearchWebAgent.search(), parses the result, and returns structured content.server.registerTool( "deepsearch-web", { title: "DeepSearch 定向检索", description: "针对站点或时间范围的 DeepSearch 定向检索,拥有比AI Agent内置搜索更好的搜索效果但更耗时,需要平衡需求", inputSchema: deepSearchWebInputShape, outputSchema: searchResultShape, }, async (args) => { const toolLogger = logger.child({ tool: "deepsearch-web" }); toolLogger.info("收到工具调用", args); const result = await deepsearchWebAgent.search(args.query, { top_k: args.top_k, locale: args.locale, filters: args.filters, }); const structured = searchResultSchema.parse(result); toolLogger.info("完成工具调用", { itemCount: structured.items.length }); return { content: [ { type: "text" as const, text: JSON.stringify(structured, null, 2), }, ], structuredContent: structured, }; }, );
- main.ts:33-43 (schema)Input schema for 'deepsearch-web' tool, extending general shape with validation requiring 'site' or 'time_range' in filters.const deepSearchWebInputShape = { ...deepSearchInputShape, filters: z .record(z.any()) .refine((filters) => typeof filters.site === "string" || typeof filters.time_range === "string", { message: "filters 需要包含 site 或 time_range 字段", }), }; const deepSearchInputSchema = z.object(deepSearchInputShape); const deepSearchWebInputSchema = z.object(deepSearchWebInputShape);
- Handler logic in DeepSearchWebAgent.search(): validates presence of site or time_range filters specific to web tool, logs, and delegates to DeepSearchMCPClient.search().async search(query: string, options: SearchOptions = {}): Promise<SearchResult> { const filters = options.filters ?? {}; if (!filters.site && !filters.time_range) { this.logger.error("缺少必要过滤条件", { query, options }); throw new Error("deepsearch-web 需要提供 site 或 time_range 过滤条件"); } this.logger.info("执行定向检索", { query, options }); return this.client.search(query, { ...options, filters }); }
- deepsearch_mcp/client.ts:37-53 (helper)DeepSearchMCPClient.search() helper: prepares payload and invokes DeepSearchTransport with toolName ('deepsearch-web'), converts response to SearchResult.async search(query: string, options: SearchOptions = {}): Promise<SearchResult> { const topK = options.top_k ?? 5; if (topK <= 0) { throw new Error("top_k 必须为正整数"); } const payload = { query, top_k: topK, locale: options.locale ?? "zh-CN", filters: options.filters ?? {}, }; this.logger.info("发起工具调用", payload); const response = await this.transport.invokeTool(this.toolName, payload); return this.toSearchResult(response); }
- source/api.ts:232-234 (helper)Prompt instruction customization in DeepSearchTransport.buildUserPrompt(): specific enforcement of site/time_range filters for 'deepsearch-web' tool.toolName === "deepsearch-web" ? "必须使用 filters 中的 site/time_range 限制,确保返回结果满足条件。" : "可结合 filters 中提供的约束优化检索。";