Skip to content
  • About
  • Courses
  • ResearchExpand
    • Research Publications
    • Books
    • Patents
  • Workshop/Conferences
  • ToolsExpand
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
  • Blog
  • Resume
Download CV
Latest

🧠 MCP Server: Model Context Prototyping with Gemini + MySQL + FastAPI

GitHub: https://github.com/nishantmunjal2003/mcp-server-gemini

πŸ“Œ 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

bashCopyEditmcp-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

bashCopyEditunzip mcp_server.zip
cd mcp-server

βœ… 2. Install Requirements

bashCopyEditpip install -r requirements.txt

βœ… 3. Configure Environment Variables

Create or edit the .env file:

iniCopyEditGEMINI_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:

sqlCopyEditCREATE 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
);

Option B: Manually create in MySQL Workbench or CLI


βœ… 5. Run the FastAPI Server

bashCopyEdituvicorn 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

jsonCopyEdit{
  "prompt": "What is quantum computing?"
}

πŸ“€ Response

jsonCopyEdit{
  "status": "success",
  "response": "Quantum computing is a field of computing that..."
}

❌ Example Error

jsonCopyEdit{
  "status": "error",
  "message": "Prompt is required"
}

πŸ” Security Notes

  • API key stored securely in .env
  • Use HTTPS if deploying online
  • Add authentication middleware if needed

☁️ Cloud Deployment (Optional)

You can deploy this on:

  • Render.com
  • Railway.app
  • Vercel (with Python API)

πŸ“¦ Postman Collection

Import this cURL into Postman:

bashCopyEditcurl --location --request POST 'http://127.0.0.1:8000/get-context/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "prompt": "What is quantum computing?"
}'

Or use the included .postman_collection.json (if provided).


πŸ“œ License

This project is open-source and free to use for educational, academic, and research purposes.

Post navigation

Previous Previous
Why You Can’t Stop Scrolling β€” And What AI Has to Do With It
NextContinue
πŸŽ“ How to Choose Your Final Year Project: A Practical Guide for BTech Students
Latest

πŸŽ“ Why Original Work Matters in Your Final Year Project (And How It Can Shape Your Career)

In engineering colleges across the country, final year projects are often treated as just another academic task. But what many students fail to realize is…

Read More πŸŽ“ Why Original Work Matters in Your Final Year Project (And How It Can Shape Your Career)Continue

Latest

πŸŽ“ How to Choose Your Final Year Project: A Practical Guide for BTech Students

Choosing the right final year project is one of the most important decisions of your engineering journey. It’s more than just a submission β€” it’s…

Read More πŸŽ“ How to Choose Your Final Year Project: A Practical Guide for BTech StudentsContinue

Artificial Intelligence Psychology

Why You Can’t Stop Scrolling β€” And What AI Has to Do With It

Ever caught yourself reaching for your phone, telling yourself it’s β€œjust for a minute”… and then suddenly it’s midnight?You didn’t mean to spend the last…

Read More Why You Can’t Stop Scrolling β€” And What AI Has to Do With ItContinue

Latest

Advance AI PPT

Read More Advance AI PPTContinue

Latest

Prompts for Image Descriptions

Describe the scene using three vivid sensory details β€” one for sight, one for sound, and one for touch. Summarize the mood of the image…

Read More Prompts for Image DescriptionsContinue

Nishant Munjal

Coding Humanity’s Future </>


Facebook Twitter Linkedin YouTube Github Email

Tools

  • SIP Calculator
  • EMI Calculator
  • Creative QR Code
  • Image Converter

Resources

  • Blog
  • Contact
  • Refund and Returns

Legal

  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2025 - All Rights Reserved

  • About
  • Courses
  • Research
    • Research Publications
    • Books
    • Patents
  • Workshop/Conferences
  • Tools
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
  • Blog
  • Resume
Download CV
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.