Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

redis-context-gateway

Python SDK for Redis Context Gateway. The REST client is generated by Speakeasy from the Gateway control-plane API, the same way as the other Iris SDKs. A small helper connects agents to a Gateway's MCP endpoint with the official mcp library.

Unpublished first increment, generated from redislabsdev/iris@7b8fb322e. Python 3.10 or later.

Control plane

from redis_context_gateway import ContextGatewayClient

with ContextGatewayClient(server_url=control_plane_url, admin_token=admin_token) as client:
    gateway = client.gateways.create(display_name="Docs", tool_exposure_mode="search")
    upstream = client.upstreams.create(
        gateway_id=gateway.id,
        display_name="Docs MCP",
        namespace="docs",
        connection={"endpoint": upstream_mcp_url},
        authentication={"methods": [{"bearer": {"value": upstream_token}}]},
    )

Every product call sends the admin token. The health probes (client.health.live(), client.health.ready()) send no credential. Async variants end in _async. See USAGE.md and docs/ for every operation and model.

Agents (MCP)

from redis_context_gateway.mcp import connect

async with connect(gateway.mcp_endpoint, agent_key) as session:
    found = await session.call_tool("search_tools", {"query": "find an issue"})
    result = await session.call_tool(
        "run_tool", {"tool": {"upstreamId": upstream.id, "originalName": "get_issue"}, "toolArgs": {"id": 42}}
    )

connect returns an initialized official mcp.ClientSession, so Lens instrumentation applies as is. The agent key is an Identity Service key with a context-retriever / cr-gateway / use grant for the Gateway. Search tools, run_tool and the result handle tools are ordinary tool calls. A tool failure comes back as a result with isError: true, not an exception.

MCP reads default to a 300-second inactivity timeout, with 30-second connect, write and connection-pool budgets. Pass timeout=10 to use ten seconds for every HTTP timeout, or timeout=httpx.Timeout(30, read=600) for a separate read budget. These are HTTP inactivity limits, not a total tool-call deadline. REST timeout defaults are unchanged.

Safety

  • Neither client follows redirects, so the admin token and agent keys stay on the Gateway.
  • Plain HTTP is refused unless the host is loopback (localhost, 127.0.0.0/8 or ::1).
  • Each request must match its own operation's method, path and query names, so an ID like ../../v1/gateways fails before anything is sent. A custom HTTP client that can't turn redirects off is refused with a TypeError.
  • The SDK never reads credentials from environment variables. Pass them in explicitly. The redis-iris CLI and goal objects own IRIS_CONTEXT_GATEWAY_* settings and the [context_gateway] config table.
  • Upstream secrets are write-only: no response model carries them.
  • Generated payload debugging is disabled, even when debug_logger is supplied, because it would log request secrets. Application logging and custom HTTP transports are outside this guarantee. Do not log whole generated exceptions: validation diagnostics can retain supplied credentials, and response errors retain server-provided bodies.
  • No call is retried automatically.

Development

uv venv && uv pip install -e . pytest pytest-asyncio ruff
# Python 3.11+: install the local Lens package for its integration test.
uv pip install ../lens-python-sdk
.venv/bin/python -m pytest tests

Hand-written files are src/redis_context_gateway/_hooks/registration.py, src/redis_context_gateway/mcp.py, tests/ and this README, protected by .genignore. Everything else is regenerated by node scripts/generate-context-gateway.mjs from the repository root.

Metadata

Release files for redis-context-gateway 0.1.0a1

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

Source distribution (sdist)

Source distribution for redis-context-gateway 0.1.0a1
File Size Uploaded
redis_context_gateway-0.1.0a1.tar.gz 58.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for redis-context-gateway 0.1.0a1
File Interpreter ABI Platform
redis_context_gateway-0.1.0a1-py3-none-any.whl Python 3 none any Details

Total release size: 183.7 kB

Release files / redis_context_gateway-0.1.0a1.tar.gz

Download URL redis_context_gateway-0.1.0a1.tar.gz
Size 58.1 kB
Tags Source
SHA-256 checksum
How to use checksums
11640de793a84fe326fc0f5117dfde38ea566fffcd94c955e7b8b10cde5cc125
BLAKE2b-256 checksum
How to use checksums
1a6f9f7af7ef79e7515df0265f9bbf6a7e5314e9132762368dd5021bb969f547
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.23

Release files / redis_context_gateway-0.1.0a1-py3-none-any.whl

Download URL redis_context_gateway-0.1.0a1-py3-none-any.whl
Size 125.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7e4c91ac6dd0bb4dd34b9156502ccb24085744d8768bda4d9bb0b8d8e2d5a30
BLAKE2b-256 checksum
How to use checksums
4801b46f915d1c524540205b360584aa94aecaba32dda7b036db17a16b1c6fb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.23

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

2 release files

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