Glean Chatbot
Enables querying internal documents indexed in Glean through a natural-language chat interface, returning answers with cited sources.
README
Glean Chatbot
Indexes a small set of internal contracts into Glean, answers questions from those
docs via Search + Chat, and exposes the same flow as an MCP tool (ask_glean).
Requirements
- Python 3.10+
- A Glean instance
- An Indexing API token
- A Client API token with Search and Chat scopes
Setup
- Clone and enter the repo:
git clone <your-repo-url>
cd glean-chatbot
- Install dependencies:
pip install -r requirements.txt
- Create a
.envfrom the example and fill in your values:
# macOS / Linux
cp .env.example .env
# Windows (PowerShell)
copy .env.example .env
| Variable | Required | Purpose |
|---|---|---|
GLEAN_INSTANCE |
yes | Instance name (https://<instance>-be.glean.com) |
GLEAN_INDEXING_TOKEN |
yes | Indexing API token |
GLEAN_CLIENT_TOKEN |
yes | Client API token (Search + Chat) |
GLEAN_ACT_AS |
yes* | User email for X-Glean-ActAs (*needed with a global client token) |
GLEAN_DATASOURCE |
no | Datasource name (default interviewds) |
GLEAN_DATASOURCE_DISPLAY |
no | Display name in the Glean UI |
GLEAN_URL_REGEX |
no | Regex every doc viewURL must match |
.env is auto-loaded by config.py (via python-dotenv). You do not need to source it.
Run
Index documents
python scripts/index_documents.py
# optional: wait until Search can find them
python scripts/index_documents.py --verify
Ask from the 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 3
MCP (Cursor)
Project config lives at .cursor/mcp.json (absolute path to src/mcp_server.py + env vars).
Restart Cursor / reload MCP after editing it. The tool is ask_glean.
Smoke-test the server alone:
python src/mcp_server.py
Tests
python tests/test_pipeline.py
No network; mocks Search/Chat.
How it works
scripts/index_documents.py pushes data/documents.json through the Indexing API.
At query time, src/pipeline.py calls Search, then (only if there are hits) Chat with
those hits as closed-book context, and returns an answer plus sources. CLI and MCP
both call that same pipeline. Results are scoped to our own documents; if Search
returns nothing, we suggest close document titles instead of inventing an answer.
Notes / limitations
- Shared sandbox ignores
datasourcesFilter; we filter client-side on the document id prefix (CUSTOM_<DATASOURCE>_Contract_). - Indexing is asynchronous — docs may take a few minutes to become searchable.
- Demo docs use
allowAnonymousAccess: true. Do not ship that in production. - Doc
viewURLs must matchGLEAN_URL_REGEXor indexing will reject them.
See DESIGN_NOTE.md for API tradeoffs and production notes.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.