Skip to main content
Glama
galaxyproject

galaxy-mcp

Official
README.md
# Galaxy MCP Server

This project provides a Model Context Protocol (MCP) server for interacting with the Galaxy bioinformatics platform. It enables AI assistants and other clients to connect to Galaxy instances, search and execute tools, manage workflows, and access other features of the Galaxy ecosystem.

## Project Overview

This repository contains a Python-based MCP server implementation that provides comprehensive integration with Galaxy's API through BioBlend.

In addition to the Python server, this repository now includes a **TypeScript
workspace** in [`galaxy-agent-tools/`](galaxy-agent-tools/) that offers the same
Galaxy operations two ways: a `galaxy-cli` command-line tool and a `galaxy-mcp`
(Node) MCP server, built on a shared core and kept in lockstep with this server's
toolset. See the [galaxy-agent-tools README](galaxy-agent-tools/README.md) to build
and use it.

## Key Features

- **Galaxy Connection**: Connect to any Galaxy instance with a URL and API key
- **OAuth Login (optional)**: Offer browser-based sign-in that exchanges credentials for temporary Galaxy API keys
- **Server Information**: Retrieve comprehensive server details including version, configuration, and capabilities
- **Tools Management**: Search, view details, and execute Galaxy tools
- **Workflow Integration**: Access and import workflows from the Interactive Workflow Composer (IWC)
- **History Operations**: Manage Galaxy histories and datasets
- **File Management**: Upload files to Galaxy from local storage
- **Verified Container Recommendation (optional)**: Resolve a real `quay.io/biocontainers` image for a set of conda packages instead of guessing one -- see [Optional extras](#optional-extras)
- **Comprehensive Testing**: Full test suite with mock-based testing for reliability

## Optional extras

### `container-recommend`

Enables the `recommend_biocontainer` tool, which resolves a verified
`quay.io/biocontainers` image for a set of conda packages. Authoring a user-defined
tool means naming a container, and a hallucinated image tag is the most common way a
UDT passes validation and then dies at run time with `manifest unknown`. This wraps
`galaxy.tool_util.deps.mulled.recommend` -- the same resolver Galaxy's own custom-tool
agent uses (added in Galaxy 26.1, galaxyproject/galaxy#22981) -- so the image is
checked against quay.io rather than invented.

It is an extra rather than a hard dependency because `galaxy-tool-util` pulls in lxml
and conda-package-streaming, and every other tool on this server works without it. The
tool is **only registered when the extra is installed**, so a stock install simply
doesn't advertise it.

```bash
uvx --from 'galaxy-mcp[container-recommend]' galaxy-mcp
# or, for a local checkout:
uv sync --extra container-recommend
```

The same resolver is also available as a standalone CLI once installed:
`mulled-recommend samtools=1.17`.

## Quick Start

The `galaxy-mcp` CLI ships with both stdio (local) and HTTP transports. Choose the setup that
matches your client:

```bash
# Stdio transport (default) – great for local development tools
uvx galaxy-mcp

# HTTP transport with OAuth (for remote/browser clients)
# Generate the session secret ONCE (`openssl rand -hex 32`) and store it. Every
# restart and every replica must use the same value, or tokens issued earlier --
# or by another replica -- stop decrypting.
export GALAXY_URL="https://usegalaxy.org.au/"          # Target Galaxy instance
export GALAXY_MCP_PUBLIC_URL="https://mcp.example.com" # Public base URL for OAuth redirects
export GALAXY_MCP_SESSION_SECRET="<your stored secret>"
uvx galaxy-mcp --transport streamable-http --host 0.0.0.0 --port 8000
```

When running over stdio you can provide long-lived credentials via environment variables:

```bash
export GALAXY_URL="https://usegalaxy.org/"
export GALAXY_API_KEY="your-api-key"
```

For OAuth flows the server exchanges user credentials for short-lived Galaxy API keys on demand, so
you typically leave `GALAXY_API_KEY` unset.

For non-OAuth HTTP clients, `connect(url=..., api_key=...)` stores Galaxy credentials per MCP
session rather than globally. Clients normally preserve MCP sessions by default, which allows
multiple users to share the same MCP server while keeping their Galaxy credentials isolated.

### Alternative Installation

```bash
# Install from PyPI
pip install galaxy-mcp

# Run (stdio by default)
galaxy-mcp

# Or from source using uv
cd mcp-server-galaxy-py
uv sync
uv run galaxy-mcp --transport streamable-http --host 0.0.0.0 --port 8000
```

## Container Usage

Images are published to the GitHub Container Registry as
[`ghcr.io/galaxyproject/galaxy-mcp`](https://github.com/galaxyproject/galaxy-mcp/pkgs/container/galaxy-mcp).
Use `:latest` (default) or pin a release, e.g. `:1.9.0`.

The published image defaults to stdio transport (no HTTP listener):

```bash
docker run --rm -it \
  -e GALAXY_URL="https://usegalaxy.org/" \
  -e GALAXY_API_KEY="your-api-key" \
  ghcr.io/galaxyproject/galaxy-mcp
```

For OAuth + HTTP:

```bash
# Generate once and keep it -- do NOT inline `openssl rand` here, or each
# container start mints a key that invalidates every token issued before it.
export GALAXY_MCP_SESSION_SECRET="<your stored secret>"

docker run --rm -it -p 8000:8000 \
  -e GALAXY_URL="https://usegalaxy.org.au/" \
  -e GALAXY_MCP_TRANSPORT="streamable-http" \
  -e GALAXY_MCP_PUBLIC_URL="https://mcp.example.com" \
  -e GALAXY_MCP_SESSION_SECRET \
  ghcr.io/galaxyproject/galaxy-mcp
```

## Connect to Claude Desktop
- Ensure that GalaxyMCP runs with `uvx galaxy-mcp`
- Add `export GALAXY_SERVER=https://usegalaxy.org` to your .bashrc (or equiv)
- Download and install [claude desktop](https://www.claude.com/download)
- Go to Settings -> Developer -> Edit Config
- Add this to `claude_desktop_config.json`
```
{
  "mcpServers": {
    "galaxy-mcp": {
      "command": "uvx",
      "args": ["galaxy-mcp"],
      "env": {
        "GALAXY_URL": "https://usegalaxy.org",
        "GALAXY_API_KEY": "SECRETS"
      }
    }
  }
}
```
- Under the developer menu, you should now see `galaxy-mcp` as running (you may need to restart Claude desktop)
- Prompt Claude with "can you connect to galaxy"
- If you have not provided the optional env config you'll be asked for connection details which you can provide like "Use my Galaxy API key: XXXXXXX"
- Talk to Claude to work with your galaxy instance, e.g. "give a summary with my histories"

## Development Guidelines

See the [Python implementation README](mcp-server-galaxy-py/README.md) for specific instructions and documentation.

## License

[MIT](LICENSE)