Gemini Streamable HTTP MCP

Gemini Streamable HTTP MCP

A Docker-based deployment that wraps the Gemini MCP server with supergateway to expose its tool capabilities over Streamable HTTP. It enables users to perform image-editing workflows and interact with the Google Gemini API using a standardized web-accessible endpoint.

Category
访问服务器

README

gemini-3-pro-mcp-streamable-http-mcp

A Docker-based deployment that wraps the RLabs-Inc/gemini-mcp stdio MCP server with supergateway to expose it over Streamable HTTP. Includes a Python test suite that validates the full image-edit workflow end-to-end.

Architecture

Client (MCP SDK)
    │
    │  Streamable HTTP  (POST/GET http://host:8000/mcp)
    ▼
┌────────────────────────────────────────────┐
│  Docker Container                          │
│                                            │
│  supergateway                              │
│    --stdio "gemini-mcp"                    │
│    --outputTransport streamableHttp        │
│    --port 8000                             │
│         │                                  │
│         │ stdio (stdin/stdout)             │
│         ▼                                  │
│  @rlabs-inc/gemini-mcp                     │
│    (talks to Google Gemini API)            │
└────────────────────────────────────────────┘

supergateway spawns gemini-mcp as a child process, speaks MCP over stdio with it, and re-exposes every tool over a single Streamable HTTP endpoint at /mcp.

Prerequisites

Quick Start

Build the image

docker build -t gemini-mcp .

Run the container

docker run -e GEMINI_API_KEY=your_key_here -p 8000:8000 gemini-mcp

The MCP server is now available at http://localhost:8000/mcp.

Connect from any MCP client

Any client that supports Streamable HTTP transport can connect. For example, with the MCP Python SDK:

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async with streamablehttp_client("http://localhost:8000/mcp") as (read, write, _):
    async with ClientSession(read, write) as session:
        await session.initialize()
        tools = await session.list_tools()
        print([t.name for t in tools.tools])

File Reference

File Purpose
Dockerfile Builds the container image: installs supergateway and @rlabs-inc/gemini-mcp globally on node:22-slim, then runs supergateway on port 8000 with Streamable HTTP output.
test_gemini_mcp.py Pytest test suite that builds the image, starts a container, connects via the MCP Python SDK, and exercises the image-edit workflow.
requirements.txt Python dependencies for the test suite.

Dockerfile

FROM node:22-slim
RUN npm install -g supergateway @rlabs-inc/gemini-mcp
ENV GEMINI_API_KEY=""
EXPOSE 8000
CMD ["supergateway", "--stdio", "gemini-mcp", \
     "--outputTransport", "streamableHttp", "--port", "8000"]
Layer What it does
node:22-slim Minimal Node.js 22 runtime.
npm install -g Pre-installs both packages so startup is fast (no npx download on every boot).
ENV GEMINI_API_KEY Declares the variable; the actual key is injected at docker run time via -e.
EXPOSE 8000 Documents the listening port.
CMD Launches supergateway, which spawns gemini-mcp over stdio and bridges it to Streamable HTTP on port 8000.

Test Suite

Dependencies

Install with:

pip install -r requirements.txt
Package Role
mcp Official MCP Python SDK -- provides ClientSession and the Streamable HTTP transport client.
pytest Test runner.
pytest-asyncio Enables async def test functions.
Pillow Image validation (format detection, integrity check via verify()).
docker Python Docker SDK -- builds images, manages container lifecycle.

Running the tests

GEMINI_API_KEY=your_key pytest test_gemini_mcp.py -v

The test suite is fully self-contained: it builds the Docker image, starts the container, runs the tests, and tears the container down afterward.

Fixtures

Fixture Scope Description
gemini_api_key session Reads GEMINI_API_KEY from the environment. Skips all tests if unset.
docker_client session Creates a Docker SDK client from the local Docker daemon.
gemini_container session Builds the image, removes stale containers, starts a fresh container on port 18000, polls until the TCP port is accepting connections, yields the container, and force-removes it on teardown.

Tests

test_list_tools

Connects to the MCP server and verifies that the expected image-edit tools are exposed:

  • gemini-start-image-edit
  • gemini-continue-image-edit
  • gemini-end-image-edit

test_image_edit_workflow

End-to-end image editing round-trip:

  1. Start session -- calls gemini-start-image-edit with a prompt ("a simple red circle on a white background"), asserts an ImageContent and TextContent block are returned, extracts the session ID.
  2. Apply edit -- calls gemini-continue-image-edit with the session ID and an edit instruction ("change the red circle to a blue star"), asserts a new image is returned.
  3. Download -- base64-decodes the image data and writes it to a temp file.
  4. Validate -- opens the bytes with Pillow, calls verify() to check integrity, asserts width/height > 0 and format is PNG/JPEG/WEBP/GIF. Also validates the file written to disk.
  5. Close session -- calls gemini-end-image-edit to clean up the server-side session.

Configuration constants

Constant Default Purpose
IMAGE_NAME gemini-mcp-test Docker image tag used during the test run.
CONTAINER_NAME gemini-mcp-test-container Container name (allows cleanup of stale runs).
HOST_PORT 18000 Host port mapped to container port 8000.
MCP_URL http://localhost:18000/mcp Full MCP endpoint URL.
STARTUP_TIMEOUT 120 Max seconds to wait for the container to accept TCP connections.
MCP_CALL_TIMEOUT 180 Read timeout (seconds) for individual MCP tool calls to the Gemini API.

Environment Variables

Variable Required Description
GEMINI_API_KEY Yes Google Gemini API key. Passed to the container at runtime.

The @rlabs-inc/gemini-mcp package also supports optional variables (GEMINI_OUTPUT_DIR, GEMINI_TOOL_PRESET, GEMINI_PRO_MODEL, etc.) which can be passed through with additional -e flags on docker run.

License

See upstream projects for license terms:

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选