mcpField
A
Anthropic Model Context Protocol (MCP) Server with Ollama Integration

Anthropic Model Context Protocol (MCP) Server with Ollama Integration

Local
github.com/jorgesandovalAI & Agents0Updated 77w ago

About Anthropic Model Context Protocol (MCP) Server with Ollama Integration

This project combines an Anthropic-compatible MCP server with middleware that routes inference requests to Ollama and Gemma3:4b. It is for users who want MCP context features alongside local model inference and SQLite-backed conversation context.

Key features

  1. 01MCP tools for context management
  2. 02Resources for conversation history
  3. 03Standard prompt templates
  4. 04Middleware connects to Ollama inference
  5. 05SQLite storage for conversation context

Use cases

  1. 01Use Gemma3:4b for inference through Ollama
  2. 02Expose conversation history to an MCP client
  3. 03Store context across a conversation session

MCP support

The server exposes tools, conversation-history resources, and prompt templates through MCP. Middleware connects inference requests to Ollama and stores conversation context in the server.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Anthropic Model Context Protocol (MCP) Server with Ollama Integration

A hybrid architecture combining an Anthropic-compatible Model Context Protocol (MCP) server with Ollama/Gemma LLMs for inference. This implementation follows the official Model Context Protocol specification while using open-source models.

Overview

This project implements an Anthropic-compatible MCP server following the official MCP specification, along with middleware that handles communication between clients and Ollama's Gemma model.

Architecture
┌───────────┐     ┌──────────────┐     ┌────────────────────────┐
│  Client   │────▶│   Middleware │────▶│  Anthropic MCP Server  │
│           │◀────│              │◀────│  (Claude MCP Protocol) │
└───────────┘     └──────┬───────┘     └────────────────────────┘
                         │                          │
                         │                          │
                         ▼                          ▼
                  ┌─────────────┐         ┌────────────────────┐
                  │    Ollama   │         │   SQLite Database  │
                  │ (Gemma3:4b) │         │  (Context Storage) │
                  └─────────────┘         └────────────────────┘

Components

  • MCP Server: Implements the Anthropic MCP protocol on port 3000
  • Middleware: Handles communication between clients and Ollama
  • Ollama: Runs the Gemma3:4b model for inference
  • Database: SQLite database for storing conversation contexts

Features

  • MCP Protocol Features:

    • Tools: For context management
    • Resources: Expose conversation history
    • Prompts: Standard prompt templates
  • Model Support:

    • Use with Claude models via Claude Desktop or other MCP clients
    • Compatible with any client supporting the Model Context Protocol

MCP Protocol Compliance

This implementation strictly adheres to the official Model Context Protocol (MCP) specification published by Anthropic:

  1. JSON-RPC 2.0 Protocol: Uses the standard JSON-RPC 2.0 format for all communication, ensuring compatibility with other MCP clients and servers.

  2. Protocol Initialization: Correctly implements the /initialize endpoint with proper protocol version negotiation (2024-03-26) and client capability declarations.

  3. Tool Interface: Fully implements the tool calling protocol with all required annotations:

    • readOnlyHint: Indicates whether tools modify state
    • destructiveHint: Flags potentially destructive operations
    • idempotentHint: Marks operations that can be safely retried
  4. Resource Management: Implements the resource protocol for exposing conversation history with proper URIs and MIME types.

  5. Prompt Templates: Provides standard prompt templates following the MCP specification for common operations.

  6. Error Handling: Implements proper error responses with standardized error codes and messages as specified in the protocol.

  7. Security: Follows the security recommendations in the MCP specification regarding authentication and authorization.

  8. Versioning: Properly handles protocol versioning to ensure forward compatibility.

Our implementation is designed to be fully compatible with any MCP client, including Claude Desktop, VS Code extensions, and other tools that adhere to the official specification.

API Endpoints

MCP Server (port 3000)

The MCP Server implements the official MCP protocol endpoints:

  • Tools: /tools/list, /tools/call
  • Resources: /resources/list, /resources/read
  • Prompts: /prompts/list, /prompts/get
  • Core: /initialize
Middleware (port 8080)
  • POST /infer: Send user messages to Ollama/Gemma while storing context in the MCP server
  • GET /health: Check the health of the middleware and its connections

Requirements

  • Python 3.10+
  • Docker and Docker Compose
  • Ollama with Gemma3:4b model installed

Installation

Using setup script
chmod +x setup.sh
./setup.sh

The setup script will:

  1. Check for Docker installation
  2. Check for Ollama installation and pull the Gemma model if needed
  3. Build and start the Docker containers
Manual setup
# Clone the repository
git clone <repository-url>
cd simple-mcp-server

# Make sure Ollama is running with Gemma model
ollama pull gemma3:4b

# Build and run with Docker
docker-compose build
docker-compose up -d

Usage Example

Using the Middleware with Ollama/Gemma

You can interact with the system through the middleware, which will use Ollama/Gemma for inference while storing conversation context in the MCP server:

# Start a new conversation
curl -X POST http://localhost:8080/infer \
  -H "Content-Type: application/json" \
  -d '{"session_id": "user123", "content": "Hello, how are you today?"}'

# Continue the conversation with the same session ID
curl -X POST http://localhost:8080/infer \
  -H "Content-Type: application/json" \
  -d '{"session_id": "user123", "content": "What's the capital of France?"}'
Using the MCP Server Directly

The MCP server on port 3000 can be used with any MCP client, such as:

  • Claude Desktop App
  • VS Code GitHub Copilot
  • Cursor
  • And many other tools listed on the MCP Clients page

Docker Configuration

The project uses Docker to containerize two main components:

  • MCP Server Container: Provides the Anthropic MCP protocol on port 3000
  • Middleware Container: Connects to Ollama for Gemma model inference on port 8080

Testing

To test your installation:

# Run the included test script
python test_system.py

# Or use the shell script
./test.sh

License

This project is licensed under the MIT License - see the LICENSE file for details.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.