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.3.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.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ollama_websearch_mcp-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 b363e98c7cd0b163cb8651217b1e8182f2e341c4763836c6ddb61a02b126e917
MD5 49541b1e6e8ad13dcf877d5710cb8e7e
BLAKE2b-256 579802bbaa597cda8a77a84167d063c42cd0211b5e1fa943a1e8b54845ee0246

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ollama_websearch_mcp-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3c2c42df26c21df07796e2e5a4e23dd8a9e01c4e7f6f2a6e58eb9f548bef4392
MD5 704e3ee8697d5332cf3892c7e9cca9cd
BLAKE2b-256 db5cd45b3dc12b2c77440aa0a837954c5b158de3fb5d8788be350762eea1ab06

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