本地语言模型多工具服务器

TOOL4LM是一个基于Node.js/TypeScript的MCP服务器,为本地语言模型提供多种工具支持,包括网页搜索、文档阅读与摘要、学术查询和计算功能。

  • by khanhs-234
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 khanhs-234/tool4lm

使用说明

TOOL4LM — Multi-Tool MCP Server for Local LMs

All-in-one tools to supercharge your local or remote LLMs.
Search smarter. Calculate faster. Summarize better.

TOOL4LM là một MCP (Model Context Protocol) server written in Node.js/TypeScript help supplement tools for locally running language models (LM Studio/Ollama/...): web search, Read & summarize the page, Find & read internal documents, Academic research, và computerNo default API key is required.


✨ Feature

  • 🔎 Web SearchFind multiple sources (SearXNG + DuckDuckGo HTML), deduplicate, return title + URL + snippet.
  • 🌐 Web Fetch/ReadLoad pages with size/time limits (anti-SSRF) and extract "readable" text for summarization.
  • 📂 Doc Search/ReadFind & read documents in the sandbox folder (txt/md/html/pdf). PDF is used. pdf-parse (lazy-load).
  • 📚 Scholar Search/GetAcademic search (arXiv + Crossref + Wikipedia) and retrieve metadata by DOI/arXivId.
  • The emoji "🧮" represents a calculator CalculatorEvaluate the expression with mathjssupport precision (round).

Tool & parameters (main name ⇄ underlined alias)

Tool When to use Parameters (shape)
calc.eval ⇄ (This symbol represents a bidirectional arrow, often used in various contexts such as indicating two-way communication, movement, or relationships.) calc_eval Local computation { expr: string, precision?: number }
web.search ⇄ (This symbol is often used to represent a back-and-forth motion or a reciprocal relationship in various contexts, but it does not have a direct translation in English as it is more of a conceptual or visual symbol.) web_search Multi-engine web search { q: string, max?: number, lang?: string, site?: string, engines?: string[], k?: number, limit?: number }
web.fetch ⇄ web_fetch Download 1 URL (HTML/binary) { url: string, timeout?: number, max_bytes?: number, headers?: Record<string,string> }
web.read ⇄ web_read "Readable" text excerpt { url: string, html?: string }
doc.find ⇄ doc_find Search in sandbox folder { q: string, top?: number, limit?: number }
doc.read ⇄ doc_read Read a file in the sandbox { path: string }
index.build ⇄ index_build Build document index { root?: string }
sch.search ⇄ sch_search Find article/paper/DOI { q: string, top?: number, limit?: number }
sch.get ⇄ (This symbol is a bidirectional arrow, often used to indicate a reversible or two-way relationship.) sch_get Retrieve metadata paper { doi?: string, arxivId?: string, url?: string }
wiki.search ⇄ wiki_search Find Wikipedia Title { q: string, lang?: string }
wiki.get ⇄ wiki_get Take Wikipedia summary { title: string, lang?: string }

Turned on openWorldHint So if the model accidentally adds an extra field, the host will still accept it; but it is recommended to use the correct parameters as specified in the table for stability.


🔧 Install & run

npm install
npm run build
npm start

When run successfully, it will print:
[TOOL4LM] started. Sandbox: <đường_dẫn_sandbox>


⚙️ MCP Configuration (LM Studio)

Add to mcp.json of LM Studio:

{
  "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"
      }
    }
  }
}

On Windows, it is recommended to use / in JSON to avoid escaping \.


📝 Example of usage flow

Web search with citations → web.search → web.fetch → web.read → summary + attach URL.
Internal document → doc.find → doc.read summary + excerpt (with notes included path)
Academic → sch.search → sch.get theo DOI/arXivId.
Calculation → calc.eval with ^/pow(a,b) (or has been normalized **)


Environmental change

  • SANDBOX_DIR — document folder (default: ./sandbox)
  • SEARXNG_ENDPOINTS — list of endpoints /search of SearXNG, separated by commas.
  • ENGINE_ORDER — for example searxng,duckduckgo
  • LANG_DEFAULT, REGION_DEFAULT — language/region suggestions when searching for a website.
  • MAX_FETCH_BYTES — page load capacity limit.
  • FETCH_TIMEOUT_MS — page load timeout (ms).

🤝 Contribution

Issues/PRs are very welcome! If you find any bugs/suggestions, please open an issue for me.


📜 License

MIT


☕ Support

If you find the project useful, you can support me via PayPal:

or click the button below: