{
  "schema_version": 2,
  "id": "develop/ai/context-engine/context-gateway",
  "title": "Redis Context Gateway",
  "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/",
  "summary": "Connect agents to MCP servers and tools over Redis data through one endpoint.",
  "aliases": [
    "/develop/ai/context-engine/context-retriever/",
    "/develop/ai/context-engine/context-retriever/interactive-demo/"
  ],
  "tags": [
    "docs",
    "develop",
    "ai"
  ],
  "last_updated": "2026-11-03T15:26:57-08:00",
  "children": [
    {
      "id": "develop/ai/context-engine/context-gateway/concepts",
      "summary": "Understand Gateways, Upstreams, credentials, tool exposure modes, the cache, compression, and agent access.",
      "title": "Redis Context Gateway concepts",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/concepts/"
    },
    {
      "id": "develop/ai/context-engine/context-gateway/quickstart",
      "summary": "Discover and call Context Gateway tools with Python, TypeScript, or the Iris CLI in search or full mode.",
      "title": "Redis Context Gateway quickstart",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/quickstart/"
    },
    {
      "id": "develop/ai/context-engine/context-gateway/manage-gateways",
      "summary": "Create and change Gateways, register MCP servers with their credentials, set tool policies, and remove Upstreams.",
      "title": "Manage Gateways and Upstreams",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/manage-gateways/"
    },
    {
      "id": "develop/ai/context-engine/context-gateway/manage-context-surfaces",
      "summary": "Create a Context Surface to expose Redis records as read-only tools, then update its data model, refresh its tools, or delete it.",
      "title": "Manage Context Surfaces",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/manage-context-surfaces/"
    },
    {
      "id": "develop/ai/context-engine/context-gateway/mcp",
      "summary": "Connect a Streamable HTTP MCP client to a Gateway with an agent key or your identity provider, use full or search mode, and read handles.",
      "title": "Connect with MCP",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/mcp/"
    },
    {
      "id": "develop/ai/context-engine/context-gateway/agent-integration",
      "summary": "Connect OpenAI Agents SDK, LangChain, or Google ADK to Gateway tools over MCP and check the agent's use of stored results.",
      "title": "Integrate with an agent",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/agent-integration/"
    },
    {
      "id": "develop/ai/context-engine/context-gateway/api-reference",
      "summary": "Reference for the Redis Context Gateway MCP endpoint, its tools and arguments, its metadata keys, and its errors.",
      "title": "MCP API Reference",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/api-reference/"
    },
    {
      "id": "develop/ai/context-engine/context-gateway/limits",
      "summary": "Find tool and result limits, tool call failure reasons, Control Plane error types, conflicts, and retry guidance.",
      "title": "Limits and errors",
      "url": "https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/limits/"
    }
  ],
  "page_type": "content",
  "content_hash": "3bb572d37ae978d810976178be3d8be01cfdce58593dfcb7b2e14ccae8e29647",
  "sections": [
    {
      "id": "what-is-context-gateway",
      "title": "What is Context Gateway?",
      "role": "overview",
      "text": "Redis Context Gateway is a Model Context Protocol (MCP) gateway for AI agents that:\n\n- **Connects MCP servers:** Register third-party and in-house MCP servers that support Streamable HTTP as Upstreams.\n- **Provides one endpoint per Gateway:** Connect your agent to a Gateway to access tools from multiple sources.\n- **Manages Upstream credentials:** Configure credentials on the Gateway so your agent does not need credentials for each connected MCP server.\n- **Makes Redis data available as tools:** A Context Surface generates tools from a data model describing records in Redis.\n- **Scales to large tool sets:** In search mode, the agent searches for tools instead of loading every definition.\n- **Handles large and repeated results:** An optional cache serves repeated calls, and compression keeps large results out of the agent's context.\n\n<div class=\"grid grid-cols-1 md:grid-cols-4 gap-6 my-8\">\n  \n  \n  \n  \n</div>"
    },
    {
      "id": "why-use-context-gateway",
      "title": "Why use Context Gateway?",
      "role": "content",
      "text": "<div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 my-6\">\n  <div class=\"p-5 border border-redis-pen-300 rounded-lg\">\n    <h3 class=\"text-redis-ink-900 font-semibold mb-3\">For AI applications</h3>\n    <ul class=\"space-y-1 text-redis-pen-600\">\n      <li>Access tools from multiple sources through one MCP connection</li>\n      <li>Tool definitions that fit the context window, through search mode</li>\n      <li>Large results read in pages instead of filling the context</li>\n      <li>Sign-in with your identity provider for MCP clients that support it</li>\n    </ul>\n  </div>\n  <div class=\"p-5 border border-redis-pen-300 rounded-lg\">\n    <h3 class=\"text-redis-ink-900 font-semibold mb-3\">For platform teams</h3>\n    <ul class=\"space-y-1 text-redis-pen-600\">\n      <li>Upstream credentials stored once, in Vault, AWS Secrets Manager, or encrypted Redis</li>\n      <li>Per-Gateway access through Identity Service agent keys</li>\n      <li>Python package, <code>iris</code> command-line interface (CLI), and REST API for administration</li>\n      <li>Managed deployment on Redis Cloud or self-managed deployment on Kubernetes</li>\n    </ul>\n  </div>\n</div>"
    },
    {
      "id": "concepts",
      "title": "Concepts",
      "role": "content",
      "text": "A **Gateway** is one MCP endpoint for an agent. Each **Upstream** behind it is an MCP server or a **Context Surface**, which generates tools from a data model of records in Redis. In full mode the agent lists every tool; in search mode it searches for the tools it needs. See [Context Gateway concepts](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/concepts) for tool policies, caching, and compression."
    },
    {
      "id": "quick-example",
      "title": "Quick example",
      "role": "content",
      "text": "1. Set up a Gateway:\n    - **Redis Cloud:** [Create a Context Gateway](https://redis.io/docs/latest/operate/iris/context-gateway/create-gateway).\n    - **Self-managed:** Follow the [deployment guide](https://redis.io/docs/latest/operate/iris/context-gateway/self-managed), then [create a Gateway and an agent key](https://redis.io/docs/latest/operate/iris/context-gateway/self-managed/api-examples). A license key is required for self-managed deployment. [Contact Redis](https://redis.io/contact/) to request access.\n1. Install the Redis Iris Python package, which includes the `iris` CLI:\n\n    [code example]\n\n1. With `IRIS_CONTEXT_GATEWAY_URL` and `IRIS_CONTEXT_GATEWAY_API_KEY` in your environment, find a tool and call it:\n\n    [code example]\n\n    From the CLI, `iris --json context-gateway tools list` lists the same tools.\n\nUse the tool names and input schemas returned by discovery. The [redis-iris package](https://pypi.org/project/redis-iris/) covers MCP calls and Gateway administration in Python and the CLI. For JavaScript and TypeScript, install the [@redis-iris/context-gateway SDK](https://www.npmjs.com/package/@redis-iris/context-gateway); see the [client guide](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/mcp#choose-a-client) to choose a client. The [quickstart](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/quickstart) shows calls in full and search mode."
    },
    {
      "id": "manage-gateways-and-upstreams",
      "title": "Manage Gateways and Upstreams",
      "role": "content",
      "text": "- [Manage Gateways and Upstreams](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/manage-gateways): create Gateways, register MCP servers, store their credentials, and set tool policies.\n- [Manage Context Surfaces](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/manage-context-surfaces): generate tools for querying records in Redis."
    },
    {
      "id": "serve-tools-at-runtime",
      "title": "Serve tools at runtime",
      "role": "content",
      "text": "- [Connect with MCP](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/mcp) from any Streamable HTTP client.\n- [Integrate with an agent](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/agent-integration) using OpenAI Agents SDK or LangGraph.\n\nUse the [MCP API Reference](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/api-reference) for MCP tools and metadata, and [limits and errors](https://redis.io/docs/latest/develop/ai/context-engine/context-gateway/limits) for constraints and recovery guidance."
    }
  ],
  "examples": [
    {
      "id": "quick-example-ex0",
      "language": "bash",
      "code": "pip install 'redis-iris>=1.0.0'",
      "section_id": "quick-example"
    },
    {
      "id": "quick-example-ex1",
      "language": "python",
      "code": "from redis_iris import ContextGateway\n\n    gateway = ContextGateway.from_env()\n\n    for tool in gateway.search(\"filter providers by specialty\"):\n        print(tool.name, tool.description)\n\n    result = gateway.call(\"<tool-name>\", {\"<argument>\": \"<value>\"})",
      "section_id": "quick-example"
    }
  ]
}
