Skip to main content

Glean MCP Server & Python Package

Simple, focused implementation providing:

  • Cookie-based client (glean_mcp.cookie_client.GleanClient) — uses browser session cookies
  • Token-based client (glean_mcp.token_client.TokenBasedGleanClient) — uses API tokens for server-to-server auth
  • MCP server (python -m glean_mcp.server) — auto-detects authentication method; ready for Docker

Links: Releases · Cookie Guide · Token Auth Guide

Install

pip install -U glean-mcp

Package Layout

src/
└── glean_mcp/
    ├── cookie_client.py      # Cookie-based authentication client
    ├── token_client.py       # Token-based authentication client
    ├── server.py             # MCP server with auto-detection
    └── glean_filter.py       # Response filtering utilities

Quick Start

MCP Server (local or Docker)

The MCP server automatically detects your authentication method.

# Choose ONE (token preferred)
export GLEAN_API_TOKEN="your-api-token"   # preferred
# OR
export GLEAN_COOKIES="your-browser-cookies"

# Set your Glean instance
export GLEAN_BASE_URL="https://your-company-be.glean.com"  # or set GLEAN_INSTANCE=your-company

# Run the MCP server locally
python -m glean_mcp.server

Docker (example):

docker run --pull always --rm \
  -e GLEAN_API_TOKEN="$GLEAN_API_TOKEN" \
  -e GLEAN_BASE_URL="$GLEAN_BASE_URL" \
  ghcr.io/alankyshum/glean-mcp-server:latest

Upgrade: use --pull always (Docker) or pip install -U glean-mcp (pip).

Library Usage (async)

Cookie-based:

from glean_mcp import GleanClient

client = GleanClient(base_url, cookies)
results = await client.search("onboarding docs")
await client.close()

Token-based:

from glean_mcp import TokenBasedGleanClient

client = TokenBasedGleanClient(base_url, api_token)
results = await client.search("onboarding docs")
await client.close()

Auto-detection (same logic as server):

from glean_mcp import create_glean_client

client = create_glean_client()  # Uses env vars; prefers token
results = await client.search("onboarding docs")
await client.close()

Authentication

Two supported methods:

🍪 Cookies (original)

  • Use browser cookies from your Glean session
  • Requires GLEAN_COOKIES
  • Uses /api/v1/ endpoints
  • See Cookie Guide
  • Use Glean API tokens for server-to-server authentication
  • Requires GLEAN_API_TOKEN
  • Uses /rest/api/v1/ endpoints
  • More secure for automated/production environments
  • See Token Auth Guide

🤖 Auto-detection rules

  1. If GLEAN_API_TOKEN is set → token-based auth
  2. Else if GLEAN_COOKIES is set → cookie-based auth
  3. If both are set → token preferred
  4. If neither is set → error with guidance

Environment Variables

Required for server/library:

Optional (server behavior):

  • GLEAN_DEFAULT_PAGE_SIZE (default: 14)
  • GLEAN_DEFAULT_SNIPPET_SIZE (default: 215)
  • GLEAN_TOOL_DESCRIPTION (tool description text)
  • GLEAN_AUTO_OPEN_BROWSER (default: true)

Development

git clone https://github.com/alankyshum/glean-mcp-server.git
cd glean-mcp-server
python -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
pytest -q

Versioning & Publishing

  • Semantic versioning; breaking changes bump MAJOR
  • Tag vX.Y.Z after updating version strings; CI publishes to PyPI/GHCR if versions match

License

MIT

Metadata

Release files for glean-mcp 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glean-mcp 3.3.0
File Size Uploaded Provenance
glean_mcp-3.3.0.tar.gz 23.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for glean-mcp 3.3.0
File Interpreter ABI Platform
glean_mcp-3.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.9 kB

Release files / glean_mcp-3.3.0.tar.gz

Download URL glean_mcp-3.3.0.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
028808045fabb999b62ec04f88ba1ebf1ca0984bc7be62c41d8a61942a214038
BLAKE2b-256 checksum
How to use checksums
170c4f8af0d65e05b73acd21f036d8096af8125da9ad0119e0be773dea526368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / glean_mcp-3.3.0-py3-none-any.whl

Download URL glean_mcp-3.3.0-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
710ca24a9bd6ce0a5072e7c0bac611bcdd157741505371dfee47722544422c46
BLAKE2b-256 checksum
How to use checksums
3dcefd5a12e13779115487c109b0d3e082ff9587f7d777509a92952bda32d60b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for glean-mcp 3.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page