Skip to main content
Glama
Ollama MCP Server Demo

Ollama MCP Server Demo

by rohitt08-l

Ollama MCP Server Demo

A beginner-friendly project that demonstrates how to build a simple Model Context Protocol (MCP) server using Python and connect it to a local Ollama model.

Overview

This project shows:

  • How to interact with a local Ollama model using the REST API

  • The difference between Ollama's Generate API and Chat API

  • How to expose an Ollama model as an MCP tool

  • How to configure and run an MCP server in VS Code

Related MCP server: mcp-ollama-code-analyzer

Project Structure

.
├── chat.py
├── generate.py
├── ollama_mcp_server.py
├── test_ollama.py
└── .vscode
    ├── mcp.json
    └── session.py

Architecture

MCP Client (VS Code)
        │
        ▼
Python MCP Server
        │
        ▼
Ollama API
        │
        ▼
gpt-oss:20b-cloud

Prerequisites

  • Python 3.10+

  • Ollama installed and running

  • A downloaded Ollama model (ex- gpt-oss:20b-cloud)

Installation

Clone the repository:

git clone <your-repository-url>
cd ollama-mcp-server-demo

Install dependencies:

pip install -r requirements.txt

Running Ollama

Start Ollama:

ollama serve

Verify available models:

ollama list

Testing Ollama

Run:

python test_ollama.py

If everything is working, the model will generate a response in the terminal.

Running the MCP Server

Start the MCP server:

python ollama_mcp_server.py

The server exposes the following MCP tool:

ask_ollama(prompt: str)

Example:

Prompt: Explain MCP

Response: Model Context Protocol (MCP) is...

Learning Objectives

This project helped me understand:

  • MCP fundamentals

  • MCP tools and servers

  • Ollama APIs

  • Local LLM integration

  • VS Code MCP configuration

  • Python-based AI tooling

Future Improvements

  • Add multiple MCP tools

  • Support chat history

  • Add document search (RAG)

  • Connect to SharePoint or Microsoft Graph

  • Add logging and error handling

Author

Rohit Patil

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers