Swarms MCP Documentation Server

Swarms MCP Documentation Server

An Agent Framework Documentation server that enables AI agents to efficiently retrieve information from documentation databases using hybrid semantic and keyword search for seamless agent integration.

Category
访问服务器

README

🐝 Swarms MCP Documentation Server

<p align="center"> <img src="https://img.shields.io/badge/Windsurf_Ready-✅-orange" alt="IDE Ready"> <img src="https://img.shields.io/badge/Error_Tolerant-✅-green" alt="Error Tolerant"> <img src="https://img.shields.io/badge/Dynamic_MD_Loader-✅-blue" alt="Dynamic MD Loader"> <img src="https://img.shields.io/badge/Healthcheck_Tool-✅-success" alt="Healthcheck Tool"> <img src="https://img.shields.io/badge/Smart_Load_Logs-✅-purple" alt="Smart Load Logs"> </p>

Version 2.2


📖 Description

This program is an Agent Framework Documentation MCP Server built on FastMCP, designed to enable AI agents to efficiently retrieve information from your documentation database. It combines hybrid semantic (vector) and keyword (BM25) search, chunked indexing, and a robust FastMCP tools API for seamless agent integration.

Key Capabilities:

  • Efficient, chunk-level retrieval using both semantic and keyword search
  • Agents can query, list, and retrieve documentation using FastMCP tools
  • Local-first, low-latency design (all data indexed and queried locally)
  • Automatic reindexing on file changes
  • Modular: add any repos to corpora/, support for all major filetypes
  • Extensible: add new tools, retrievers, or corpora as needed

Main modules:

  • embed_documents.py → Loads, chunks, and embeds documents
  • swarms_server.py → Brings up the MCP server and FastMCP tools


🌟 Key Features

  • Hybrid Retriever 🔍: Combines semantic and keyword search.
  • Dynamic Markdown Handling 📄: Smart loader based on file size.
  • Specialized Loaders ⚙️: .py, .ipynb, .md, .txt, .yaml, .yml.
  • Chunk and File Summaries 📈: Displays chunk counts along with file counts.
  • Live Watchdog 🔥: Instantly responds to any changes in corpora/.
  • User Confirmation for Costs ✅: Confirms before expensive embeddings.
  • Healthcheck Endpoint 🚑: Ensure server is ready for use.
  • Local-First 🗂️: All repos indexed locally without external dependencies.
  • Safe Deletion Helper 🔥: Auto-delete broken/mismatched indexes.

🏗️ Version History

Version Date Highlights
2.2 2025‑04‑25 Split embed/load from server; full chunk counting in loading summaries
1.0 2025‑04‑25 Dynamic Markdown loader, color logs, Healthcheck tool
0.7 2025‑04‑25 Specialized file loaders for .py, .ipynb, .md
0.5 2025‑04‑10 OpenAI large model embeddings, extended MCP tools
0.1 2025‑04‑10 Initial version with generic loaders

📚 Managing Your Corpora (Local Repos)

Because Swarms and other frameworks are very large, full corpora are not pushed to GitHub.

Instead, you clone them manually under corpora/:

# Inside your project folder:
cd corpora/

# Clone useful frameworks:
git clone https://github.com/SwarmsAI/Swarms
git clone https://github.com/SwarmsAI/Swarms-Examples
git clone https://github.com/microsoft/autogen
git clone https://github.com/langchain-ai/langgraph
git clone https://github.com/openai/openai-agent-sdk

Notes:

  • Add any repo — public, private, custom.
  • Build your own custom AI knowledge base locally.
  • Large repos (>500MB) are fine; all indexing is local.

🚀 Quick Start

# 1. Activate virtual environment
venv\Scripts\Activate.ps1

# 2. Install all dependencies
pip install -r requirements.txt

# 3. Configure OpenAI API Key
echo OPENAI_API_KEY=sk-... > .env

# 4. (Load and embed documents
python embed_documents.py

# 5. Start MCP server
python swarms_server.py
# If no index is found, the server will prompt you to embed documents automatically.

⚙️ Configuration

  • Corpus: Drop repos inside corpora/
  • Environment Variables:
    • .env must contain OPENAI_API_KEY
  • Index File Support:
    • Both chroma-collections.parquet and chroma.sqlite3 are supported. .parquet is preferred if both exist.
  • Auto-Embedding:
    • If no index is found, the server will prompt you to embed and index your documents automatically.
  • Optional:
    • Disable Chroma compaction if you prefer:
      setx CHROMA_COMPACTION_SERVICE__COMPACTOR__DISABLED_COLLECTIONS "swarms_docs"
      
  • Command-Line Flags:
    • --reindex → trigger a refresh reindex during server run.

🔄 File Watching & Auto Reindexing

The MCP Server watches corpora/ for any file changes:

  • Any modification, creation, or deletion triggers a live reindex.
  • No need to restart the server.

🛠️ Available FastMCP Tools

Tool Description
swarm_docs.search Search relevant documentation chunks
swarm_docs.list_files List all indexed files
swarm_docs.get_chunk Get a specific chunk by path and index
swarm_docs.reindex Force reindex (full or incremental)
swarm_docs.healthcheck Check MCP Server status

❓ Troubleshooting

  • Q: I get 'No valid existing index found' when starting the server.
    • A: The server will now prompt you to embed and index documents. Accept the prompt to proceed, or run python embed_documents.py manually first.
  • Q: Which index file is used?
    • A: The server will use chroma-collections.parquet if available, otherwise chroma.sqlite3.
  • Q: I want to force a reindex.
    • A: Run python swarms_server.py --reindex or use the swarm_docs.reindex tool.

📋 Example Usage

# Search the documentation
result = swarm_docs.search("How do I load a notebook?")
print(result)

# List all available files
files = swarm_docs.list_files()
print(files)

# Get a specific document chunk
chunk = swarm_docs.get_chunk(path="examples/agent.py", chunk_idx=2)
print(chunk["content"])

🧰 Extending & Rebuilding

  • Add new docs → drop into corpora/, then:

    python swarms_server.py --reindex
    
  • Schema changes → (e.g. different metadata structure):

    python swarms_server.py --reindex --full
    
  • Add new repo → Drop folder under corpora/, reindex.

  • Recommended for mostly read-only repos:

    setx CHROMA_COMPACTION_SERVICE__COMPACTOR__DISABLED_COLLECTIONS "swarms_docs"
    

🔗 IDE Integration

Plug directly into Windsurf Cascade:

"swarms": {
  "command": "C:/…/Swarms/venv/Scripts/python.exe",
  "args": ["swarms_server.py"]
}

Then you can access swarm_docs.* tools from Cascade automations.


📦 Requirements

💡 Python 3.11 Environment Required

Create your environment explicitly:

python3.11 -m venv venv

Then install with:

pip install -r requirements.txt

✅ MCP Server Ready

After boot:

  • Proper loading summaries
  • Safe confirmation before expensive actions
  • Auto file watching and reindexing
  • Windsurf plug-in ready
  • Full tool coverage

You're good to cascade it! 🏄‍♂️


📈 Flow Diagram

                          +------------------+
                          |    🖥️ MCP Server  |
                          +------------------+
                                  |
     +---------------------------------------------------+
     |                                                   |
+-------------+                                     +-----------------+
|  📁 Corpora |                                     | 🔎 FastMCP Tools |
|  Folder     |                                     | (search, list,   |
|  (markdown, |                                     | get_chunk, etc.) |
|  code, etc) |                                     +-----------------+
+-------------+                                               |
      |                                                       |
+-----------------+                                   +----------------+
|  📚 Loaders      |                                   | 🧠 Ensemble    |
| (Python, MD, TXT)|                                   | Retriever (BM25|
|  Split into Chunks|                                  | + Chroma)      |
+-----------------+                                   +----------------+
      |                                                       |
+-----------------+                                   +----------------+
| ✂️ Text Splitter |                                   | 🧩 Similarity   |
| (RecursiveCharacter) |                              | Search (chunks) |
+-----------------+                                   +----------------+
      |                                                       |
+-----------------+                                   +----------------+
| 💾 Embed chunks  |  —OpenAI Embedding (small)—>    | 🛢️ Chroma Vector |
| via OpenAI API  |                                   | DB (Local Store) |
+-----------------+                                   +----------------+
      |                                                       |
+-----------------+                                   +----------------+
| 📡 Reindex Watcher|                                  | 👀 File Watchdog |
| (Auto detect      |                                  | (Auto reindex   |
| new/modified files|                                  | on file events) |
+-----------------+                                   +----------------+

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选