Back to MCP directory
publicPublicdnsLocal runtime

tool4lm

TOOL4LM是一个为本地语言模型提供多工具支持的MCP服务器,集成了网页搜索、文档读取、学术查询和计算器等功能,无需默认API密钥即可增强模型能力。

article

README

🚀 TOOL4LM — 本地大语言模型的多功能MCP服务器

TOOL4LM是一款强大的MCP(模型上下文协议)服务器,由Node.js和TypeScript编写,专为本地运行的大语言模型(如LM Studio、Ollama等)提供丰富的工具支持。它集成了网页搜索、网页读取与总结、内部文档搜索与读取、学术检索以及计算等功能,且默认无需API密钥,能显著提升本地或远程大语言模型的使用效率和体验。

🚀 快速开始

按照以下步骤安装并运行TOOL4LM:

npm install
npm run build
npm start

当成功运行时,会输出如下信息: [TOOL4LM] started. Sandbox: <沙盒路径>

✨ 主要特性

  • 🔎 网页搜索:支持多源搜索(SearXNG + DuckDuckGo HTML),自动去重,返回标题、URL和摘要。
  • 🌐 网页抓取/读取:可在限制大小和时间的情况下下载网页(防止服务器端请求伪造),并提取“可读”文本进行总结。
  • 📂 文档搜索/读取:能在沙盒目录中搜索并读取文档(支持txt、md、html、pdf格式)。对于PDF文件,使用pdf-parse进行懒加载。
  • 📚 学术搜索/获取:支持学术检索(arXiv + Crossref + Wikipedia),并可根据DOI/arXivId获取论文元数据。
  • 🧮 计算器:使用mathjs评估表达式,支持设置精度(四舍五入)。

📦 安装指南

安装依赖并启动服务

npm install
npm run build
npm start

LM Studio的MCP配置

在LM Studio的mcp.json文件中添加以下配置:

{
  "mcpServers": {
    "TOOL4LM": {
      "command": "node",
      "args": ["--enable-source-maps", "C:/path/to/tool4lm/dist/server.js"],
      "type": "mcp",
      "env": {
        "SANDBOX_DIR": "C:/path/to/your_docs",
        "SEARXNG_ENDPOINTS": "https://searx.be/search,https://searx.tiekoetter.com/search",
        "ENGINE_ORDER": "searxng,duckduckgo",
        "LANG_DEFAULT": "vi",
        "REGION_DEFAULT": "vn",
        "MAX_FETCH_BYTES": "1048576",
        "FETCH_TIMEOUT_MS": "8000"
      }
    }
  }
}

⚠️ 重要提示 在Windows系统中,建议在JSON文件中使用/来避免对\进行转义。

💻 使用示例

网页搜索引用流程

web.searchweb.fetchweb.read → 总结并附加URL。

内部文档处理流程

doc.finddoc.read → 总结并引用段落(附上path)。

学术检索流程

sch.search → 根据DOI/arXivId使用sch.get

计算操作

使用calc.eval,支持^/pow(a,b)(或已规范化的**)。

📚 详细文档

工具与参数(主名称 ⇄ 下划线别名)

| 工具 | 使用场景 | 参数(格式) | |------|----------|--------------| | calc.evalcalc_eval | 本地计算 | { expr: string, precision?: number } | | web.searchweb_search | 多引擎网页搜索 | { q: string, max?: number, lang?: string, site?: string, engines?: string[], k?: number, limit?: number } | | web.fetchweb_fetch | 下载单个URL(HTML/二进制) | { url: string, timeout?: number, max_bytes?: number, headers?: Record<string,string> } | | web.readweb_read | 提取“可读”文本 | { url: string, html?: string } | | doc.finddoc_find | 在沙盒目录中搜索 | { q: string, top?: number, limit?: number } | | doc.readdoc_read | 读取沙盒中的单个文件 | { path: string } | | index.buildindex_build | 构建文档索引 | { root?: string } | | sch.searchsch_search | 搜索论文/文献/DOI | { q: string, top?: number, limit?: number } | | sch.getsch_get | 获取论文元数据 | { doi?: string, arxivId?: string, url?: string } | | wiki.searchwiki_search | 搜索维基百科标题 | { q: string, lang?: string } | | wiki.getwiki_get | 获取维基百科摘要 | { title: string, lang?: string } |

💡 使用建议 由于已开启openWorldHint,即使模型意外添加了额外字段,服务器仍会接受;但建议按照表格中的参数准确使用,以确保稳定性。

环境变量

  • SANDBOX_DIR — 文档目录(默认:./sandbox)。
  • SEARXNG_ENDPOINTS — SearXNG的/search端点列表,用逗号分隔。
  • ENGINE_ORDER — 例如searxng,duckduckgo
  • LANG_DEFAULT, REGION_DEFAULT — 网页搜索时的语言/地区建议。
  • MAX_FETCH_BYTES — 网页下载大小限制。
  • FETCH_TIMEOUT_MS — 网页下载超时时间(毫秒)。

🤝 贡献

非常欢迎提交问题(Issues)和拉取请求(PRs)!如果发现任何问题或有相关建议,请帮忙创建一个问题。

📄 许可证

本项目采用MIT许可证。

☕ 支持

如果您觉得这个项目有用,可以通过PayPal支持我:

通过PayPal捐赠

或者点击下面的按钮:

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client