Glean Chatbot
Glean Chatbot
将一小批内部合同文档索引到 Glean,通过 Search + Chat 解答这些文档中的问题,并将同一流程以 MCP 工具(ask_glean)的形式提供。
要求
Python 3.10+
一个 Glean 实例
一个 Indexing API 令牌
一个包含 Search 和 Chat 作用域的 Client API 令牌
Related MCP server: search-context
安装与设置
克隆并进入仓库:
git clone <your-repo-url>
cd glean-chatbot安装依赖:
pip install -r requirements.txt根据示例创建
.env并填入你的取值:
# macOS / Linux
cp .env.example .env
# Windows (PowerShell)
copy .env.example .env变量 | 是否必需 | 用途 |
| 是 | 实例名称( |
| 是 | Indexing API 令牌 |
| 是 | Client API 令牌(支持 Search + Chat) |
| 是* | 用于 |
| 否 | 数据源名称(默认为 |
| 否 | 在 Glean UI 中显示的名称 |
| 否 | 每个文档 |
.env 由 config.py 自动加载(通过 python-dotenv),无需手动 source。
运行
为文档建立索引
python scripts/index_documents.py
# optional: wait until Search can find them
python scripts/index_documents.py --verify从 CLI 提问
python scripts/ask.py "Who owns the Enronry Tony contract?"
python scripts/ask.py "What must OKLightning Tony deliver before go-live?" --top-k 3MCP (Cursor)
项目配置文件位于 .cursor/mcp.json(包含 src/mcp_server.py 的绝对路径以及环境变量)。编辑后重启 Cursor / 重新加载 MCP。工具名为 ask_glean。
单独对服务器进行冒烟测试:
python src/mcp_server.py测试
python tests/test_pipeline.py不访问网络;模拟 Search/Chat。
工作原理
scripts/index_documents.py 通过 Indexing API 将 data/documents.json 推送为索引。查询时,src/pipeline.py 先调用 Search,然后在存在命中结果时,把命中内容作为闭卷上下文调用 Chat,并返回答案和来源。CLI 和 MCP 都调用同一个 pipeline。结果被限制在我们自己的文档范围内;如果 Search 没有返回任何内容,我们会推荐相近的文档标题,而不是凭空编造答案。
备注 / 限制
共享沙箱会忽略
datasourcesFilter;我们在客户端按文档 id 前缀(CUSTOM_<DATASOURCE>_Contract_)进行过滤。索引是异步的——文档可能需要几分钟才能被搜索到。
演示文档使用了
allowAnonymousAccess: true。请勿将其带到生产环境。文档的
viewURL必须匹配GLEAN_URL_REGEX,否则索引会将其拒绝。
关于 API 的取舍与生产环境注意事项,请参阅 DESIGN_NOTE.md。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Cited answers from your organisation's documents. GDPR-compliant, hosted in Germany.
Answer questions using your semantic layer and company knowledge graph.
Find recorded calls and meetings, read transcripts, and ask questions grounded in your recordings.
Your company brain: search decisions, people, customers and projects across connected sources.
Related MCP Servers
AlicenseNot gradedqualityDmaintenanceEnables AI assistants and developer tools to securely access and interact with an organization's enterprise knowledge, documents, and people through natural language while respecting existing access permissions.166MIT- AlicenseAqualityFmaintenanceEnables semantic search across documentation stored in Gemini FileSearchStores, returning AI-generated answers with source citations.11MIT

Rememberizer MCP Serverofficial
AlicenseNot gradedqualityDmaintenanceEnables querying and managing personal/team internal knowledge from sources like Slack, Gmail, and Drive through semantic search and retrieval.Apache 2.0- FlicenseNot gradedqualityDmaintenanceEnables searching a knowledge base and asking grounded questions with hybrid retrieval, reranking, and cited answers.-