glean-mcp


Nameglean-mcp JSON
Version 3.3.0 PyPI version JSON
download
home_pageNone
SummaryPython client + MCP server adapter for Glean (search, chat, read documents). Provides a reusable HTTP client plus simple sync helper functions.
upload_time2025-08-16 05:20:59
maintainerNone
docs_urlNone
authorAlan Shum
requires_python>=3.9
licenseNone
keywords glean mcp model-context-protocol search
VCS
bugtrack_url
requirements mcp httpx pydantic python-dotenv uvloop
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/alankyshum/glean-mcp-server/releases) · [Cookie Guide](docs/COOKIES.md) · [Token Auth Guide](docs/TOKEN_BASED_AUTH.md)

## Install
```bash
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.

```bash
# 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):
```bash
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:
```python
from glean_mcp import GleanClient

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

Token-based:
```python
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):
```python
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](docs/COOKIES.md)

### 🔑 Token (recommended)
- 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](docs/TOKEN_BASED_AUTH.md)

### 🤖 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:
- `GLEAN_BASE_URL` (e.g. https://your-company-be.glean.com) or `GLEAN_INSTANCE`
- One of: `GLEAN_API_TOKEN` (preferred) or `GLEAN_COOKIES`

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
```bash
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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "glean-mcp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "glean, mcp, model-context-protocol, search",
    "author": "Alan Shum",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/17/0c/4f8af0d65e05b73acd21f036d8096af8125da9ad0119e0be773dea526368/glean_mcp-3.3.0.tar.gz",
    "platform": null,
    "description": "# Glean MCP Server & Python Package\n\nSimple, focused implementation providing:\n\n- Cookie-based client (`glean_mcp.cookie_client.GleanClient`) \u2014 uses browser session cookies\n- Token-based client (`glean_mcp.token_client.TokenBasedGleanClient`) \u2014 uses API tokens for server-to-server auth\n- MCP server (`python -m glean_mcp.server`) \u2014 auto-detects authentication method; ready for Docker\n\nLinks: [Releases](https://github.com/alankyshum/glean-mcp-server/releases) \u00b7 [Cookie Guide](docs/COOKIES.md) \u00b7 [Token Auth Guide](docs/TOKEN_BASED_AUTH.md)\n\n## Install\n```bash\npip install -U glean-mcp\n```\n\n## Package Layout\n```\nsrc/\n\u2514\u2500\u2500 glean_mcp/\n    \u251c\u2500\u2500 cookie_client.py      # Cookie-based authentication client\n    \u251c\u2500\u2500 token_client.py       # Token-based authentication client\n    \u251c\u2500\u2500 server.py             # MCP server with auto-detection\n    \u2514\u2500\u2500 glean_filter.py       # Response filtering utilities\n```\n\n## Quick Start\n\n### MCP Server (local or Docker)\nThe MCP server automatically detects your authentication method.\n\n```bash\n# Choose ONE (token preferred)\nexport GLEAN_API_TOKEN=\"your-api-token\"   # preferred\n# OR\nexport GLEAN_COOKIES=\"your-browser-cookies\"\n\n# Set your Glean instance\nexport GLEAN_BASE_URL=\"https://your-company-be.glean.com\"  # or set GLEAN_INSTANCE=your-company\n\n# Run the MCP server locally\npython -m glean_mcp.server\n```\n\nDocker (example):\n```bash\ndocker run --pull always --rm \\\n  -e GLEAN_API_TOKEN=\"$GLEAN_API_TOKEN\" \\\n  -e GLEAN_BASE_URL=\"$GLEAN_BASE_URL\" \\\n  ghcr.io/alankyshum/glean-mcp-server:latest\n```\nUpgrade: use `--pull always` (Docker) or `pip install -U glean-mcp` (pip).\n\n### Library Usage (async)\n\nCookie-based:\n```python\nfrom glean_mcp import GleanClient\n\nclient = GleanClient(base_url, cookies)\nresults = await client.search(\"onboarding docs\")\nawait client.close()\n```\n\nToken-based:\n```python\nfrom glean_mcp import TokenBasedGleanClient\n\nclient = TokenBasedGleanClient(base_url, api_token)\nresults = await client.search(\"onboarding docs\")\nawait client.close()\n```\n\nAuto-detection (same logic as server):\n```python\nfrom glean_mcp import create_glean_client\n\nclient = create_glean_client()  # Uses env vars; prefers token\nresults = await client.search(\"onboarding docs\")\nawait client.close()\n```\n\n## Authentication\n\nTwo supported methods:\n\n### \ud83c\udf6a Cookies (original)\n- Use browser cookies from your Glean session\n- Requires `GLEAN_COOKIES`\n- Uses `/api/v1/` endpoints\n- See [Cookie Guide](docs/COOKIES.md)\n\n### \ud83d\udd11 Token (recommended)\n- Use Glean API tokens for server-to-server authentication\n- Requires `GLEAN_API_TOKEN`\n- Uses `/rest/api/v1/` endpoints\n- More secure for automated/production environments\n- See [Token Auth Guide](docs/TOKEN_BASED_AUTH.md)\n\n### \ud83e\udd16 Auto-detection rules\n1) If `GLEAN_API_TOKEN` is set \u2192 token-based auth\n2) Else if `GLEAN_COOKIES` is set \u2192 cookie-based auth\n3) If both are set \u2192 token preferred\n4) If neither is set \u2192 error with guidance\n\n## Environment Variables\n\nRequired for server/library:\n- `GLEAN_BASE_URL` (e.g. https://your-company-be.glean.com) or `GLEAN_INSTANCE`\n- One of: `GLEAN_API_TOKEN` (preferred) or `GLEAN_COOKIES`\n\nOptional (server behavior):\n- `GLEAN_DEFAULT_PAGE_SIZE` (default: 14)\n- `GLEAN_DEFAULT_SNIPPET_SIZE` (default: 215)\n- `GLEAN_TOOL_DESCRIPTION` (tool description text)\n- `GLEAN_AUTO_OPEN_BROWSER` (default: true)\n\n## Development\n```bash\ngit clone https://github.com/alankyshum/glean-mcp-server.git\ncd glean-mcp-server\npython -m venv .venv && source .venv/bin/activate\npip install -e '.[dev]'\npytest -q\n```\n\n## Versioning & Publishing\n- Semantic versioning; breaking changes bump MAJOR\n- Tag `vX.Y.Z` after updating version strings; CI publishes to PyPI/GHCR if versions match\n\n## License\nMIT\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client + MCP server adapter for Glean (search, chat, read documents). Provides a reusable HTTP client plus simple sync helper functions.",
    "version": "3.3.0",
    "project_urls": {
        "Changelog": "https://github.com/alankyshum/glean-mcp-server/releases",
        "Documentation": "https://github.com/alankyshum/glean-mcp-server#readme",
        "Homepage": "https://github.com/alankyshum/glean-mcp-server",
        "Issues": "https://github.com/alankyshum/glean-mcp-server/issues",
        "Repository": "https://github.com/alankyshum/glean-mcp-server"
    },
    "split_keywords": [
        "glean",
        " mcp",
        " model-context-protocol",
        " search"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3dcefd5a12e13779115487c109b0d3e082ff9587f7d777509a92952bda32d60b",
                "md5": "82cae543219627ccfd11bd59b3347d33",
                "sha256": "710ca24a9bd6ce0a5072e7c0bac611bcdd157741505371dfee47722544422c46"
            },
            "downloads": -1,
            "filename": "glean_mcp-3.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82cae543219627ccfd11bd59b3347d33",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 24232,
            "upload_time": "2025-08-16T05:20:58",
            "upload_time_iso_8601": "2025-08-16T05:20:58.369862Z",
            "url": "https://files.pythonhosted.org/packages/3d/ce/fd5a12e13779115487c109b0d3e082ff9587f7d777509a92952bda32d60b/glean_mcp-3.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "170c4f8af0d65e05b73acd21f036d8096af8125da9ad0119e0be773dea526368",
                "md5": "6690d26f0c86b47b77576a79db2272fe",
                "sha256": "028808045fabb999b62ec04f88ba1ebf1ca0984bc7be62c41d8a61942a214038"
            },
            "downloads": -1,
            "filename": "glean_mcp-3.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6690d26f0c86b47b77576a79db2272fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 23712,
            "upload_time": "2025-08-16T05:20:59",
            "upload_time_iso_8601": "2025-08-16T05:20:59.471342Z",
            "url": "https://files.pythonhosted.org/packages/17/0c/4f8af0d65e05b73acd21f036d8096af8125da9ad0119e0be773dea526368/glean_mcp-3.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-16 05:20:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alankyshum",
    "github_project": "glean-mcp-server",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "mcp",
            "specs": [
                [
                    ">=",
                    "0.9.0"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    ">=",
                    "0.25.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "uvloop",
            "specs": [
                [
                    ">=",
                    "0.19.0"
                ]
            ]
        }
    ],
    "lcname": "glean-mcp"
}
        
Elapsed time: 1.20023s