Get the FREE Ultimate OpenClaw Setup Guide →

mcp-gemini

This project provides a dedicated MCP (Model Context Protocol) server that wraps the @google/genai SDK. It exposes Google's Gemini model capabilities as standard MCP tools, allowing other LLMs (like Cline) or MCP-compatible systems to leverage Gemini's features as a backend workhorse.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio bsmi021-mcp-gemini-server node dist/server.js \
  --env CONNECTION_TOKEN="generated_connection_token_for_secure_client_server_communication" \
  --env GOOGLE_AI_STUDIO_API_KEY="your Google AI Studio API key"

How to use

The MCP Gemini Server wraps Google's Gemini model capabilities via the @google/genai SDK and exposes them as MCP tools. It focuses on URL-based multimedia analysis for images and YouTube videos, while providing standard generation and function-calling tools to integrate Gemini into larger MCP workflows. Once running, clients can connect to this server as an MCP backend and call a suite of Gemini-backed tools such as gemini_generateContent, gemini_generateContentStream, gemini_generateImage, and gemini_url_analysis, as well as manage context through caching and stateful chat features. The server also supports external MCP client interactions, enabling you to connect to other MCP servers and invoke their tools from Gemini.

To use the tools, ensure you’ve built the project (npm run build) and started the server (node dist/server.js). After connecting with the appropriate token, you can issue standard MCP tool calls to generate content, analyze web content from URLs, fetch image/video analyses, and perform URL-context aware prompts. Note that file uploads are not supported; provide publicly accessible URLs for image and video analysis, and use text prompts to guide Gemini’s responses. You can also leverage function calling to request execution of client-defined functions or to pass results back into the MCP flow.

How to install

Prerequisites

  • Node.js v18 or later
  • Git (optional, for cloning the repository)
  • npm (comes with Node.js)

Installation steps

  1. Clone or download the mcp-gemini-server project and navigate to its directory:

    git clone https://github.com/bsmi021/mcp-gemini-server.git cd mcp-gemini-server

  2. Install dependencies:

    npm install

  3. Build the TypeScript sources to JavaScript:

    npm run build

    This outputs the server entry at dist/server.js. You can start the server with node dist/server.js (see next step).

  4. Run the server:

    node dist/server.js

  5. Generate a secure connection token to configure both server and client (recommended method):

    node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

  6. Set up environment variables (example):

    export GOOGLE_AI_STUDIO_API_KEY=your_api_key_here export CONNECTION_TOKEN=generated_connection_token_here

  7. (Optional) If you want to run via a process manager or container, adapt the command to your environment (see mcp_config for usage details).

Additional notes

Environment variables and configuration:

  • GOOGLE_AI_STUDIO_API_KEY is required for Gemini URL contextual processing and caching features that rely on Google AI Studio.
  • CONNECTION_TOKEN is a shared secret used by MCP clients to authenticate with the server; keep it secure and rotate periodically.
  • The server focuses on URL-based multimedia analysis; direct local file uploads are not supported.
  • Supported Gemini models include gemini-1.5-pro-latest, gemini-1.5-flash, and gemini-2.5-pro. Image generation uses Gemini 2.0 Flash Experimental or Imagen 3.1 depending on the model and capabilities.
  • If you need to integrate with other MCP servers, you can use mcpConnectToServer, mcpListServerTools, mcpCallServerTool, and mcpDisconnectFromServer to chain analyses across backends.
  • When deploying, ensure the dist/server.js path remains accessible and that your runtime environment has network access to fetch public URLs for analysis.

Related MCP Servers

Sponsor this space

Reach thousands of developers