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


📦 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

-
security - not tested
-
license - not tested
-
quality - not tested

A FastMCP server that enables natural language querying of PostgreSQL databases through LLM integration, allowing users to generate SQL queries from plain English and visualize the results.

  1. 🧠 Prompt-to-SQL Flow
    1. 📦 Architecture
      1. 📌 Features
        1. 🛠️ Getting Started
          1. ⚙️ Env Configuration
            1. 📤 Prompt Example
              1. 📄 License

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  This is an MCP server for PostgREST. It allows LLMs perform database queries and operations on Postgres databases via PostgREST. This server works with both Supabase projects (which use PostgREST) and standalone PostgREST servers.
                  Last updated -
                  497
                  1,278
                  TypeScript
                  Apache 2.0
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  A server that enables interaction with PostgreSQL, MySQL, MariaDB, or SQLite databases through Claude Desktop using natural language queries.
                  Last updated -
                  Python
                • -
                  security
                  A
                  license
                  -
                  quality
                  An MCP server that enables natural language querying of Supabase PostgreSQL databases using Claude 3.7, allowing users to inspect schemas, execute SQL, manage migrations, and convert natural language to SQL queries.
                  Last updated -
                  Python
                  MIT License
                  • Linux
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  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 -
                  Python

                View all related MCP servers

                ID: 7briqbw2w5