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.
Clone the repository and install dependencies:
# Clone repository
git clone https://github.com/techkwon/mcp-gemini.git
cd mcp-gemini
# Install dependencies
npm install
Configure your Google API key in the config.ts file:
export default {
googleApiKey: "your_api_key_here",
// Other settings...
};
Build and start the server:
# Build TypeScript
npm run build
# Start server with PM2
npm start
# Run in development mode
npm run dev
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
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"
]
}
}
Server won't start:
# Check PM2 logs
npm run logs
# Check PM2 process status
npm run status
API key errors:
Memory usage issues:
If port 8000 is already in use:
# Terminate existing Node.js processes
pkill -f "node"
Claude desktop app configuration files are located at:
{
"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}"
}
}
}
]
}
]
}
@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
All API responses follow this format:
{
"jsonrpc": "2.0",
"id": "request_id",
"result": {
"content": "Response content"
}
}
Errors are returned in this format:
{
"jsonrpc": "2.0",
"id": "request_id",
"error": {
"code": error_code,
"message": "Error message",
"data": {
"details": "Detailed error information"
}
}
}
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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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