Skip to main content

MCP Service for Ollama Web Search

Project description

Ollama Web Search MCP Service

A MCP (Model Context Protocol) service for performing web searches using Ollama.

Features

  • Perform web searches using Ollama's search capabilities
  • Format search results for easy consumption
  • Official MCP Python SDK implementation
  • Environment-based configuration
  • Comprehensive error handling
  • Stdio-based communication interface

Installation & Usage

Option 1: Direct execution with uvx (Recommended)

Install and run directly using uvx:

uvx ollama-websearch-mcp

This will automatically install the package and its dependencies, then start the MCP server.

Option 2: Local development

For local development, clone the repository and install dependencies:

git clone https://github.com/huangxinping/ollama-websearch-mcp.git
cd ollama-websearch-mcp
uv sync

Local usage commands

Run as MCP Server (for development):

python mcp_service.py

Build Package:

uv build

MCP Interface

Tools

  1. search
    • Description: Perform a web search using Ollama
    • Parameters:
      • query (string): The search query
      • max_results (integer, optional): Maximum number of results to return (default: 3, range: 1-10)

Example Output

Search result format:

1. Example Title
   URL: https://example.com
   Content: Example content from the search result...

2. Another Title
   URL: https://another-example.com
   Content: Another example content...

Project Structure

ollama-websearch-mcp/
├── mcp_service.py             # MCP service main program
├── README.md                  # Project documentation
├── .env                       # Environment variables
├── .gitignore                 # Git ignore file
├── pyproject.toml             # Project configuration file
├── setup.py                   # Package setup file
└── uv.lock                    # Dependency lock file

Tech Stack

  • Python 3.12+: Programming language
  • MCP: Model Context Protocol framework
  • Ollama: AI model API for web search
  • python-dotenv: Environment variable management
  • uv: Python package manager

Development Standards

  • Use uv native commands for package management
  • Follow Python PEP 8 coding standards
  • Include type hints and docstrings
  • Complete error handling and logging

Publishing to PyPI

To publish the package to PyPI, follow these steps:

  1. Install development dependencies:

    uv sync --group dev
    
  2. Build the package:

    uv build
    
  3. Check the built package:

    uv run twine check dist/*
    
  4. Upload to PyPI:

    uv run twine upload dist/*
    

Make sure you have your PyPI credentials configured before uploading.

AI IDE/CLI Configuration

Claude Code (CLI)

Add to your MCP configuration:

{
  "mcpServers": {
    "ollama-websearch": {
      "command": "uvx",
      "args": ["ollama-websearch-mcp"],
      "env": {
        "OLLAMA_API_KEY": "your_api_key_here"
      }
    }
  }
}

Cursor IDE

Add to your .cursorrules or MCP settings:

{
  "mcp": {
    "servers": {
      "ollama-websearch": {
        "command": "uvx",
        "args": ["ollama-websearch-mcp"],
        "env": {
           "OLLAMA_API_KEY": "your_api_key_here"
        }
      }
    }
  }
}

Windsurf IDE

Add to your Windsurf MCP configuration:

{
  "mcpServers": {
    "ollama-websearch": {
      "command": "uvx",
      "args": ["ollama-websearch-mcp"],
        "env": {
           "OLLAMA_API_KEY": "your_api_key_here"
        }
    }
  }
}

VS Code with Continue Extension

Add to your continue configuration:

{
  "mcp": {
    "servers": {
      "ollama-websearch": {
        "command": "uvx",
        "args": ["ollama-websearch-mcp"],
        "env": {
           "OLLAMA_API_KEY": "your_api_key_here"
        }
      }
    }
  }
}

Other MCP-Compatible Tools

For any MCP-compatible client, use:

# Command
uvx ollama-websearch-mcp

# Or with Python path
python -m mcp_service

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ollama_websearch_mcp-0.1.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ollama_websearch_mcp-0.1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file ollama_websearch_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: ollama_websearch_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ollama_websearch_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2a5537061a0876425217f1870bfeea14800aa917326f5e6afbef3492030b0135
MD5 b9c34ea4d163c070f263103c0c76e50f
BLAKE2b-256 e54146e6a3c523981d1518fe7a1b412baf2f38a1607a3aec08442a058d7cfa3c

See more details on using hashes here.

File details

Details for the file ollama_websearch_mcp-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ollama_websearch_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd0146cf1225e5658cc1f421e0ee1f3c8a61a84820d4df9ef8004c57673c6eb7
MD5 9a10b1436eb1deb1d940f4fe655956c8
BLAKE2b-256 78b8f7b9b63d22ffb626d7c11f814492c2715113464f2ec35e7462386638af71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page