npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stable-search-mcp

v0.2.1

Published

Pure Node.js MCP server for stable-search multi-source web search

Readme

stable-search MCP Server

stable-search-mcp 是一个可通过 npx 启动的 MCP 服务,用来把 stable-search 的多源搜索能力暴露给支持 MCP 的智能体。

当前实现已是 纯 Node.js + TypeScript,不再依赖外置 Python 运行时。这意味着:

  • 安装后只需 Node.js 即可运行
  • 可直接发布到 npm,并通过 npx stable-search-mcp 启动
  • 保留 Grok、Tavily、Exa、SearxNG 的多源编排、聚合、回退与排序能力

提供的 MCP Tools

stable_search

输入:

  • query:必填,搜索词
  • intent:可选,general | docs | news | overview
  • freshness:可选,day | week | month | year
  • limit:可选,返回结果上限,默认 12,最大 20

输出:

  • answer
  • results
  • citations
  • sourcesUsed
  • errors
  • meta
  • final
  • fetch
  • siteMap
  • providerDetails

stable_search_status

输出各 provider 是否已启用/已配置,并返回不含密钥的诊断信息:

  • Grok
  • Tavily
  • Exa
  • SearxNG

环境变量

按现有实现保持兼容,常用变量如下:

  • GROK_API_BASE_URL / GROK_API_URL
  • GROK_API_KEY
  • TAVILY_PROXY_URL
  • TAVILY_PROXY_KEY
  • EXA_POOL_URL
  • EXA_POOL_KEY
  • EXA_TIMEOUT
  • SEARXNG_URL
  • FIRECRAWL_API_URL
  • FIRECRAWL_API_KEY
  • STABLE_FETCH_DEFAULT
  • STABLE_FETCH_TOP_N
  • STABLE_FETCH_MAX_RETRIES
  • STABLE_USE_JINA
  • STABLE_USE_DEFUDDLE
  • STABLE_READER_TIMEOUT
  • STABLE_CACHE_TTL_SEC
  • STABLE_CACHE_MAX_ITEMS

其中有三项尤须公子自行显式设定,不再内置任何默认反代:

  • GROK_API_BASE_URLGROK_API_URL
  • TAVILY_PROXY_URL
  • SEARXNG_URL

程序会自动读取项目根目录下的 .env,亦可直接由 MCP 客户端通过 env 注入。

请使用 .env.example 作为占位模板;切勿将真实密钥写入仓库。

本地运行

安装依赖

npm install

开发模式

npm run dev

构建

npm run build

启动 MCP 服务

npm start

若公子使用 .env,可直接在项目根目录放置该文件后再启动,无须另手导入。

或在发布后通过:

npx stable-search-mcp

冒烟自测

检查配置状态:

npm run smoke:status

执行一次搜索:

npm run smoke:search

MCP 客户端配置示例

本地源码方式

{
  "mcpServers": {
    "stable-search": {
      "command": "npm",
      "args": ["start"],
      "cwd": "/absolute/path/to/stable-search",
      "env": {
        "GROK_API_KEY": "<secret>",
        "TAVILY_PROXY_KEY": "<secret>",
        "EXA_POOL_URL": "https://exa-pool.example.com",
        "EXA_POOL_KEY": "<secret>",
        "SEARXNG_URL": "https://searxng.example.com"
      }
    }
  }
}

npx 方式

{
  "mcpServers": {
    "stable-search": {
      "command": "npx",
      "args": ["stable-search-mcp"],
      "env": {
        "GROK_API_KEY": "<secret>",
        "TAVILY_PROXY_KEY": "<secret>"
      }
    }
  }
}

示例 Tool Calls

stable_search

{
  "query": "OpenAI GPT-5.4 release notes",
  "intent": "docs",
  "freshness": "month",
  "limit": 8
}

stable_search_status

{}

架构说明

当前版本是 纯 Node.js MCP 服务

  • src/index.ts:MCP 服务入口,定义 tools,并通过 stdio 提供服务
  • src/search-core.ts:搜索编排、聚合、回退、抓取与结果整形
  • src/providers.ts:Grok、Tavily、Exa、SearxNG、Firecrawl 与 reader fallback 调用
  • src/utils.ts:评分、去重、缓存、意图判断与公共工具

兼容策略

  • 继续保留 intentfreshnesslimit 这些面向 MCP 的稳定输入
  • freshness 仍做 day/week/month/year -> pd/pw/pm/py 的内部映射
  • 输出结构继续保持 agent-friendly 与稳定 JSON 形态

当前限制

  • npx stable-search-mcp 仍需先将本包发布到 npm
  • provider 可用性仍取决于环境变量与上游服务是否可达
  • 仓中的 stable_search.py 仅作迁移参照,运行时已不再依赖它
  • GrokTavilySearxNG 不再带任何默认代理地址,未配置时会在 stable_search_status 中直接显示未就绪

npm 发布步骤

  1. 登录 npm:
npm login
  1. 确认包名是否可用;若需改名,请修改 package.json 中的 name

  2. package.json 中这些占位值改成真实仓库地址:

  • repository.url
  • homepage
  • bugs.url
  1. 构建并检查打包内容:
npm run build
npm pack --dry-run
  1. 正式发布:
npm publish

若要发布 scoped 包,如 @scope/stable-search-mcp,请同步调整 name,并保留 publishConfig.accesspublic

后续建议

  • 增加自动化测试,覆盖 stable_searchstable_search_status
  • 发布到 npm 后验证 npx stable-search-mcp 的安装与启动体验
  • 若要进一步提升可维护性,可将 provider 请求层拆得更细,并补录 fixture 测试