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.
What is Ollama MCP Database Assistant?
Ollama MCP Database Assistant is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 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 a...
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.
This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- An interactive chat interface that combines Ollama's LLM cap
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx ollama-mcp-database-assistantConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Ollama MCP Database Assistant
The Ollama MCP Database Assistant is an interactive chat interface that combines a locally-running Ollama language model with PostgreSQL database access through the Model Context Protocol, enabling users to ask natural language questions about their data and receive AI-generated answers backed by real SQL queries. Unlike cloud-based database AI tools, all LLM processing happens locally via Ollama (defaulting to the qwen2.5-coder:7b-instruct model), keeping sensitive database contents private. It is designed for developers and data analysts who want a conversational interface to their PostgreSQL databases without sending data to external AI providers.
Prerequisites
- Node.js 16+ and npm installed
- Ollama installed and running locally (https://ollama.com)
- The qwen2.5-coder:7b-instruct model pulled in Ollama (or another code-capable model)
- A PostgreSQL database with a valid connection string
- Git to clone the repository (no npm package available)
Install Ollama and pull the required model
Download and install Ollama from https://ollama.com, then pull the default model used by this assistant. The model will be used for all SQL generation and response interpretation.
# Pull the default model:
ollama pull qwen2.5-coder:7b-instruct
# Verify Ollama is running:
ollama listClone the repository
Clone the ollama-mcp-db repository to your local machine since it is not published to npm.
git clone https://github.com/robdodson/ollama-mcp-db.git
cd ollama-mcp-dbInstall Node.js dependencies
Install all required npm packages for the TypeScript project.
npm installConfigure your PostgreSQL connection
Create a .env file in the project root with your PostgreSQL connection string and optionally a custom Ollama model identifier.
# Create .env file:
DATABASE_URL=postgresql://user:password@localhost:5432/your_database
OLLAMA_MODEL=qwen2.5-coder:7b-instructStart the assistant
Launch the interactive database assistant. It will connect to your PostgreSQL database and start the MCP server with Ollama integration.
npm startAsk natural language questions about your data
Type natural language questions in the chat interface. The assistant generates SELECT queries, executes them against your database, and returns AI-interpreted results. All operations are read-only.
Ollama MCP Database Assistant Examples
Client configuration
Environment configuration for the Ollama MCP Database Assistant with PostgreSQL connection details.
{
"mcpServers": {
"ollama-db-assistant": {
"command": "node",
"args": ["/path/to/ollama-mcp-db/dist/index.js"],
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mydb",
"OLLAMA_MODEL": "qwen2.5-coder:7b-instruct"
}
}
}
}Prompts to try
Natural language database questions the Ollama MCP Database Assistant can answer.
- "How many users signed up in the last 30 days?"
- "Show me the top 10 best-selling products by revenue this quarter"
- "What is the average order value by country?"
- "List all customers who have not placed an order in over 6 months"
- "What tables are in this database and what are their schemas?"Troubleshooting Ollama MCP Database Assistant
Ollama model not found or slow to respond
Ensure Ollama is running (`ollama serve`) and the model is downloaded (`ollama list`). If qwen2.5-coder:7b-instruct is not listed, run `ollama pull qwen2.5-coder:7b-instruct`. You can switch to a smaller/faster model by changing OLLAMA_MODEL in your .env file.
PostgreSQL connection fails
Verify your DATABASE_URL is correct by testing with psql: `psql postgresql://user:password@localhost:5432/dbname`. Ensure the database user has SELECT permissions on the tables you want to query, and that PostgreSQL is accepting connections on the specified host and port.
SQL queries return unexpected results or errors
The assistant only executes SELECT statements for safety. If the model generates an invalid query, try rephrasing your question to be more specific about the tables or columns involved. You can ask the assistant to 'show the database schema' first to help it generate more accurate queries.
Frequently Asked Questions about Ollama MCP Database Assistant
What is Ollama MCP Database Assistant?
Ollama MCP Database Assistant is a Model Context Protocol (MCP) server that 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. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Ollama MCP Database Assistant?
Follow the installation instructions on the Ollama MCP Database Assistant GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Ollama MCP Database Assistant?
Ollama MCP Database Assistant works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Ollama MCP Database Assistant free to use?
Yes, Ollama MCP Database Assistant is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Ollama MCP Database Assistant Alternatives — Similar Databases Servers
Looking for alternatives to Ollama MCP Database Assistant? Here are other popular databases servers you can use with Claude, Cursor, and VS Code.
Excelize
★ 20.6kGo language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
MCP Toolbox for Databases
★ 15.3kOpen source MCP server specializing in easy, fast, and secure tools for Databases.
DBHub
★ 2.8kA universal database gateway MCP server that enables AI assistants to connect to and query multiple databases (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite) with support for schema exploration, SQL execution, and secure connections via SSH tunnels.
Tabularis
★ 2.1kA lightweight, cross-platform database client for developers. Supports MySQL, PostgreSQL and SQLite. Hackable with plugins. Built for speed, security, and aesthetics.
Postgres AI Guide
★ 1.7kMCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
Anyquery
★ 1.7k🏎️ 🏠 ☁️ - Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by design.
Browse More Databases MCP Servers
Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Ollama MCP Database Assistant in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Ollama MCP Database Assistant?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.