I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

MCP Gemini Server
A server implementation of the Model Context Protocol (MCP) to enable AI assistants like Claude to interact with Google's Gemini API.
Project Overview
This project implements a server that follows the Model Context Protocol, allowing AI assistants to communicate with Google's Gemini models. With this MCP server, AI assistants can request text generation, text analysis, and maintain chat conversations through the Gemini API.
Features
- Client-Server Communication: Implements MCP protocol for secure message exchange between client and server.
- Message Processing: Handles and processes client requests, sending appropriate responses.
- Error Handling & Logging: Logs server activities and ensures smooth error recovery.
-
Environment Variables Support: Uses
.env
file for storing sensitive information securely. - API Testing & Debugging: Supports manual and automated testing using Postman and test scripts.
Installation
Prerequisites
- Python 3.7 or higher
- Google AI API key
Setup
- Clone this repository:
git clone https://github.com/yourusername/mcp-gemini-server.git
cd mcp-gemini-server
- Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- Windows:
venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
- Windows:
-
Install dependencies:
pip install -r requirements.txt
- Create a
.env
file in the root directory with your Gemini API key:
GEMINI_API_KEY=your_api_key_here
Usage
- Start the server:
python server.py
-
The server will run on
http://localhost:5000/
by default -
Send MCP requests to the
/mcp
endpoint using POST method
Example Request
import requests
url = 'http://localhost:5000/mcp'
payload = {
'action': 'generate_text',
'parameters': {
'prompt': 'Write a short poem about AI',
'temperature': 0.7
}
}
response = requests.post(url, json=payload)
print(response.json())
API Reference
Endpoints
-
GET /health
: Check if the server is running -
GET /list-models
: List available Gemini models -
POST /mcp
: Main endpoint for MCP requests
MCP Actions
1. generate_text
Generate text content with Gemini.
Parameters:
-
prompt
(required): The text prompt for generation -
temperature
(optional): Controls randomness (0.0 to 1.0) -
max_tokens
(optional): Maximum tokens to generate
Example:
{
"action": "generate_text",
"parameters": {
"prompt": "Write a short story about a robot",
"temperature": 0.8,
"max_tokens": 500
}
}
2. analyze_text
Analyze text content.
Parameters:
-
text
(required): The text to analyze -
analysis_type
(optional): Type of analysis ('sentiment', 'summary', 'keywords', or 'general')
Example:
{
"action": "analyze_text",
"parameters": {
"text": "The weather today is wonderful! I love how the sun is shining.",
"analysis_type": "sentiment"
}
}
3. chat
Have a conversation with Gemini.
Parameters:
-
messages
(required): Array of message objects with 'role' and 'content' -
temperature
(optional): Controls randomness (0.0 to 1.0)
Example:
{
"action": "chat",
"parameters": {
"messages": [
{"role": "user", "content": "Hello, how are you?"},
{"role": "assistant", "content": "I'm doing well! How can I help?"},
{"role": "user", "content": "Tell me about quantum computing"}
],
"temperature": 0.7
}
}
Error Handling
The server returns appropriate HTTP status codes and error messages:
-
200
: Successful request -
400
: Bad request (missing or invalid parameters) -
500
: Server error (API issues, etc.)
Testing
Use the included test script to test various functionalities:
# Test all functionalities
python test_client.py
# Test specific functionality
python test_client.py text # Test text generation
python test_client.py analyze # Test text analysis
python test_client.py chat # Test chat functionality
MCP Protocol Specification
The Model Context Protocol implemented here follows these specifications:
-
Request Format:
-
action
: String specifying the operation -
parameters
: Object containing action-specific parameters
-
-
Response Format:
-
result
: Object containing the operation result -
error
: String explaining any error (when applicable)
-
License
MIT License
相关推荐
I find academic articles and books for research and literature reviews.
Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.
Confidential guide on numerology and astrology, based of GG33 Public information
Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.
Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.
Advanced software engineer GPT that excels through nailing the basics.
Converts Figma frames into front-end code for various mobile frameworks.
Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.
La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.
Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx
Plataforma de automatización de flujo de trabajo de código justo con capacidades de IA nativas. Combine el edificio visual con código personalizado, auto-anfitrión o nube, más de 400 integraciones.
Espejo dehttps: //github.com/agentience/practices_mcp_server
🧑🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.
Reviews

user_8KFgkYu9
As a dedicated user of mcp-server, I am thoroughly impressed with its seamless performance and easy integration. This open-source solution, crafted by amitsh06, has significantly streamlined my server management tasks. The detailed documentation on GitHub ensures a smooth setup process. Highly recommend it to any developer seeking efficient server management!