dsh-free-search 0.9.66 → 0.9.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -548,7 +548,7 @@ Search engine test:
548
548
  npx -y -p dsh-free-search dsh-free-search-mcp
549
549
  ```
550
550
 
551
- `web_search` 默认只自动调用免 key 的 Bing / DuckDuckGo;在参数或 `MCP_SEARCH_ENGINE` 里显式点名 `google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` / `perplexity` / `serpbase` / `serply` / `outcrawl` / `tinyfish` / `jina` / `kimi` / `aliyun` / `doubao` / `zhihu_global` / `zhihu_site` / `specstream` / `deepseek-official` / `openai` / `gemini` / `claude` / `agy` 时才会使用付费或有额度限制的引擎;`anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` 可显式选择,且有免 key 档;`degoog` 需要 `MCP_DEGOOG_INSTANCES`;`baidu-html` / `so360` / `sogou` / `wechat` / `toutiao` 是默认关闭的 HTML SERP 抓取引擎。支持 `time_range`(day/week/month/year)。`advanced_search` 是同一后端的兼容别名,便于按宿主工具名调用。`web_fetch` 仍走直连 / 浏览器 / Exa / Firecrawl。`multi_search` 并行合并多个引擎(默认只跑免费引擎),`domain_search` 直查包/论文/CVE/财报/金融/法律等垂直源,`platform_search` 直查 GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/掘金/豆瓣/Qiita/YouTube/Vimeo/X,`video_search` 查 Bing/DDG 视频,`research` 做轻量多引擎检索 + 抓取 + 证据摘要,`weather` 查询 1–7 天天气;不监听端口。Claude Desktop 配置示例:
551
+ `web_search` 默认只自动调用免 key 的 Bing / DuckDuckGo;在参数或 `MCP_SEARCH_ENGINE` 里显式点名 `google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` / `perplexity` / `serpbase` / `serply` / `outcrawl` / `tinyfish` / `jina` / `kimi` / `aliyun` / `doubao` / `zhihu_global` / `zhihu_site` / `specstream` / `deepseek-official` / `openai` / `gemini` / `claude` / `agy` 时才会使用付费或有额度限制的引擎;`anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` 可显式选择,且有免 key 档;`degoog` 需要 `MCP_DEGOOG_INSTANCES`;`baidu-html` / `so360` / `sogou` / `wechat` / `toutiao` 是默认关闭的 HTML SERP 抓取引擎。支持 `time_range`(day/week/month/year)。`advanced_search` 是同一后端的兼容别名,便于按宿主工具名调用。`web_fetch` 仍走直连 / 浏览器 / Exa / Firecrawl。`multi_search` 并行合并多个引擎(默认只跑免费引擎),`domain_search` 直查包/论文/CVE/财报/金融/法律等垂直源,`platform_search` 直查 GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/掘金/豆瓣/Qiita/YouTube/Vimeo/X,`video_search` 查 Bing/DDG 视频,`research` 做轻量多引擎检索 + 抓取 + 证据摘要,`cache_search` 检索本地研究缓存,`free_search_test` 逐引擎探测,`doctor` 输出本地配置/凭据诊断,`weather` 查询 1–7 天天气;不监听端口。Claude Desktop 配置示例:
552
552
 
553
553
  ```json
554
554
  {
@@ -1292,7 +1292,7 @@ The repo also ships a standalone stdio MCP server for Claude Desktop, Cursor, Co
1292
1292
  npx -y -p dsh-free-search dsh-free-search-mcp
1293
1293
  ```
1294
1294
 
1295
- `web_search` auto-runs only the keyless Bing / DuckDuckGo engines; a keyed engine (`google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` / `perplexity` / `serpbase` / `serply` / `outcrawl` / `tinyfish` / `jina` / `kimi` / `aliyun` / `doubao` / `zhihu_global` / `zhihu_site` / `specstream` / `deepseek-official` / `openai` / `gemini` / `claude` / `agy`) runs only when named in the argument or `MCP_SEARCH_ENGINE`; `anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` can also be named explicitly and have keyless tiers; `degoog` needs `MCP_DEGOOG_INSTANCES`; `baidu-html` / `so360` / `sogou` / `wechat` / `toutiao` are opt-in HTML SERP scrapers. It supports `time_range` (day/week/month/year). `advanced_search` is a compatibility alias over the same backend for hosts that call that tool name. `web_fetch` still uses direct / browser / Exa / Firecrawl. `multi_search` merges several engines in parallel (free engines by default), `domain_search` queries structured package/paper/CVE/filing/finance/law sources, `platform_search` queries GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/Juejin/Douban/Qiita/YouTube/Vimeo/X, `video_search` queries Bing/DDG videos, `research` runs a lightweight multi-engine search + fetch + evidence brief, and `weather` returns a 1-7 day forecast; the server does not listen on a port. Claude Desktop example:
1295
+ `web_search` auto-runs only the keyless Bing / DuckDuckGo engines; a keyed engine (`google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` / `perplexity` / `serpbase` / `serply` / `outcrawl` / `tinyfish` / `jina` / `kimi` / `aliyun` / `doubao` / `zhihu_global` / `zhihu_site` / `specstream` / `deepseek-official` / `openai` / `gemini` / `claude` / `agy`) runs only when named in the argument or `MCP_SEARCH_ENGINE`; `anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` can also be named explicitly and have keyless tiers; `degoog` needs `MCP_DEGOOG_INSTANCES`; `baidu-html` / `so360` / `sogou` / `wechat` / `toutiao` are opt-in HTML SERP scrapers. It supports `time_range` (day/week/month/year). `advanced_search` is a compatibility alias over the same backend for hosts that call that tool name. `web_fetch` still uses direct / browser / Exa / Firecrawl. `multi_search` merges several engines in parallel (free engines by default), `domain_search` queries structured package/paper/CVE/filing/finance/law sources, `platform_search` queries GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/Juejin/Douban/Qiita/YouTube/Vimeo/X, `video_search` queries Bing/DDG videos, `research` runs a lightweight multi-engine search + fetch + evidence brief, `cache_search` searches the local research cache, `free_search_test` probes engines, `doctor` reports local config/credentials, and `weather` returns a 1-7 day forecast; the server does not listen on a port. Claude Desktop example:
1296
1296
 
1297
1297
  ```json
1298
1298
  {
package/lib/client.js CHANGED
@@ -777,7 +777,7 @@ window.__ModuleLoader__.load({
777
777
  "cache_search",
778
778
  "domain_search",
779
779
  ];
780
- const PLUGIN_VERSION = "0.9.66";
780
+ const PLUGIN_VERSION = "0.9.68";
781
781
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
782
782
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
783
783
  const NAV_ITEMS = [
package/lib/doctor.js CHANGED
@@ -33,6 +33,7 @@ export function buildDoctorReport({
33
33
  tools = { enabled: [], disabled: [] },
34
34
  toolsKnown = [],
35
35
  engines = [],
36
+ suppressWarnings = false,
36
37
  now = Date.now(),
37
38
  } = {}) {
38
39
  const lines = [];
@@ -44,14 +45,16 @@ export function buildDoctorReport({
44
45
  );
45
46
  lines.push(`providers: search=${searchProvider || "auto"} · fetch=${fetchProvider || "auto"}`);
46
47
  const warnings = [];
47
- if (poolsConfigured && provider !== "auto" && provider !== "multi") {
48
- warnings.push(`language pools are configured, but provider is ${provider || effectiveLabel}; zhPool/enPool only apply to auto or multi`);
49
- }
50
- if (searchProvider && searchProvider !== "ddg" && searchProvider !== "deepseek-official") {
51
- warnings.push(`search is served by "${searchProvider}", not this plugin; search providers are mutually exclusive (the last takeover wins)`);
52
- }
53
- if (fetchProvider && fetchProvider !== "fs-quality-fetch" && fetchProvider !== "http") {
54
- warnings.push(`fetch is served by "${fetchProvider}", not this plugin; fetch providers are mutually exclusive`);
48
+ if (!suppressWarnings) {
49
+ if (poolsConfigured && provider !== "auto" && provider !== "multi") {
50
+ warnings.push(`language pools are configured, but provider is ${provider || effectiveLabel}; zhPool/enPool only apply to auto or multi`);
51
+ }
52
+ if (searchProvider && searchProvider !== "ddg" && searchProvider !== "deepseek-official") {
53
+ warnings.push(`search is served by "${searchProvider}", not this plugin; search providers are mutually exclusive (the last takeover wins)`);
54
+ }
55
+ if (fetchProvider && fetchProvider !== "fs-quality-fetch" && fetchProvider !== "http") {
56
+ warnings.push(`fetch is served by "${fetchProvider}", not this plugin; fetch providers are mutually exclusive`);
57
+ }
55
58
  }
56
59
  if (warnings.length > 0) {
57
60
  lines.push("");
package/lib/mcp_server.js CHANGED
@@ -7,6 +7,9 @@ import { ENGINES } from "./domain_engines.js";
7
7
  import { fetchWeather, formatWeather } from "./weather.js";
8
8
  import { PLATFORMS, searchPlatform, searchBingVideos, searchDdgVideos } from "./platform_engines.js";
9
9
  import { assessEvidenceQuality } from "./quality.js";
10
+ import { search as cachedPageSearch, put as cachePagePut } from "./cache.js";
11
+ import { buildDoctorReport } from "./doctor.js";
12
+ import { agyAvailable } from "./agy.js";
10
13
 
11
14
  const SERVER_NAME = "dsh-free-search";
12
15
  const PROTOCOL_VERSIONS = ["2024-11-05", "2025-03-26", "2025-06-18"];
@@ -159,6 +162,55 @@ const TOOLS = [
159
162
  additionalProperties: false,
160
163
  },
161
164
  },
165
+ {
166
+ name: "cache_search",
167
+ description: "Search the local cache of pages fetched by research/web_fetch. Returns title, URL, excerpt and fetch time; no network.",
168
+ inputSchema: {
169
+ type: "object",
170
+ properties: {
171
+ query: { type: "string", description: "Text to search in cached titles and bodies." },
172
+ limit: { type: "integer", minimum: 1, maximum: 20, description: "Maximum hits, default 8." },
173
+ },
174
+ required: ["query"],
175
+ additionalProperties: false,
176
+ },
177
+ },
178
+ {
179
+ name: "free_search_test",
180
+ description: "Run a small live probe for one or more search engines and report status, latency and a sample result. Makes network requests; use for diagnostics.",
181
+ inputSchema: {
182
+ type: "object",
183
+ properties: {
184
+ engines: {
185
+ type: "array",
186
+ items: { type: "string", enum: MCP_ENGINE_IDS.filter((id) => id !== "auto") },
187
+ minItems: 1,
188
+ maxItems: 20,
189
+ uniqueItems: true,
190
+ description: "Engine ids to probe.",
191
+ },
192
+ query: { type: "string", description: "Probe query, default 'test'." },
193
+ },
194
+ required: ["engines"],
195
+ additionalProperties: false,
196
+ },
197
+ },
198
+ {
199
+ name: "doctor",
200
+ description: "Report the local MCP configuration: engine list, credential availability, cache mode and versions. No network calls.",
201
+ inputSchema: {
202
+ type: "object",
203
+ properties: {
204
+ engines: {
205
+ type: "array",
206
+ items: { type: "string", enum: MCP_ENGINE_IDS.filter((id) => id !== "auto") },
207
+ uniqueItems: true,
208
+ description: "Engine ids to report; omit for all.",
209
+ },
210
+ },
211
+ additionalProperties: false,
212
+ },
213
+ },
162
214
  ];
163
215
 
164
216
  function packageVersion() {
@@ -344,10 +396,15 @@ export async function searchVideosWeb(args = {}) {
344
396
  return { provider: used.join("+") || "video", query, sources };
345
397
  }
346
398
 
347
- async function fetchDocument(url, maxChars) {
399
+ async function fetchDocument(url, maxChars, title = "") {
348
400
  const result = await getFetchProvider().fetch({ url }, undefined);
349
401
  const content = String(result?.body?.content ?? "");
350
402
  if (content.length === 0) throw new Error(`no readable text (HTTP ${result?.statusCode ?? "?"})`);
403
+ try {
404
+ cachePagePut(result?.url ?? url, title || result?.body?.title || "", content);
405
+ } catch {
406
+ // cache is best effort; a missing local sqlite cache must not fail a fetch
407
+ }
351
408
  return {
352
409
  url: result?.url ?? url,
353
410
  status: result?.statusCode ?? 0,
@@ -394,7 +451,7 @@ export async function researchWeb(args = {}) {
394
451
  const candidates = search.sources.slice(0, maxDocuments);
395
452
  const perDocumentChars = Math.min(8000, 900 + depth * 1200);
396
453
  const settled = await Promise.allSettled(
397
- candidates.map(async (source) => ({ source, ...(await fetchDocument(source.url, perDocumentChars)) }))
454
+ candidates.map(async (source) => ({ source, ...(await fetchDocument(source.url, perDocumentChars, source.title || "")) }))
398
455
  );
399
456
  const documents = [];
400
457
  settled.forEach((entry, index) => {
@@ -422,6 +479,114 @@ export async function researchWeb(args = {}) {
422
479
  };
423
480
  }
424
481
 
482
+ function markdownCacheResults(value) {
483
+ if (!value.hits?.length) return `No cached pages match "${value.query}".`;
484
+ const lines = value.hits.map((hit) => `- ${hit.title || hit.url} - ${hit.url}\n ${hit.excerpt} _(cached ${hit.fetched_at})_`);
485
+ return `Cached pages matching "${value.query}":\n\n${lines.join("\n")}`;
486
+ }
487
+
488
+ function markdownEngineTests(value) {
489
+ const lines = (value.results ?? []).map((result) => {
490
+ if (result.ok) return `- ${result.engine}: ok · ${result.sources} source(s)${result.sample ? ` · ${result.sample}` : ""}`;
491
+ return `- ${result.engine}: failed · ${result.error}`;
492
+ });
493
+ return `Engine test (${value.query}):\n\n${lines.join("\n") || "No engine results."}`;
494
+ }
495
+
496
+ export async function searchCachedPages(args = {}) {
497
+ const query = String(args.query ?? "").trim();
498
+ if (!query) throw new Error("query is required");
499
+ const limit = Math.min(Math.max(Number(args.limit) || 8, 1), 20);
500
+ return { query, hits: cachedPageSearch(query, limit) };
501
+ }
502
+
503
+ export async function testEngines(args = {}) {
504
+ const engines = Array.isArray(args.engines)
505
+ ? [...new Set(args.engines.map((id) => String(id ?? "").trim().toLowerCase()).filter(Boolean))]
506
+ : [];
507
+ if (engines.length === 0) throw new Error("engines must be a non-empty array");
508
+ for (const engine of engines) {
509
+ if (engine === "auto" || !MCP_ENGINE_IDS.includes(engine)) throw new Error(`unknown engine "${engine}"`);
510
+ }
511
+ const query = String(args.query ?? "").trim() || "test";
512
+ const results = await Promise.allSettled(engines.map((engine) => runMcpEngine(engine, query, { maxResults: 2 })));
513
+ return {
514
+ query,
515
+ results: results.map((entry, index) => {
516
+ if (entry.status === "fulfilled") {
517
+ const sources = entry.value.sources ?? [];
518
+ return {
519
+ engine: engines[index],
520
+ ok: true,
521
+ sources: sources.length,
522
+ sample: sources[0]?.title || sources[0]?.url || "",
523
+ };
524
+ }
525
+ return { engine: engines[index], ok: false, error: entry.reason?.message ?? String(entry.reason) };
526
+ }),
527
+ };
528
+ }
529
+
530
+ const MCP_ENGINE_CREDENTIALS = {
531
+ google: ["GOOGLE_CSE_API_KEY", "GOOGLE_CSE_ID"],
532
+ baidu: ["BAIDU_API_KEY"],
533
+ brave: ["BRAVE_API_KEY"],
534
+ metaso: ["METASO_API_KEY"],
535
+ yandex: ["YANDEX_API_KEY", "YANDEX_FOLDER_ID"],
536
+ yuanbao: ["TENCENTCLOUD_WSA_APIKEY"],
537
+ "deepseek-tools": ["DEEPSEEK_TOOLS_API_KEY", "DEEPSEEK_API_KEY"],
538
+ zhipu: ["ZHIPU_API_KEY"],
539
+ perplexity: ["PERPLEXITY_API_KEY"],
540
+ serpbase: ["SERPBASE_API_KEY"],
541
+ serply: ["SERPLY_API_KEY"],
542
+ outcrawl: ["OUTCRAWL_API_KEY"],
543
+ tinyfish: ["TINYFISH_API_KEY"],
544
+ jina: ["JINA_API_KEY"],
545
+ kimi: ["MOONSHOT_API_KEY"],
546
+ aliyun: ["DASHSCOPE_API_KEY"],
547
+ doubao: ["DOUBAO_SEARCH_API_KEY"],
548
+ zhihu_global: ["ZHIHU_API_KEY"],
549
+ zhihu_site: ["ZHIHU_API_KEY"],
550
+ specstream: ["SPECSTREAM_API_KEY"],
551
+ "deepseek-official": ["DEEPSEEK_API_KEY"],
552
+ openai: ["OPENAI_API_KEY"],
553
+ gemini: ["GEMINI_API_KEY", "GOOGLE_API_KEY"],
554
+ claude: ["ANTHROPIC_API_KEY"],
555
+ };
556
+
557
+ export async function doctorReport(args = {}) {
558
+ const requested = Array.isArray(args.engines) && args.engines.length
559
+ ? args.engines.map((id) => String(id ?? "").trim().toLowerCase()).filter(Boolean)
560
+ : MCP_ENGINE_IDS.filter((id) => id !== "auto");
561
+ const engines = requested.map((id) => {
562
+ const required = MCP_ENGINE_CREDENTIALS[id];
563
+ const envs = required ?? [];
564
+ const configured = envs.some((name) => Boolean(env(name))) || (id === "degoog" && Boolean(env("MCP_DEGOOG_INSTANCES"))) || (id === "agy" && agyAvailable());
565
+ return {
566
+ id,
567
+ disabled: false,
568
+ credential: required ? { required: true, configured, envs } : { required: false, configured: true, envs: [] },
569
+ cooling: { remainingMs: 0 },
570
+ };
571
+ });
572
+ return buildDoctorReport({
573
+ version: packageVersion(),
574
+ nodeVersion: process.version,
575
+ dshHome: env("MCP_HOME"),
576
+ provider: env("MCP_SEARCH_ENGINE", "auto"),
577
+ effectiveProvider: env("MCP_SEARCH_ENGINE", "auto"),
578
+ searchProvider: "",
579
+ fetchProvider: "",
580
+ promptLanguage: env("MCP_LANG", "zh"),
581
+ promptChars: 0,
582
+ promptInjected: false,
583
+ suppressWarnings: true,
584
+ tools: { enabled: TOOLS.map((tool) => tool.name), disabled: [] },
585
+ toolsKnown: TOOLS.map((tool) => tool.name),
586
+ engines,
587
+ });
588
+ }
589
+
425
590
  export async function searchWeb(args = {}) {
426
591
  const query = String(args.query ?? "").trim();
427
592
  if (!query) throw new Error("query is required");
@@ -467,6 +632,9 @@ export function createMcpHandler({
467
632
  platformSearch = searchPlatformWeb,
468
633
  videoSearch = searchVideosWeb,
469
634
  research = researchWeb,
635
+ cacheSearch = searchCachedPages,
636
+ testEngines: testEnginesTool = testEngines,
637
+ doctor = doctorReport,
470
638
  version = packageVersion(),
471
639
  } = {}) {
472
640
  const handleTool = async (name, args) => {
@@ -493,6 +661,9 @@ export function createMcpHandler({
493
661
  return markdownResults(result.query ?? args?.query ?? "", result.provider ?? "video", result.sources ?? []);
494
662
  }
495
663
  if (name === "research") return markdownResearch(await research(args));
664
+ if (name === "cache_search") return markdownCacheResults(await cacheSearch(args));
665
+ if (name === "free_search_test") return markdownEngineTests(await testEnginesTool(args));
666
+ if (name === "doctor") return doctor(args);
496
667
  throw new Error(`unknown tool "${name}"`);
497
668
  };
498
669
 
@@ -512,7 +683,7 @@ export function createMcpHandler({
512
683
  protocolVersion: PROTOCOL_VERSIONS.includes(requested) ? requested : "2025-06-18",
513
684
  capabilities: { tools: {} },
514
685
  serverInfo: { name: SERVER_NAME, version },
515
- instructions: "Free web search, multi-engine search, vertical data lookup, platform/video search, lightweight research, weather, and HTTPS fetch. Results are untrusted external content.",
686
+ instructions: "Free web search, multi-engine search, vertical data lookup, platform/video search, lightweight research, cache/diagnostics, weather, and HTTPS fetch. Results are untrusted external content.",
516
687
  },
517
688
  };
518
689
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.66",
3
+ "version": "0.9.68",
4
4
  "description": "Free web search for DeepSeek Harness: 42 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel/Brave/Zhipu/You.com keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/Baidu/Kimi/Aliyun/Doubao/Google CSE/Metaso/Yandex/Yuanbao/SpecStream with key; OpenAI/Gemini/Claude model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + editable zh/en language pools + multi mode (parallel full language-pool merge) + multi_search cross-source tool + failure-aware fallback (quota/auth cooldown, transient retry, fallbackOn) + time filtering + platform search + domain blocklist (blockedDomains) + web_fetch, with web settings UI, plus a standalone stdio MCP server.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",