Gemini with Web Search MCP server

Integrates Google's Gemini model with real-time web search and YouTube data to enhance AI responses with up-to-date information from the internet.
Back to servers
Setup instructions
Provider
techkwon
Release date
Mar 31, 2025
Language
TypeScript
Stats
4 stars

This MCP Gemini API server provides Google Gemini capabilities for Cursor and Claude applications, including text generation, image analysis, video analysis, and web search functionality using the Gemini 2.0 Flash model.

Requirements

  • Node.js 18.0.0 or higher
  • npm or yarn
  • Google API key (for Gemini API access)

Installation

Clone the repository and install dependencies:

# Clone repository
git clone https://github.com/techkwon/mcp-gemini.git
cd mcp-gemini

# Install dependencies
npm install

Configuration

Configure your Google API key in the config.ts file:

export default {
  googleApiKey: "your_api_key_here",
  // Other settings...
};

Running the Server

Build and start the server:

# Build TypeScript
npm run build

# Start server with PM2
npm start

# Run in development mode
npm run dev

Managing the Server with PM2

The server is automatically managed through PM2:

# Check server status
npm run status

# View server logs
npm run logs

# Stop server
npm run stop

# Restart server
npm run restart

# Configure auto-start on system reboot
pm2 startup
pm2 save

Integration with Cursor/Claude

MCP Configuration

Add the following to your ~/.cursor/mcp.json file:

{
  "github.com/techkwon/mcp-gemini": {
    "command": "npm",
    "args": ["start"],
    "cwd": "<project_path>",
    "env": {
      "NODE_ENV": "production"
    },
    "disabled": false,
    "autoStart": true,
    "autoApprove": [
      "gem-generate",
      "gem-generate-image",
      "gem-analyze-video",
      "gem-search"
    ]
  }
}

API Endpoints

  • /gem-generate: Text generation
  • /gem-generate-image: Image generation/analysis
  • /gem-analyze-video: YouTube video analysis
  • /gem-search: Web search

Troubleshooting

Common Issues

  • Server won't start:

    # Check PM2 logs
    npm run logs
    
    # Check PM2 process status
    npm run status
    
  • API key errors:

    • Verify your API key is correctly set in config.ts
    • Check Gemini API quotas and permissions
  • Memory usage issues:

    • Check memory limit settings in ecosystem.config.js
    • Monitor memory usage with PM2

Port Conflicts

If port 8000 is already in use:

# Terminate existing Node.js processes
pkill -f "node"

Claude Desktop App Integration

Configuration File Location

Claude desktop app configuration files are located at:

  • Windows: %APPDATA%/Claude/config.json
  • macOS: ~/Library/Application Support/Claude/config.json

JSON Configuration Example

{
  "apis": [
    {
      "name": "MCP Gemini",
      "url": "http://localhost:8000",
      "methods": [
        {
          "name": "Text Generation",
          "method": "gem-generate",
          "template": {
            "jsonrpc": "2.0",
            "id": "{uuid}",
            "method": "gem-generate",
            "params": {
              "prompt": "{input}"
            }
          }
        },
        {
          "name": "Image Generation",
          "method": "gem-generate-image",
          "template": {
            "jsonrpc": "2.0",
            "id": "{uuid}",
            "method": "gem-generate-image",
            "params": {
              "prompt": "{input}"
            }
          }
        },
        {
          "name": "Video Analysis",
          "method": "gem-analyze-video",
          "template": {
            "jsonrpc": "2.0",
            "id": "{uuid}",
            "method": "gem-analyze-video",
            "params": {
              "videoUrl": "{input}",
              "query": "Please summarize the main content of this video"
            }
          }
        },
        {
          "name": "Web Search",
          "method": "gem-search",
          "template": {
            "jsonrpc": "2.0",
            "id": "{uuid}",
            "method": "gem-search",
            "params": {
              "query": "{input}"
            }
          }
        }
      ]
    }
  ]
}

Usage Instructions

  • Open the Claude desktop app configuration file
  • Add the JSON configuration above to your existing settings
  • Restart the Claude desktop app
  • Use in chat with the following format:
@MCP Gemini.Text Generation Tell me about traditional Korean food
@MCP Gemini.Image Generation Beautiful landscape of a traditional Korean village
@MCP Gemini.Video Analysis https://youtube.com/watch?v=VIDEO_ID
@MCP Gemini.Web Search Latest AI technology trends

Response Format

All API responses follow this format:

{
  "jsonrpc": "2.0",
  "id": "request_id",
  "result": {
    "content": "Response content"
  }
}

Error Responses

Errors are returned in this format:

{
  "jsonrpc": "2.0",
  "id": "request_id",
  "error": {
    "code": error_code,
    "message": "Error message",
    "data": {
      "details": "Detailed error information"
    }
  }
}

Security Considerations

  • Always manage API keys as environment variables
  • Add appropriate security settings in production environments
  • Be careful not to log sensitive information

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-gemini" '{"command":"npm","args":["start"],"cwd":"${projectPath}","env":{"NODE_ENV":"production"},"disabled":false,"autoStart":true,"autoApprove":["gem-generate","gem-generate-image","gem-analyze-video","gem-search"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp-gemini": {
            "command": "npm",
            "args": [
                "start"
            ],
            "cwd": "${projectPath}",
            "env": {
                "NODE_ENV": "production"
            },
            "disabled": false,
            "autoStart": true,
            "autoApprove": [
                "gem-generate",
                "gem-generate-image",
                "gem-analyze-video",
                "gem-search"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-gemini": {
            "command": "npm",
            "args": [
                "start"
            ],
            "cwd": "${projectPath}",
            "env": {
                "NODE_ENV": "production"
            },
            "disabled": false,
            "autoStart": true,
            "autoApprove": [
                "gem-generate",
                "gem-generate-image",
                "gem-analyze-video",
                "gem-search"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later