Model Context Protocol server that surfaces UniProtKB data as MCP resources, tools, and prompts.
Project description
UniProt MCP Server
A Model Context Protocol (MCP) server that provides seamless access to UniProtKB protein data. Query protein entries, sequences, Gene Ontology annotations, and perform ID mappings through a typed, resilient interface designed for LLM agents.
โจ Features
- ๐ Dual Transport: Stdio for local development and Streamable HTTP for remote deployments
- ๐ Rich Data Access: Fetch complete protein entries with sequences, features, GO annotations, cross-references, and taxonomy
- ๐ Advanced Search: Full-text search with filtering by review status, organism, keywords, and more
- ๐ ID Mapping: Convert between 200+ database identifier types with progress tracking
- ๐ก๏ธ Production Ready: Automatic retries with exponential backoff, CORS support, Prometheus metrics
- ๐ Typed Responses: Structured Pydantic models ensure data consistency
- ๐ฏ MCP Primitives: Resources, tools, and prompts designed for agent workflows
๐ Quick Start
Installation
pip install uniprot-mcp
Run the Server
Local development (stdio):
uniprot-mcp
Remote deployment (HTTP):
uniprot-mcp-http --host 0.0.0.0 --port 8000
The HTTP server provides:
- MCP endpoint:
http://localhost:8000/mcp - Health check:
http://localhost:8000/healthz - Metrics:
http://localhost:8000/metrics(Prometheus format)
Test with MCP Inspector
npx @modelcontextprotocol/inspector uniprot-mcp
๐ MCP Primitives
Resources
Access static or dynamic data through URI patterns:
| URI | Description |
|---|---|
uniprot://uniprotkb/{accession} |
Raw UniProtKB entry JSON for any accession |
uniprot://help/search |
Documentation for search query syntax |
Tools
Execute actions and retrieve typed data:
| Tool | Parameters | Returns | Description |
|---|---|---|---|
fetch_entry |
accession, fields? |
Entry |
Fetch complete protein entry with all annotations |
get_sequence |
accession |
Sequence |
Get protein sequence with length and metadata |
search_uniprot |
query, size, reviewed_only, fields?, sort?, include_isoform |
SearchHit[] |
Full-text search with advanced filtering |
map_ids |
from_db, to_db, ids |
MappingResult |
Convert identifiers between 200+ databases |
fetch_entry_flatfile |
accession, version, format |
string |
Retrieve historical entry versions (txt/fasta) |
Progress tracking: map_ids reports progress (0.0 โ 1.0) for long-running jobs.
Prompts
Pre-built templates for common workflows:
- Summarize Protein: Generate a structured summary from a UniProt accession, including organism, function, GO terms, and notable features.
๐ง Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
UNIPROT_ENABLE_FIELDS |
unset | Request minimal field subsets to reduce payload size |
UNIPROT_LOG_LEVEL |
info |
Logging level: debug, info, warning, error |
UNIPROT_LOG_FORMAT |
plain |
Log format: plain or json |
UNIPROT_MAX_CONCURRENCY |
8 |
Max concurrent UniProt API requests |
MCP_HTTP_HOST |
0.0.0.0 |
HTTP server bind address |
MCP_HTTP_PORT |
8000 |
HTTP server port |
MCP_HTTP_LOG_LEVEL |
info |
Uvicorn log level |
MCP_HTTP_RELOAD |
0 |
Enable auto-reload: 1 or true |
MCP_CORS_ALLOW_ORIGINS |
* |
CORS allowed origins (comma-separated) |
MCP_CORS_ALLOW_METHODS |
GET,POST,DELETE |
CORS allowed methods |
MCP_CORS_ALLOW_HEADERS |
* |
CORS allowed headers |
CLI Flags
# HTTP server flags
uniprot-mcp-http --host 127.0.0.1 --port 9000 --log-level debug --reload
๐ Usage Examples
Fetching a Protein Entry
# Using MCP client
result = await session.call_tool("fetch_entry", {
"accession": "P12345"
})
# Returns structured Entry with:
# - primaryAccession, protein names, organism
# - sequence (length, mass, sequence string)
# - features (domains, modifications, variants)
# - GO annotations (biological process, molecular function, cellular component)
# - cross-references to other databases
Searching for Proteins
# Search reviewed human proteins
result = await session.call_tool("search_uniprot", {
"query": "kinase AND organism_id:9606",
"size": 50,
"reviewed_only": True,
"sort": "annotation_score"
})
# Returns list of SearchHit objects with accessions and scores
Mapping Identifiers
# Convert UniProt IDs to PDB structures
result = await session.call_tool("map_ids", {
"from_db": "UniProtKB_AC-ID",
"to_db": "PDB",
"ids": ["P12345", "Q9Y6K9"]
})
# Returns MappingResult with successful and failed mappings
๐ ๏ธ Development
Prerequisites
- Python 3.11 or 3.12
- uv (recommended) or pip
Setup
# Clone the repository
git clone https://github.com/josefdc/Uniprot-MCP.git
cd Uniprot-MCP
# Install dependencies
uv sync --group dev
# Install development tools
uv tool install ruff
uv tool install mypy
Running Tests
# Run all tests with coverage
uv run pytest --maxfail=1 --cov=uniprot_mcp --cov-report=term-missing
# Run specific test file
uv run pytest tests/unit/test_parsers.py -v
# Run integration tests only
uv run pytest tests/integration/ -v
Code Quality
# Lint
uv tool run ruff check .
# Format
uv tool run ruff format .
# Type check
uv tool run mypy src
# Run all checks
uv tool run ruff check . && \
uv tool run ruff format --check . && \
uv tool run mypy src && \
uv run pytest
Local Development Server
# Stdio server
uv run uniprot-mcp
# HTTP server with auto-reload
uv run python -m uvicorn uniprot_mcp.http_app:app --reload --host 127.0.0.1 --port 8000
๐๏ธ Architecture
src/uniprot_mcp/
โโโ adapters/ # UniProt REST API client and response parsers
โ โโโ uniprot_client.py # HTTP client with retry logic
โ โโโ parsers.py # Transform UniProt JSON โ Pydantic models
โโโ models/
โ โโโ domain.py # Typed data models (Entry, Sequence, etc.)
โโโ server.py # MCP stdio server (FastMCP)
โโโ http_app.py # MCP HTTP server (Starlette + CORS)
โโโ prompts.py # MCP prompt templates
โโโ obs.py # Observability (logging, metrics)
tests/
โโโ unit/ # Unit tests for parsers, models, tools
โโโ integration/ # End-to-end tests with VCR fixtures
โโโ fixtures/ # Test data (UniProt JSON responses)
๐ฆ Publishing
This server is published to:
- PyPI: uniprot-mcp
- MCP Registry: io.github.josefdc/uniprot-mcp
Building and Publishing
# Build distribution packages
uv build
# Publish to PyPI (requires token)
uv publish --token pypi-YOUR_TOKEN
# Publish to MCP Registry (requires GitHub auth)
mcp-publisher login github
mcp-publisher publish
See docs/registry.md for detailed registry publishing instructions.
๐ค Contributing
Contributions are welcome! Please:
- Read our Contributing Guidelines
- Follow our Code of Conduct
- Check the Security Policy for vulnerability reporting
- Review the Changelog for recent changes
Quick start for contributors:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with tests
- Run quality checks:
uv tool run ruff check . && uv tool run mypy src && uv run pytest - Commit using Conventional Commits (
feat:,fix:,docs:, etc.) - Push and open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- UniProt Consortium: For providing comprehensive, high-quality protein data through their REST API
- Anthropic: For the Model Context Protocol specification and Python SDK
- Community: For feedback, bug reports, and contributions
๐ Links
- Documentation: GitHub Repository
- UniProt API: REST API Documentation
- MCP Specification: Model Context Protocol
- Issues & Support: GitHub Issues
โ ๏ธ Disclaimer
This is an independent project and is not officially affiliated with or endorsed by the UniProt Consortium. Please review UniProt's terms of use when using their data.
Built with โค๏ธ for the bioinformatics and AI communities
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uniprot_mcp_fastmcp-0.1.1.tar.gz.
File metadata
- Download URL: uniprot_mcp_fastmcp-0.1.1.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81babb31655296c81e466d4b1398b0aea6dcd87fb269b1c57645f9adef3db0f0
|
|
| MD5 |
5d85095e952100bc2c7ffbc145557f5d
|
|
| BLAKE2b-256 |
59f52229223ea999f26cebc979166dd02074795011060cacde79422146f7a51a
|
File details
Details for the file uniprot_mcp_fastmcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: uniprot_mcp_fastmcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6dc01ad4d5b5a626756d59b05927fa76b376322d40308ba768ccbc06e372e87
|
|
| MD5 |
d09e3e9c0906f8da8b2eeba2b589a804
|
|
| BLAKE2b-256 |
d3906aecdbff7d3ff6058a8dfd4eac21e912c66092392cb303fa982431716985
|