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: LightRAG MCP Server
빠른 시작
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. 자세한 내용은 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。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceA comprehensive MCP server that provides full integration with LightRAG API, offering 22 tools across document management, querying, knowledge graph operations, and system management.37MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI clients to interact with a LightRAG knowledge graph server via MCP, providing 30 tools for queries, document management, and graph operations.283MIT
- FlicenseNot gradedqualityCmaintenanceEnables building and querying knowledge graphs by ingesting documents into Neo4j using Gemini for entity extraction, and exposes MCP tools for graph health, document ingestion, and knowledge base querying.
- AlicenseNot gradedqualityBmaintenanceEnables document-based Q&A with multi-modal RAG, hybrid retrieval, knowledge graph reasoning, and multi-agent orchestration via MCP tools.4MIT
Related MCP Connectors
Knowledge coverage map and health score. Ingest docs into a governed knowledge graph via MCP.
Manage SRG+ hubs, channels, content, assets, users, and workspaces from any MCP-aware AI agent.
Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/guazixiong/sag-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server