Skip to main content
Glama
deepan2003

Database-MCP

by deepan2003

🏢 Company Database AI Manager

📖 Overview

The Company Database AI Manager is a natural language interface for a corporate database. Instead of writing complex SQL queries to insert, update, or retrieve data, users can simply type commands in plain English (e.g., "Add an IT department and assign 5 employees to it").

The system uses the Model Context Protocol (MCP) to securely connect a Groq-powered LangGraph agent to a local Python database server. The AI autonomously reasons through the user's prompt, selects the correct database tools, executes the SQL operations, and returns the result in a clean Streamlit web interface.

Related MCP server: PySqlitMCP

⚙️ Architecture & How It Works

This project separates the database logic from the AI logic using a true Server/Client architecture:

  1. The Server (server.py & models.py): Runs an independent FastMCP server that hosts SQLite database tools (setup_database, add_record, search_database).

  2. The Client (client.py & app.py): Runs a LangGraph agent powered by Groq's llama-3.3-70b-versatile or openai/gpt-oss-120b.

  3. The Protocol (MCP): The client connects to the server securely via standard input/output (stdio). It asks the server for available tools, passes them to the LangGraph agent, and triggers the Python functions without directly importing them.

📂 Folder Structure

📦 llm-db-mcp
 ┣ 📜 .env                # Stores secure API keys (Do NOT commit to GitHub)
 ┣ 📜 .gitignore          # Prevents sensitive files from being pushed to Git
 ┣ 📜 app.py              # The Streamlit web UI for interacting with the AI
 ┣ 📜 client.py           # The terminal-based LangGraph agent script
 ┣ 📜 company.db          # The automatically generated SQLite database file
 ┣ 📜 models.py           # SQLAlchemy schemas (Departments, Roles, Employees, Projects)
 ┣ 📜 requirements.txt    # Project dependencies and version numbers
 ┗ 📜 server.py           # The FastMCP server hosting the database tools

🚀 Setup & Installation

1. Prerequisites

Python 3.10 or higher.

A free Groq API Key.

2. Environment Setup

Create and activate a virtual environment (Conda is recommended):

conda create -n db_mcp python=3.11
conda activate db_mcp

3. Install Dependencies

Install all required packages from the requirements.txt file:

pip install -r requirements.txt

4. Configure API Keys

Create a .env file in the root directory and add your Groq API key:

GROQ_API_KEY=gsk_your_api_key_here

🖥️ Usage

To launch the interactive chat interface, run:

streamlit run app.py

Option 2: Run the Terminal Client

To run the agent strictly through the command line:

🛠️ Example Prompts to Try

Once the app is running, try typing these prompts into the chat:

"Set up the database tables." (Run this first!)

"Add an IT department."

"Add a new employee named John Doe with a salary of 75000 in the IT department."

"Show me all employees who make more than 50000."

🔒 Security Notes

Never commit your .env file or API keys to version control.

The .gitignore file is pre-configured to block .env and company.db from being uploaded to GitHub.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables natural language database operations and semantic document search through SQLite and vector database integration. Converts plain English instructions into SQL queries and provides RAG capabilities for uploaded documents.
    -
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables comprehensive SQLite database management through natural language, including database creation, table operations, data CRUD operations, backup/restore functionality, and CSV import/export capabilities.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables LLM agents to perform complete database operations on SQLite databases, including creating tables, executing queries, and managing data through CRUD operations with schema inspection capabilities.
    21 npm
    MIT