Ollama MCP Server Demo
by rohitt08-l
README.md
# 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
## Project Structure
```text
.
├── chat.py
├── generate.py
├── ollama_mcp_server.py
├── test_ollama.py
└── .vscode
├── mcp.json
└── session.py
```
## Architecture
```text
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 (e.g. `gpt-oss:20b-cloud`)
## Installation
Clone the repository:
```bash
git clone <your-repository-url>
cd ollama-mcp-server-demo
```
Install dependencies:
```bash
pip install -r requirements.txt
```
## Running Ollama
Start Ollama:
```bash
ollama serve
```
Verify available models:
```bash
ollama list
```
## Testing Ollama
Run:
```bash
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:
```bash
python ollama_mcp_server.py
```
The server exposes the following MCP tool:
```text
ask_ollama(prompt: str)
```
Example:
```text
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
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues