Ollama MCP Database Assistant
Manages environment variables for database connection strings and model configuration in a secure way.
Provides the runtime environment needed for executing the MCP server application.
Leverages Ollama's LLM capabilities to interpret natural language questions, generate SQL queries, and provide AI-powered responses based on database results.
Provides natural language interface to PostgreSQL databases, enabling SQL query generation, schema-aware responses, and read-only data access through the Model Context Protocol.
Click on "Install 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., "@Ollama MCP Database Assistantwhat were our top 5 selling products last quarter?"
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.
Ollama MCP Database Assistant
An interactive chat interface that combines Ollama's LLM capabilities with PostgreSQL database access through the Model Context Protocol (MCP). Ask questions about your data in natural language and get AI-powered responses backed by real SQL queries.
Features
Natural language interface to your PostgreSQL database
Automatic SQL query generation
Schema-aware responses
Interactive chat interface
Secure, read-only database access
Related MCP server: PostgreSQL MCP Server
Prerequisites
Node.js 16 or higher
A running PostgreSQL database
Ollama installed and running locally
The qwen2.5-coder:7b-instruct model pulled in Ollama
Setup
Clone the repository:
git clone [your-repo-url]
cd [your-repo-name]Install dependencies:
npm installPull the required Ollama model:
ollama pull qwen2.5-coder:7b-instructCreate a
.envfile in the project root:
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
OLLAMA_MODEL=qwen2.5-coder:7b-instruct # Optional - this is the defaultUsage
Start the chat interface:
npm startAsk questions about your data in natural language:
Connected to database. You can now ask questions about your data.
Type "exit" to quit.
What would you like to know about your data? Which products generated the most revenue last month?
Analyzing...
[AI will generate and execute a SQL query, then explain the results]Type 'exit' to quit the application.
How It Works
The application connects to your PostgreSQL database through the PostgreSQL MCP server
It loads and caches your database schema
When you ask a question:
The schema and question are sent to Ollama
Ollama generates an appropriate SQL query
The query is executed through MCP
Results are sent back to Ollama for interpretation
You receive a natural language response
Environment Variables
Variable | Description | Default |
DATABASE_URL | PostgreSQL connection string | Required |
OLLAMA_MODEL | Ollama model to use | qwen2.5-coder:7b-instruct |
Security
All database access is read-only
SQL queries are restricted to SELECT statements
Database credentials are kept secure in your .env file
Development
Built with:
TypeScript
Model Context Protocol (MCP)
Ollama
PostgreSQL
Troubleshooting
Common Issues
"Failed to connect to database"
Check your DATABASE_URL in .env
Verify PostgreSQL is running
Check network connectivity
"Failed to connect to Ollama"
Ensure Ollama is running (
ollama serve)Verify the model is installed (
ollama list)
"Error executing query"
Check database permissions
Verify table/column names in the schema
License
MIT
Contributing
Fork the repository
Create your feature branch
Commit your changes
Push to the branch
Open a Pull Request
This server cannot be installed
Maintenance
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
- AlicenseBqualityBmaintenanceA Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.Last updated182,274198AGPL 3.0
- Alicense-qualityFmaintenanceA Model Context Protocol server providing dual transport (HTTP and Stdio) access to PostgreSQL databases, allowing AI assistants to query databases and fetch schema information through natural language.Last updated9031MIT
- Alicense-qualityDmaintenanceProvides a natural language interface for querying and managing PostgreSQL, MySQL, MariaDB, MSSQL, and SQLite databases using the Model Context Protocol. Users can explore database schemas and visualize query results through an integrated web dashboard.Last updated26MIT
- Flicense-qualityDmaintenanceA 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
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
GibsonAI MCP server: manage your databases with natural language
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/robdodson/ollama-mcp-db'
If you have feedback or need assistance with the MCP directory API, please join our Discord server