TinySearch

TinySearch

Shrink the web for your local LLMs! Provides web research capabilities to low resource models and environments.

Category
访问服务器

README

TinySearch

<p align="center"> <img src="assets/tinysearch_logo.png" alt="TinySearch" width="240" /> </p>

License Release Last commit MCP FastAPI TinySearch MCP server

A tiny local-first web research engine for MCP agents.

TinySearch searches the web, reranks results, crawls the best pages, extracts the most relevant chunks, and returns a source-grounded prompt your LLM can answer from.

<p align="center"> <img src="assets/demo_terminal_prompt.gif" alt="TinySearch terminal demo showing a source-grounded research prompt" width="780" /> </p>

No hosted dashboard. No account system. No analytics. No scraped-data cache.

Just search -> crawl -> rerank -> grounded prompt.

Quick start

Run TinySearch as an MCP server over Streamable HTTP:

docker run --rm -p 8000:8000 -e MCP_TRANSPORT=streamable-http -e MCP_HOST=0.0.0.0 marcellm01/tinysearch:latest

Then connect your MCP client to:

{
  "mcpServers": {
    "tinysearch": {
      "url": "http://localhost:8000/mcp"
    }
  }
}

TinySearch exposes one MCP tool:

research(query)

Pass the user's question as-is. TinySearch searches, crawls, reranks, and returns the grounded prompt in answer.

Why TinySearch?

  • Give local agents web research without wiring together a whole search stack.
  • Keep source URLs attached to the evidence your model sees.
  • Avoid dumping full webpages into context.
  • Use local ONNX embeddings or an OpenAI-compatible embedding API.
  • Run over MCP or a simple FastAPI endpoint.

TinySearch is built for local agents, prototypes, personal workflows, and small systems where source-grounded web research matters more than running a full search backend.

How it works

flowchart TB
    subgraph Row1["Search and choose pages"]
        direction LR
        A[User query] --> B[DuckDuckGo HTML search]
        B --> C[Filter HTTP results<br/>build title URL domain snippet docs]
        C --> D[Rank search docs<br/>dense + BM25 weighted RRF]
    end

    subgraph Row2["Crawl and build prompt"]
        direction LR
        E[Crawl kept URLs in parallel<br/>crawl4ai markdown] --> F[Truncate and chunk markdown]
        F --> G[Rank combined chunk pool<br/>dense + BM25 weighted RRF]
        G --> H[Dedupe chunks<br/>apply source quotas and fill]
        H --> I[Build source-grounded prompt]
    end

    Row1 --> Row2

TinySearch does not directly answer the question. It returns a structured prompt in the MCP tool's answer field, and your client model uses that prompt to produce the final cited response.

QUESTION
What happened in the latest NFL playoffs?

TODAY
2026-05-15

RESULTS
1. Title
   URL
   Relevant extracted text...

2. Title
   URL
   Relevant extracted text...

INSTRUCTIONS
Answer only from the results. Cite source URLs.

Run from source

Use this path if you want to inspect the code, edit TinySearch, or run it as a local stdio MCP server.

git clone https://github.com/MarcellM01/TinySearch
cd TinySearch

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

MCP clients spawn TinySearch from their config. Add it with absolute paths:

macOS / Linux:

{
  "mcpServers": {
    "tinysearch": {
      "command": "/absolute/path/to/TinySearch/.venv/bin/python",
      "args": [
        "/absolute/path/to/TinySearch/servers/mcp_server.py"
      ]
    }
  }
}

Windows:

{
  "mcpServers": {
    "tinysearch": {
      "command": "C:/absolute/path/to/TinySearch/.venv/Scripts/python.exe",
      "args": [
        "C:/absolute/path/to/TinySearch/servers/mcp_server.py"
      ]
    }
  }
}

Template config files live in mcp_templates/.

The repo also includes agentic_coding_templates/global-rules-recommended.md, a global-rules template for agentic coding tools such as Cline and Roo Code. These rules help coding agents call TinySearch only when web research is actually needed.

The server uses stdio by default, which is what Cursor and similar clients expect when they spawn python .../mcp_server.py. To run with sse or streamable-http, set MCP_TRANSPORT when starting the process. Do not put transport in configs/research_config.json.

Docker

The quick start command runs TinySearch over Streamable HTTP on http://localhost:8000/mcp. Docker pulls marcellm01/tinysearch:latest automatically if the image is not already local.

With MCP_TRANSPORT=streamable-http, the image serves Streamable HTTP on /mcp and SSE on /mcp/sse. GET requests to /mcp without an mcp-session-id are treated as the legacy SSE stream. If a client still cannot connect, try MCP_TRANSPORT=sse alone or the stdio Docker setup below.

Persistent models and config

For repeated use, keep downloaded models in a Docker volume and mount your local config:

docker run --rm \
  -p 8000:8000 \
  -v tinysearch-models:/data/models \
  -v "$PWD/configs/research_config.json:/config/research_config.json:ro" \
  -e TINYSEARCH_CONFIG_PATH=/config/research_config.json \
  -e MCP_TRANSPORT=streamable-http \
  -e MCP_HOST=0.0.0.0 \
  marcellm01/tinysearch:latest

MCP over stdio

Use this mode for MCP clients that launch tools as local commands instead of connecting to a URL. Replace /absolute/path/to/TinySearch with this repo's absolute path:

{
  "mcpServers": {
    "tinysearch": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-v",
        "tinysearch-models:/data/models",
        "-v",
        "/absolute/path/to/TinySearch/configs/research_config.json:/config/research_config.json:ro",
        "-e",
        "TINYSEARCH_CONFIG_PATH=/config/research_config.json",
        "-e",
        "TINYSEARCH_MODELS_DIR=/data/models",
        "marcellm01/tinysearch:latest"
      ]
    }
  }
}

Edit configs/research_config.json to choose embedding_model (fast, balanced, quality, or a custom Hugging Face ONNX repo id). The named Docker volume keeps downloaded model bundles between launches.

Optional HTTP server

Useful when you want HTTP instead of MCP:

uvicorn servers.fastapi_server:app --reload

Endpoints:

  • GET /health
  • GET /web_search?query=...
  • POST /site_crawl
  • POST /research

Configuration

Tune research defaults in configs/research_config.json. Set TINYSEARCH_CONFIG_PATH to load a different JSON config file, which is the recommended Docker override pattern.

The onnx embedding backend uses local ONNX bundles under models/. Starting the MCP server or FastAPI app downloads the configured embedding_model once from Hugging Face when embedding_backend is onnx.

Built-in local presets:

  • fast: onnx-models/all-MiniLM-L6-v2-onnx
  • balanced: BAAI/bge-small-en-v1.5
  • quality: BAAI/bge-base-en-v1.5

You can also set embedding_model to a custom Hugging Face ONNX repo id. Set TINYSEARCH_MODELS_DIR to move the model cache, or use TINYSEARCH_ONNX_MODEL_DIR when you need to point at one exact bundle directory.

Key settings:

  • Search: search_top_k, search_rrf_cutoff, search_dense_weight, search_max_results_to_keep
  • Chunks: chunk_rrf_cutoff, chunk_dense_weight, chunk_max_results_to_keep
  • Crawl: crawl_max_chunk_tokens, crawl_overlap_tokens, max_concurrent_crawls
  • Embeddings: embedding_backend, embedding_model, embedding_openai_env_file, max_concurrent_embedding_calls
  • Tokenizer: encoding_name
  • Dense input prefixes: dense_query_prefix, dense_document_prefix
  • Trace: trace_path

For embedding_backend openai_compatible, add a .env file at the project root, or set embedding_openai_env_file, with:

OPENAI_BASE_URL=
OPENAI_API_KEY=
OPENAI_EMBEDDING_MODEL=

OPENAI_BASE_URL is optional for api.openai.com. EMBEDDING_MODEL and MODEL_NAME are accepted as aliases for OPENAI_EMBEDDING_MODEL.

The research pipeline requires dense embeddings. It raises if search_dense_weight or chunk_dense_weight is set to 0.

When not to use TinySearch

TinySearch is not a replacement for a commercial search API or a persistent crawler. It is probably not the right tool if you need:

  • guaranteed search coverage
  • large-scale indexing
  • long-term page caching
  • enterprise observability
  • production SLA-backed web search

TinySearch vs...

Tool type What it gives you Tradeoff
Search API Search results Usually hosted / paid
Full crawler / index Persistent search backend More infrastructure
SearxNG Metasearch Still needs setup and a ranking layer
TinySearch MCP research prompt with ranked chunks Lightweight; not a full search engine

Entrypoints

  • pipelines.agentic_research.agentic_run: single-turn search, crawl, ranking, and prompt assembly
  • servers.mcp_server: MCP server for agent clients
  • servers.fastapi_server: optional HTTP API

Tests

Run the unittest suite:

python -m unittest discover tests

Contact

Using TinySearch or want to build on it?

Email me or reach me on Bluesky.

Privacy notes

TinySearch reads the pages it crawls and returns ranked excerpts to the calling client. It does not include credentials in the repo, and .env / trace output should stay local. If you enable openai_compatible embeddings, your embedding provider receives the text snippets sent for vectorization.

License

Source code in this repository is under the MIT License.

When embedding_backend is onnx, TinySearch may download the selected local ONNX embedding bundle at runtime from Hugging Face. Those weights are separate distributions under their model-card licenses; keep license and attribution notices if you ship or redistribute those files. Optional manual export for fast uses sentence-transformers/all-MiniLM-L6-v2 (Apache-2.0).

See NOTICE for Docker and third-party distribution notes.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选