Ollama Server
FreeNot checkedEnables natural language database queries by combining Ollama's language models with SQLite database access through an MCP server.
About
Enables natural language database queries by combining Ollama's language models with SQLite database access through an MCP server.
README
A simple Model Context Protocol (MCP) server that enables natural language database queries by combining Ollama's language models with SQLite database access.
Overview
This project demonstrates how to build an MCP server that exposes SQLite database operations as tools, which can then be called by an AI language model (Ollama) through an agentic loop. Users can ask natural language questions about their database, and the system will automatically determine which SQL queries to execute and return human-readable results.
How It Works
The system consists of two main components:
- Server (
server.py): An MCP server that provides tools for interacting with a SQLite database - Client (
client.py): An MCP client that connects to Ollama and uses the server's tools to answer natural language queries
The flow:
- User asks a natural language question
- Client sends question to Ollama with available MCP tools
- Ollama determines which tools to call and generates tool arguments
- Client executes tools via MCP server
- Results are fed back to Ollama for response generation
- Final answer is displayed to the user
Features
MCP Server Tools:
list_tables(): Lists all tables in the SQLite databasedescribe_table(table_name): Returns the schema of a specific tableexecute_query(sql): Executes read-only SQL SELECT statements (write operations are blocked for safety)
Natural Language Interface: Ask questions in German or English about your database
Agentic Loop: The AI model automatically chains tool calls to answer complex questions
Safety: Write operations are blocked; only SELECT queries are allowed
Requirements
- Python 3.8+
- Ollama (running locally or accessible remotely)
- A local SQLite database
Installation
- Clone the repository:
git clone https://github.com/ollibeyer/mcp-example.git
cd mcp-example
- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Ensure Ollama is running with the required model:
ollama pull qwen2.5:7b-instruct
ollama serve
Usage
Run the client with a natural language query:
python client.py "Welche Tabellen gibt es in der Datenbank?"
Or run with a custom query:
python client.py "Zeige mir alle Kunden aus Berlin."
Some example queries:
- "Welche Tabellen gibt es in der Datenbank?" (What tables are in the database?)
- "Zeige mir alle Kunden aus Berlin." (Show me all customers from Berlin.)
- "Welches Produkt wurde am häufigsten bestellt?" (Which product was ordered most frequently?)
Configuration
Edit the following variables in client.py to customize:
MODEL: The Ollama model to use (default:qwen2.5:7b-instruct)SERVER_SCRIPT: Path to the server scriptPYTHON: Path to the Python executable in the virtual environment
Edit server.py to change:
DB_PATH: Path to your SQLite database (default:sample.dbin the same directory)
Database
The project includes a sample SQLite database (sample.db) with example tables. You can replace it with your own database or modify the DB_PATH in server.py.
Development
To extend this project:
- Add new tools to
server.pyusing the@mcp.tool()decorator - Optionally customize the tool-to-Ollama conversion in
client.py - Experiment with different Ollama models
License
This is an example project. Feel free to use, modify, and extend it for your own purposes.
References
Installing Ollama Server
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/ollibeyer/mcp-exampleFAQ
Is Ollama Server MCP free?
Yes, Ollama Server MCP is free — one-click install via Unyly at no cost.
Does Ollama Server need an API key?
No, Ollama Server runs without API keys or environment variables.
Is Ollama Server hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Ollama Server in Claude Desktop, Claude Code or Cursor?
Open Ollama Server on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
wenb1n-dev/SmartDB_MCP
A universal database MCP server supporting simultaneous connections to multiple databases. It provides tools for database operations, health analysis, SQL optim
by wenb1n-devPostgres Server
This server enables interaction with PostgreSQL databases through the Model Context Protocol, optimized for the AWS Bedrock AgentCore Runtime. It provides tools
by madhurprashPostgres
Query your database in natural language
by AnthropicPostgreSQL
Read-only database access with schema inspection.
by modelcontextprotocolCompare Ollama Server with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All data MCPs
