Skip to main content

MCP server for Ontology Lookup Service (OLS) API

Project description

OLS MCP Server

Large Language Models are notoriously bad at working with ontologies, often hallucinating terms or their identifiers. This server provides a reliable way to access and query ontologies, ensuring accurate and up-to-date information.

Speaking ontologies

This repository contains a Model Context Protocol (MCP) server providing access to the Ontology Lookup Service (OLS) API. This server enables AI assistants to search for and retrieve ontological terms, concepts, and hierarchies from various biological and medical ontologies.

This server is designed to work seamlessly with AI assistants like Claude Desktop, allowing users to query ontologies using natural language. It supports a wide range of ontologies, including Gene Ontology (GO), Human Phenotype Ontology (HP), and many others.

The mcp server in action in Claude Desktop.

Without (top part of image below) and with mcp server engaged (bottom of figure below):

With and without mcp server in claude desktop.

Features

The OLS MCP Server provides the following tools:

  • 🔍 Search Terms: Search for terms across ontologies with flexible filtering
  • 📚 Search Ontologies: Discover available ontologies and their metadata
  • ℹ️ Get Ontology Information: Retrieve detailed information about specific ontologies
  • 🎯 Get Term Information: Get comprehensive details about specific terms
  • 🌳 Get Term Children: Find direct child terms in ontological hierarchies
  • 👨‍👩‍👧‍👦 Get Term Ancestors: Retrieve parent terms and ancestors
  • 🤖 Find Similar Terms: Discover semantically similar terms using LLM embeddings

Supported Ontologies

The server works with any ontology available through the EBI Ontology Lookup Service, including:

  • GO (Gene Ontology)
  • EFO (Experimental Factor Ontology)
  • HP (Human Phenotype Ontology)
  • MONDO (Monarch Disease Ontology)
  • ChEBI (Chemical Entities of Biological Interest)
  • UBERON (Uber-anatomy ontology)
  • And many more...

Installation

Prerequisites

  • Python 3.12 or higher
  • uv package manager

Install uv (if not already installed)

# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

Install the OLS MCP Server

# Clone the repository
git clone https://github.com/seandavi/ols-mcp-server.git
cd ols-mcp-server

# Install dependencies
uv sync

# Install as a tool (optional)
uv tool install .

Configuration

Claude Desktop Configuration

To use this server with Claude Desktop, add the following configuration to your Claude Desktop config file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "ols-mcp-server": {
      "command": "uv",
      "args": [
        "tool",
        "run",
        "ols-mcp-server"
      ],
      "env": {}
    }
  }
}

Alternative Configuration (if installed as tool)

If you installed the server as a uv tool, you can use this simpler configuration:

{
  "mcpServers": {
    "ols-mcp-server": {
      "command": "ols-mcp-server",
      "args": [],
      "env": {}
    }
  }
}

Usage Examples

Once configured with Claude Desktop, you can use natural language to interact with the OLS API:

Searching for Terms

"Search for terms related to diabetes in the Human Phenotype Ontology"

"Find all terms containing 'apoptosis' in the Gene Ontology"

Getting Ontology Information

"Tell me about the Gene Ontology"

"What ontologies are available for chemical compounds?"

Exploring Term Hierarchies

"Show me the children of the term 'metabolic process' in GO"

"What are the ancestor terms for HP:0000118?"

Finding Similar Terms

"Find terms similar to 'heart development' in the Gene Ontology"

Development Setup

Setting up the Development Environment

  1. Clone the repository:

    git clone <repository-url>
    cd ols-mcp-server
    
  2. Install dependencies:

    uv sync --extra dev
    
  3. Activate the virtual environment:

    source .venv/bin/activate  # macOS/Linux
    # or
    .venv\Scripts\activate     # Windows
    

Code Quality

# Format code
uv run ruff format

# Lint code
uv run ruff check

# Type checking
uv run mypy src/

Adding New Features

  1. Add new tools in src/ols_mcp_server/server.py using the @mcp.tool() decorator
  2. Create models in src/ols_mcp_server/models.py for structured responses
  3. Update tests to cover new functionality
  4. Update documentation as needed

API Documentation

The server interacts with the EBI Ontology Lookup Service API v2. Key endpoints:

  • Search: https://www.ebi.ac.uk/ols4/api/search
  • Ontologies: https://www.ebi.ac.uk/ols4/api/v2/ontologies
  • Terms: https://www.ebi.ac.uk/ols4/api/terms
  • Hierarchies: https://www.ebi.ac.uk/ols4/api/v2/ontologies/{ontology}/classes/{term}/children

Troubleshooting

Common Issues

  1. Server not found: Ensure the path to the server is correct in your Claude config
  2. Permission errors: Make sure the server script is executable
  3. Network errors: Check your internet connection and firewall settings
  4. Python version: Ensure you're using Python 3.12 or higher

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Run tests: uv run pytest
  5. Format code: uv run ruff format
  6. Submit a pull request ]

Acknowledgments

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

iflow_mcp_ols_mcp_server-0.1.0.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

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

iflow_mcp_ols_mcp_server-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_ols_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_ols_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_ols_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1a9a87fb89c63f9ae6cb4703f6d666c16575601478e7ad396a480da7baddfb6e
MD5 58e75becca0f07e3032e7b78daa668fc
BLAKE2b-256 cd6cb4e611cc1bc808ec1d6358722cc438ee3fbdd254a9cbc53d922782bf577e

See more details on using hashes here.

File details

Details for the file iflow_mcp_ols_mcp_server-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_ols_mcp_server-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_ols_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d66b042bf064105cdbd2c5cabdf0575576520ca634a1b52e3db2ccbc9d1998f9
MD5 a1d0543f3f167239c2e14d5049ffb790
BLAKE2b-256 70d31e663e4198f752dfb6dff3a5032377081e7338078ad0b089981211f4977f

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