mcp-client-for-ollama

The mcp-client-for-ollama is a simple yet powerful Python client designed for interacting with Model Context Protocol (MCP) servers using Ollama. This client enables local large language models (LLMs) to utilize tools effectively. It primarily facilitates communication with APIs, streamlining workflows and enhancing the capabilities of LLMs.

GitHub Stars

215

User Rating

Not Rated

Favorites

0

Views

175

Forks

35

Issues

10

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Python 3.10以上

Installation

Installation

Prerequisites

Python: 3.10 or higher

Installation Steps

1. Clone Repository

bash
git clone https://github.com/jonigl/mcp-client-for-ollama.git
cd mcp-client-for-ollama

2. Install Dependencies

bash
pip install -r requirements.txt

3. Start the Server

bash
python -m mcp_client

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Python version and reinstall dependencies.

Configuration

Configuration

Basic Configuration

Server Setup

Edit ~/.config/mcp_client/config.json:
json
{
  "mcpServers": {
    "example-server": {
      "url": "http://localhost:3000",
      "model": "example-model"
    }
  }
}

Advanced Configuration

Environment Variables

Set the following environment variables as needed:
bash
export MCP_SERVER_URL="http://localhost:3000"

Security Settings

Store API keys in environment variables or secure configuration files
Set appropriate file access permissions

Examples

Examples

Basic Usage

Here are basic usage examples for the MCP server:

Command-line Usage

bash
mcp-client --server example-server --model example-model

Programmatic Usage

python
import requests

response = requests.get('http://localhost:3000/mcp/call', params={'tool': 'example-tool'})
print(response.json())

Use Cases

Testing different models simultaneously using multiple MCP servers.
Utilizing streaming responses for real-time data processing.
Using human-in-the-loop capabilities for users to review model outputs and provide feedback.
Employing dynamic model switching to select the optimal model based on different tasks.

Additional Resources