MCP Database Assistant
Provides tools for reading and writing to a SQLite database, including sales analytics, inventory management, customer management, and order processing.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Database AssistantShow me the current inventory levels for all products."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP-Database-Assistant
The goal of this project is to build a simple realistic Database AI assistant following Model-Context-Protocol (MCP) standard that can understand natural-language questions using LLM like Ollama, communicates with database tools through an MCP client-server architecture, selects the correct database operation, and performs safe read/write actions on an external SQLite database.
Project Structure:
mcp_db_assistant/
├── streamlit_app.py # Simple browser UI for dropdown/custom questions, write approval, and final answer
├── host_app.py # Host app: Ollama LLM + MCP client orchestration
├── mcp_server.py # MCP server: exposes read/write DB tools
├── init_db.py # Creates and resets SQLite database
├── retail.db # Sample SQLite database
├── requirements.txt
├── .envTech stack used: Python, Ollama, qwen2.5:7b, MCP SDK, FastMCP, SQL, Streamlit
Related MCP server: MCP SQLite Server
Workflow:
User asks a natural-language question
↓
Host discovers relevant MCP tools from the MCP server
↓
Host sends question + MCP tool schemas to Ollama qwen2.5:7b
↓
Ollama LLM decides which exposed tool to call and what arguments to pass
↓
Host executes the respective registered tool through MCP Client SDK
↓
MCP Client talks to MCP Server using MCP JSON-RPC over stdio
↓
MCP Server reads/writes SQLite database
↓
Executed tool result goes back to Host
↓
Host sends result back to Ollama
↓
Ollama explains the result to the end userImportant communication distinction
Host ↔ Ollama LLM
Uses Ollama Python SDK / Ollama API
Host ↔ MCP Client SDK
Uses normal Python method calls, such as session.call_tool(...)
MCP Client ↔ MCP Server
Uses MCP protocol, JSON-RPC over stdio
MCP Server ↔ SQLite Database
Uses normal python, sqlite3 database codeTools registered in the MCP server
The MCP server has below registered tools which are the controlled database operations.
For reading operations:
list_tables
describe_table
get_sales_summary
get_revenue_by_region
get_sales_by_channel
get_daily_sales_trend
check_inventory
get_product_details
search_products
get_low_stock_products
get_supplier_reorder_report
get_top_products_by_revenue
get_customer_profile
get_customer_orders
get_order_details
get_segment_performance
run_readonly_sql
For writing operations: The Host asks for human confirmation before executing write tools.
create_customer
update_customer_segment
create_product
update_product_price
update_reorder_level
restock_inventory
adjust_inventory
create_sales_order
cancel_order
For tracking/auditing operations:
get_inventory_movements
get_audit_log
Handling Out-of-scope questions
Out-of-context handling is mainly done through the Host’s system prompt. If a custom question is not related to this retail database assistant, the LLM should not call MCP tools for unrelated topics. It should answer with a short message explaining that the demo only supports retail database operations and analytics, such as customers, products, inventory, sales/orders, suppliers, and audit logs.
This server cannot be deployed
Maintenance
Related MCP Connectors
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to connect to and query an SQLite database through the Model Context Protocol, allowing natural language interaction with database tables and data.-
- FlicenseNot gradedqualityDmaintenanceQuery, explore, and manage SQLite databases through the Model Context Protocol. Connect any MCP-compatible AI client to your databases.-
- FlicenseNot gradedqualityDmaintenanceEnables natural language database queries by combining Ollama's language models with SQLite database access through an MCP server.-
- FlicenseNot gradedqualityDmaintenanceEnables querying and managing a SQLite database using natural language, with an MCP server and Groq LLM.-