Skip to main content
Glama
rajeevchandra

SQL Query MCP Server

🚀 MCP-Powered Streamlit Dashboard with Ollama + PostgreSQL

A modern data analysis tool that lets you:

  • Query your PostgreSQL database with natural language

  • Run SQL manually or generate it using LLMs (Ollama)

  • Analyze data with charts, statistics, and export to CSV


🧠 Prompt-to-SQL Flow

graph TD
    A[🧑 User types a data question] --> B[Streamlit sends prompt to Ollama API]
    B --> C[Ollama generates SQL query as text]
    C --> D[Streamlit extracts the SQL]
    D --> E[Streamlit sends SQL to MCP server]
    E --> F[MCP executes query on PostgreSQL]
    F --> G[Results returned to Streamlit]
    G --> H[📊 Results shown + Chart + CSV Export]

Related MCP server: PostgreSQL MCP AI Explorer

📦 Architecture

  • Streamlit – UI + charting

  • MCP (FastMCP) – Tools/resources for SQL query and table listing

  • PostgreSQL – Stores your company data

  • Ollama – LLM that translates natural language prompts to SQL


📌 Features

✅ Natural language → SQL
✅ Charting (bar/line/time series)
✅ CSV download
✅ Statistical summary
✅ Prompt explainability with raw output
✅ Auto-detect date/time fields
✅ LLM integration with llama3 (configurable)


🛠️ Getting Started

git clone <this-repo>
cd postgres-mcp-server
docker-compose up --build

⚙️ Env Configuration

MCP_API_URL=http://mcp-server:3333/mcp
OLLAMA_URL=http://ollama:11434/api/generate

📤 Prompt Example

“List departments with average salary > 50000”

👉 Translated to SQL:

SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 50000;

Why is this a good use case for MCP?

🔗 MCP makes it dead simple to expose structured tools like SQL queries to LLMs. 🎯 Agents can discover and call your tools without hardcoding logic. 💬 You get the best of both worlds — interpretability, flexibility, and control.

Whether you're building internal tools, research dashboards, or intelligent agents — this pattern is reusable, secure, and 100% local.

📄 License

MIT

F
license - not found
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    quality
    D
    maintenance
    A FastMCP server that provides natural language interaction with MS SQL databases, enabling users to query data, list tables, describe structures, and execute database operations through a conversational AI interface.
    Last updated
  • F
    license
    -
    quality
    D
    maintenance
    A Model Context Protocol server that enables natural language data exploration and visualization for PostgreSQL databases. It allows users to convert questions into SQL queries and interact with data through a Streamlit web interface featuring automated chart generation.
    Last updated
  • A
    license
    A
    quality
    A
    maintenance
    An MCP server that gives AI agents direct read-only access to PostgreSQL databases, enabling natural language analytics through tools for schema exploration, querying, trend analysis, and data quality checks.
    Last updated
    11
    5
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rajeevchandra/mcp-ollama-postgres'

If you have feedback or need assistance with the MCP directory API, please join our Discord server