Skip to main content
Glama

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
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

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
                  FastMCP is a comprehensive MCP server allowing secure and standardized data and functionality exposure to LLM applications, offering resources, tools, and prompt management for efficient LLM interactions.
                  Last updated 6 months ago
                  3
                  Python
                  MIT License
                • -
                  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 4 months ago
                  Python
                • -
                  security
                  A
                  license
                  -
                  quality
                  MCP-Server from your Database optimized for LLMs and AI-Agents. Supports PostgreSQL, MySQL, ClickHouse, Snowflake, MSSQL, BigQuery, Oracle Database, SQLite, ElasticSearch, DuckDB
                  Last updated 7 days ago
                  428
                  Go
                  Apache 2.0
                  • Linux
                • -
                  security
                  A
                  license
                  -
                  quality
                  A FastMCP-based server that enables executing Microsoft SQL Server data queries and table structure queries through a standardized MCP protocol interface.
                  Last updated 2 months ago
                  3
                  Python
                  MIT License

                View all related MCP servers

                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