Related MCP Server Resources

Explore more AI models, providers, and integration options:

  • Explore AI Models
  • Explore AI Providers
  • Explore MCP Servers
  • LangDB Pricing
  • Documentation
  • AI Industry Blog
  • MongoDB MCP Server for LLMs
  • Azure Cosmos DB MCP Server
  • Code Analysis MCP Server
  • AGE-MCP-Server
  • Semgrep MCP Server
Back to MCP Servers
SQL Query MCP Server

SQL Query MCP Server

Public
rajeevchandra/mcp-ollama-postgres

Enables natural language querying of PostgreSQL databases by translating prompts into SQL via LLM integration, with features including data visualization, statistical summaries, CSV export, and seamless Model Context Protocol execution for flexible, interpretable data analysis.

python
0 tools
May 30, 2025
Updated Jun 4, 2025

Supercharge Your AI with SQL Query MCP Server

MCP Server

Unlock the full potential of SQL Query MCP Server through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.

Unified API Access
Complete Tracing
Instant Setup
Get Started Now

Free tier available β€’ No credit card required

Instant Setup
99.9% Uptime
10,000+Monthly Requests

πŸš€ 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]

πŸ“¦ 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 cd postgres-mcp-server docker-compose up --build
  • Access UI: http://localhost:8501
  • MCP API: http://localhost:3333/mcp

βš™οΈ 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

Publicly Shared Threads0

Discover shared experiences

Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!

Share your threads to help others
Related MCPs5
  • MongoDB MCP Server for LLMs
    MongoDB MCP Server for LLMs

    Enables LLMs to seamlessly interact with MongoDB databases via Model Context Protocol, offering sche...

    Added May 30, 2025
  • Azure Cosmos DB MCP Server
    Azure Cosmos DB MCP Server

    Enables seamless, secure interaction between AI language models and Azure Cosmos DB by translating n...

    Added May 30, 2025
  • Code Analysis MCP Server
    Code Analysis MCP Server

    Enables AI-driven natural language exploration and analysis of codebases via Model Context Protocol,...

    4 tools
    Added May 30, 2025
  • AGE-MCP-Server
    AGE-MCP-Server

    Enables integration of Apache AGE graph database capabilities with Azure Database for PostgreSQL thr...

    Added May 30, 2025
  • Semgrep MCP Server
    Semgrep MCP Server

    Model Context Protocol server enabling seamless integration of Semgrep’s fast, semantic static code ...

    6 tools
    Added May 30, 2025