Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Enables natural language database queries by combining Ollama's language models with SQLite database access through an MCP server.

README.md

MCP Ollama Server

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:

  1. Server (server.py): An MCP server that provides tools for interacting with a SQLite database
  2. Client (client.py): An MCP client that connects to Ollama and uses the server's tools to answer natural language queries

The flow:

  1. User asks a natural language question
  2. Client sends question to Ollama with available MCP tools
  3. Ollama determines which tools to call and generates tool arguments
  4. Client executes tools via MCP server
  5. Results are fed back to Ollama for response generation
  6. Final answer is displayed to the user

Features

  • MCP Server Tools:
  • list_tables(): Lists all tables in the SQLite database
  • describe_table(table_name): Returns the schema of a specific table
  • execute_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

  1. Clone the repository:
git clone https://github.com/ollibeyer/mcp-example.git
cd mcp-example
  1. Create a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. 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: ``bash 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 script
  • PYTHON: Path to the Python executable in the virtual environment

Edit server.py to change:

  • DB_PATH: Path to your SQLite database (default: sample.db in 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:

  1. Add new tools to server.py using the @mcp.tool() decorator
  2. Optionally customize the tool-to-Ollama conversion in client.py
  3. Experiment with different Ollama models

License

This is an example project. Feel free to use, modify, and extend it for your own purposes.

References

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.