nishantmunjal2003/mcp-server-gemini
3.2
If you are the rightful owner of mcp-server-gemini and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
MCP Server is a lightweight, extendable API server designed for natural language processing and database logging.
๐ง MCP Server: Model Context Prototyping with Gemini + MySQL + FastAPI
๐ Project Overview
MCP Server is a lightweight, extendable API server that:
- Accepts a natural language
prompt
- Sends the prompt to Gemini (Google's LLM) via API
- Stores both the prompt and the AI-generated response into a MySQL database
- Built using FastAPI, Google Generative AI SDK, and MySQL
โ๏ธ Features
- ๐ REST API Endpoint:
/get-context/
- ๐ง LLM Integration: Gemini via
google-generativeai
- ๐๏ธ Database Logging: Stores prompt & response
- ๐ API key secured via
.env
- ๐ Easy to deploy on local or cloud (Render, Railway, etc.)
๐ Folder Structure
mcp-server/
โ
โโโ app.py # Main FastAPI server
โโโ gemini_integration.py # Gemini API integration
โโโ schema.sql # SQL for DB setup
โโโ requirements.txt # Python dependencies
โโโ .env # Environment variables
โโโ README.md # Project documentation
๐ Getting Started
โ 1. Clone or Unzip the Project
unzip mcp_server.zip
cd mcp-server
โ 2. Install Requirements
pip install -r requirements.txt
โ 3. Configure Environment Variables
Create or edit the .env
file:
GEMINI_API_KEY=your_google_gemini_api_key_here
You can get your key from Google AI Studio.
โ 4. Setup MySQL Database
Option A: Use schema.sql
Run this SQL file in MySQL:
CREATE DATABASE IF NOT EXISTS mcp_db;
USE mcp_db;
CREATE TABLE IF NOT EXISTS responses (
id INT AUTO_INCREMENT PRIMARY KEY,
prompt TEXT,
response TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
โ 5. Run the FastAPI Server
uvicorn app:app --reload
Access it at:
๐ http://127.0.0.1:8000
๐งช How to Use
๐ API Endpoint
POST /get-context/
Content-Type: application/json
๐ฅ Request Body
{
"prompt": "What is quantum computing?"
}
๐ค Response
{
"status": "success",
"response": "Quantum computing is a field of computing that..."
}
๐ Security Notes
- API key stored securely in
.env
- Use HTTPS if deploying online
โ๏ธ Cloud Deployment
Deploy on:
๐ฆ Postman Test
curl --location --request POST 'http://127.0.0.1:8000/get-context/' \
--header 'Content-Type: application/json' \
--data-raw '{
"prompt": "What is quantum computing?"
}'
๐ License
Open-source for research, learning, and educational purposes.