SAG MCP Server
SAG MCP Server
SAG ナレッジベースのための読み書き対応 MCP サーバー。Streamable HTTP トランスポートで 18 個のツールを公開し、Claude Desktop、Cursor、VS Code、およびあらゆる MCP クライアントと互換性があります。
特徴
18 ツール: ソース/ドキュメントの CRUD、セマンティック検索、ナレッジグラフクエリ、モデル設定
Streamable HTTP: ローカル依存なしで任意の MCP クライアントから接続可能
Bearer 認証: JWT トークン認証を内蔵
ゼロ設定: 実行中の SAG インスタンスとそのまま連携
Related MCP server: fayna-rag-mcp
クイックスタート
1. 前提条件
実行中の SAG インスタンス(Docker またはネイティブ)。SAG デプロイガイド を参照してください。
2. インストール
pip install sag-mcp-serverまたはソースから:
git clone https://github.com/Zleap-AI/sag-mcp-server.git
cd sag-mcp-server
pip install -e .3. 起動
HTTP モード(推奨):
export SAG_API_URL=http://your-sag-host:9002
sag-mcp-server http 9003stdio モード(ローカル統合用):
sag-mcp-server stdio4. Claude Desktop から接続
claude_desktop_config.json に追加:
{
"mcpServers": {
"sag": {
"type": "http",
"url": "http://your-sag-host:9003/mcp/",
"headers": {
"Authorization": "Bearer <your-jwt-token>"
}
}
}
}トークンを取得:
curl -s -X POST http://your-sag-host:9002/api/v1/auth/login \
-H 'Content-Type: application/json' -d '{"name":"Admin"}' \
| python3 -c "import sys,json;print(json.load(sys.stdin)['access_token'])"ツール
カテゴリ | ツール | 説明 |
ソース |
| すべてのナレッジベースソースを一覧表示 |
| 新しいソースを作成 | |
| ソースとそのすべてのデータを削除 | |
ドキュメント |
| ソース内のドキュメントを一覧表示 |
| ローカルファイルをアップロード(自動解析+抽出) | |
| テキストを直接書き込む(ファイル不要) | |
| ドキュメントを再処理 | |
| 処理を一時停止 | |
| 処理を再開 | |
| ドキュメントを削除 | |
検索 |
| LLM サマリー付きセマンティック検索 |
| ナレッジグラフのエンティティを照会 | |
| ドキュメントのアウトラインを取得 | |
| キーワード/正規表現検索 | |
| ドキュメント全文を読み取る | |
設定 |
| モデル設定を表示 |
| モデル設定を更新 | |
| モデルの接続をテスト |
設定
すべての設定は環境変数で行います:
変数 | デフォルト | 説明 |
|
| SAG API ベース URL |
| (空=自動ログイン) | JWT Bearer トークン |
|
| ログインユーザー名(トークンが空の場合) |
|
| HTTP サーバーポート |
クライアント設定
Claude Desktop
{
"mcpServers": {
"sag": {
"type": "http",
"url": "http://your-sag-host:9003/mcp/",
"headers": { "Authorization": "Bearer <token>" }
}
}
}Cursor
~/.cursor/mcp.json:
{
"mcpServers": {
"sag": {
"type": "http",
"url": "http://your-sag-host:9003/mcp/",
"headers": { "Authorization": "Bearer <token>" }
}
}
}Dify
タイプ: Streamable HTTP
URL:
http://your-sag-host:9003/mcp/ヘッダー:
Authorization: Bearer <token>
Docker
SAG と一緒にコンテナとして実行:
# docker-compose.yml addition
services:
mcp:
build: .
environment:
SAG_API_URL: http://api:8000
SAG_SECRET_KEY: ${SAG_SECRET_KEY}
ports:
- "9003:9003"
command: ["sag-mcp-server", "http", "9003"]
depends_on:
api:
condition: service_healthy開発
git clone https://github.com/Zleap-AI/sag-mcp-server.git
cd sag-mcp-server
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check src/API 互換性
SAG v0.7.x+ が必要で、以下のエンドポイントをサポートします:
POST /api/v1/auth/login— JWT 認証GET/POST/DELETE /api/v1/sources— ソース CRUDGET/POST/DELETE /api/v1/sources/{id}/documents— ドキュメント CRUDPOST /api/v1/search— セマンティック検索GET /api/v1/system/model-config— モデル設定
ライセンス
MIT ライセンス。詳細は LICENSE を参照してください。
中文文档
基于 SAG 知识库的读写 MCP Server。通过 Streamable HTTP 暴露 18 个工具,兼容 Claude Desktop、Cursor、VS Code 及所有 MCP 客户端。
特性
18 个工具:信源/文档增删改查、语义检索、知识图谱查询、模型配置
Streamable HTTP:无需本地安装任何依赖,客户端通过 HTTP 直连
Bearer 鉴权:内置 JWT token 认证
零配置:与运行中的 SAG 实例直接配合使用
快速开始
1. 前提条件
运行中的 SAG 实例(Docker 或原生部署)。参见 SAG 部署指南。
2. 安装
pip install sag-mcp-server或从源码安装:
git clone https://github.com/Zleap-AI/sag-mcp-server.git
cd sag-mcp-server
pip install -e .3. 启动
HTTP 模式(推荐):
export SAG_API_URL=http://your-sag-host:9002
sag-mcp-server http 9003stdio 模式(本地集成):
sag-mcp-server stdio4. 连接 Claude Desktop
编辑 claude_desktop_config.json:
{
"mcpServers": {
"sag": {
"type": "http",
"url": "http://your-sag-host:9003/mcp/",
"headers": {
"Authorization": "Bearer <your-jwt-token>"
}
}
}
}获取 token:
curl -s -X POST http://your-sag-host:9002/api/v1/auth/login \
-H 'Content-Type: application/json' -d '{"name":"Admin"}' \
| python3 -c "import sys,json;print(json.load(sys.stdin)['access_token'])"工具清单
类别 | 工具 | 说明 |
信源 |
| 列出所有知识库信源 |
| 创建新信源 | |
| 删除信源及全部数据 | |
文档 |
| 列出信源下文档 |
| 上传本地文件(自动解析+抽取) | |
| 直接写入文本(无需文件) | |
| 重新处理文档 | |
| 暂停处理 | |
| 恢复处理 | |
| 删除文档 | |
检索 |
| 语义检索(含 LLM 摘要) |
| 查询知识图谱实体 | |
| 获取文档大纲 | |
| 关键词/正则检索 | |
| 读取文档全文 | |
模型 |
| 查看模型配置 |
| 更新模型设置 | |
| 测试模型连通性 |
配置说明
所有配置通过环境变量:
变量 | 默认值 | 说明 |
|
| SAG API 地址 |
| (空=自动登录) | JWT Bearer token |
|
| 登录用户名(token 为空时生效) |
|
| HTTP 服务端口 |
客户端配置
Claude Desktop
{
"mcpServers": {
"sag": {
"type": "http",
"url": "http://your-sag-host:9003/mcp/",
"headers": { "Authorization": "Bearer <token>" }
}
}
}Cursor
~/.cursor/mcp.json:
{
"mcpServers": {
"sag": {
"type": "http",
"url": "http://your-sag-host:9003/mcp/",
"headers": { "Authorization": "Bearer <token>" }
}
}
}Dify
类型:Streamable HTTP
URL:
http://your-sag-host:9003/mcp/请求头:
Authorization: Bearer <token>
Docker 部署
与 SAG 一起以容器方式运行:
# 添加到 docker-compose.yml
services:
mcp:
build: .
environment:
SAG_API_URL: http://api:8000
SAG_SECRET_KEY: ${SAG_SECRET_KEY}
ports:
- "9003:9003"
command: ["sag-mcp-server", "http", "9003"]
depends_on:
api:
condition: service_healthy开发指南
git clone https://github.com/Zleap-AI/sag-mcp-server.git
cd sag-mcp-server
pip install -e ".[dev]"
# 运行测试
pytest
# 代码检查
ruff check src/API 兼容性
需要 SAG v0.7.x+,支持以下接口:
POST /api/v1/auth/login— JWT 认证GET/POST/DELETE /api/v1/sources— 信源增删改查GET/POST/DELETE /api/v1/sources/{id}/documents— 文档增删改查POST /api/v1/search— 语义检索GET /api/v1/system/model-config— 模型配置
许可证
MIT License。详见 LICENSE。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
MCP facade over the Nebelus Construction API. ~48 tools give full agent build parity: create/update/probe agents, edit graphs, attach knowledge and vector stores, wire connectors, set governance policies and locked guardrails, enable grounding-trace, and read deployment wiring. Purpose-built for regulated industries: data residency is enforced per region (EU / GCC-KSA), with PII controls and an audit trail. Agents are created as drafts — no deploy tool is exposed over MCP by design; publishing happens in the Nebelus console.
Make your knowledge agent-ready. One MCP endpoint, 5 connectors, 3 search modes.
The knowledge base your AI reads and writes, under your rules — over MCP, EU-hosted.
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server that provides full integration with LightRAG API, offering 22 tools across document management, querying, knowledge graph operations, and system management.38MIT

fayna-rag-mcpofficial
AlicenseNot gradedqualityDmaintenanceEnables local knowledge base management with retrieval-augmented generation (RAG), providing semantic search, document reading, listing, and Q&A via MCP tools and REST endpoints, all running locally without cloud dependencies.MIT- FlicenseNot gradedqualityBmaintenanceEnables to build and query a knowledge base with retrieval-augmented generation, supporting document ingestion, hybrid search, and live data integration from external APIs via MCP tools.2-
- FlicenseNot gradedqualityCmaintenanceEnables AI agents and users to search a unified organizational knowledge warehouse, create and iterate on documents, manage folders and reviews, and curate shareable knowledge packs through any compatible MCP client.-