loading…
Search for a command to run...
loading…
Enables integration between MCP-compatible clients and APIs registered in the SmartAPI registry, allowing seamless discovery and interaction with bioinformatics
Enables integration between MCP-compatible clients and APIs registered in the SmartAPI registry, allowing seamless discovery and interaction with bioinformatics and life sciences APIs through standardized MCP protocols.
Create MCP (Model Context Protocol) servers for one or multiple APIs registered in the SmartAPI registry.
Test PyPI version Python versions License
The SmartAPI MCP Server enables integration between MCP-compatible clients and APIs registered in the SmartAPI registry. This allows for seamless discovery and interaction with bioinformatics and life sciences APIs through standardized MCP protocols.
Built on top of the AWS Labs OpenAPI MCP Server, this project extends MCP support to the extensive collection of APIs available in the SmartAPI registry, with special focus on bioinformatics and life sciences APIs.
awslabs_openapi_mcp_server>=0.2.12pip install smartapi-mcp
git clone https://github.com/biothings/smartapi-mcp.git
cd smartapi-mcp
pip install -e .
git clone https://github.com/biothings/smartapi-mcp.git
cd smartapi-mcp
pip install -e ".[dev]"
uvx is a tool for running Python applications in isolated environments. This is the recommended way to run smartapi-mcp for MCP client integration:
# Install uvx if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# or with homebrew on macOS
brew install uv
# Run smartapi-mcp with uvx (automatically installs if needed)
uvx smartapi-mcp --api_set biothings_core
# Run with specific version
uvx [email protected] --api_set biothings_core
# Run with additional arguments
uvx smartapi-mcp --smartapi_id 59dce17363dce279d389100834e43648 --server_name "MyGene MCP Server"
To use smartapi-mcp with Claude Desktop, add the following configuration to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"smartapi-biothings-core": {
"command": "uvx",
"args": ["smartapi-mcp", "--api_set", "biothings_core", "--server_name", "BioThings Core APIs"]
},
"smartapi-mygene": {
"command": "uvx",
"args": ["smartapi-mcp", "--smartapi_id", "59dce17363dce279d389100834e43648", "--server_name", "MyGene.info API"]
},
"smartapi-myvariant": {
"command": "uvx",
"args": ["smartapi-mcp", "--smartapi_id", "09c8782d9f4027712e65b95424adba79", "--server_name", "MyVariant.info API"]
}
}
}
For other MCP clients that support external MCP servers, you can typically configure them by providing:
uvx["smartapi-mcp", "--api_set", "biothings_core"] (or other desired arguments){
"mcpServers": {
"biothings-core": {
"command": "uvx",
"args": ["smartapi-mcp", "--api_set", "biothings_core"],
"env": {
"LOG_LEVEL": "INFO"
}
}
}
}
{
"mcpServers": {
"biothings-comprehensive": {
"command": "uvx",
"args": [
"smartapi-mcp",
"--smartapi_ids",
"59dce17363dce279d389100834e43648,09c8782d9f4027712e65b95424adba79,8f08d1446e0bb9c2b323713ce83e2bd3",
"--server_name",
"Comprehensive Bioinformatics APIs",
"--log-level",
"DEBUG"
]
}
}
}
{
"mcpServers": {
"smartapi-dev": {
"command": "uvx",
"args": [
"smartapi-mcp",
"--api_set",
"biothings_test",
"--log-level",
"DEBUG"
],
"env": {
"SMARTAPI_LOG_LEVEL": "DEBUG"
}
}
}
}
You can also use environment variables in your MCP client configuration:
{
"mcpServers": {
"smartapi-configured": {
"command": "uvx",
"args": ["smartapi-mcp"],
"env": {
"SMARTAPI_API_SET": "biothings_core",
"SERVER_NAME": "BioThings Core MCP Server",
"LOG_LEVEL": "INFO"
}
}
}
}
If you prefer not to use uvx, you can create a dedicated virtual environment:
# Create and activate virtual environment
python -m venv smartapi-mcp-env
source smartapi-mcp-env/bin/activate # On Windows: smartapi-mcp-env\Scripts\activate
# Install smartapi-mcp
pip install smartapi-mcp
# Test the installation
smartapi-mcp --api_set biothings_core
Then configure your MCP client to use the full path to the executable:
{
"mcpServers": {
"smartapi-biothings": {
"command": "/path/to/smartapi-mcp-env/bin/smartapi-mcp",
"args": ["--api_set", "biothings_core"]
}
}
}
# Install globally (not recommended for most users)
pip install smartapi-mcp
# Find the installation path
which smartapi-mcp
MCP client configuration:
{
"mcpServers": {
"smartapi-biothings": {
"command": "smartapi-mcp",
"args": ["--api_set", "biothings_core"]
}
}
}
Check uvx installation:
uvx --version
Test server manually:
uvx smartapi-mcp --api_set biothings_core --log-level DEBUG
Check MCP client logs for specific error messages
Verify server is running with tools registered:
uvx smartapi-mcp --api_set biothings_core --log-level DEBUG 2>&1 | grep -i "tool"
Check API connectivity:
curl -s https://mygene.info/v3/metadata | head -20
Try a smaller API set first:
uvx smartapi-mcp --smartapi_id 59dce17363dce279d389100834e43648
{
"mcpServers": {
"smartapi-http": {
"command": "uvx",
"args": ["smartapi-mcp", "--api_set", "biothings_core", "--transport", "http", "--port", "8001"]
}
}
}
# Use BioThings core APIs (MyGene, MyVariant, MyChem, MyDisease, MyGeneSet)
smartapi-mcp --api_set biothings_core
# Use all BioThings APIs (with some exclusions)
smartapi-mcp --api_set biothings_all
# Single API
smartapi-mcp --smartapi_id 59dce17363dce279d389100834e43648
# Multiple APIs
smartapi-mcp --smartapi_ids "59dce17363dce279d389100834e43648,09c8782d9f4027712e65b95424adba79"
# HTTP mode on localhost:8000 (default)
smartapi-mcp --api_set biothings_core --transport http
# Custom host and port
smartapi-mcp --api_set biothings_core --transport http --host 0.0.0.0 --port 9000
# Custom logging level
smartapi-mcp --api_set biothings_core --log-level DEBUG
# Custom server name
smartapi-mcp --api_set biothings_core --server_name "My Custom MCP Server"
# Query-based API discovery
smartapi-mcp --smartapi_q "tags.name=biothings"
# Exclude specific APIs
smartapi-mcp --api_set biothings_all --smartapi_exclude_ids "api_id_1,api_id_2"
import asyncio
from smartapi_mcp import (
get_smartapi_ids,
load_api_spec,
get_mcp_server,
get_merged_mcp_server,
PREDEFINED_API_SETS
)
async def main():
# Get SmartAPI IDs using a query
smartapi_ids = await get_smartapi_ids("tags.name=biothings")
print(f"Found {len(smartapi_ids)} APIs matching the query")
# Load API specification for a specific SmartAPI
api_spec = load_api_spec("59dce17363dce279d389100834e43648") # MyGene.info
print(f"Loaded API: {api_spec.get('info', {}).get('title', 'Unknown')}")
# Create MCP server for a single API
server = await get_mcp_server(
smartapi_id="59dce17363dce279d389100834e43648",
server_name="MyGene MCP Server"
)
# Create merged MCP server for multiple APIs (recommended approach)
merged_server = await get_merged_mcp_server(
api_set="biothings_core", # Use predefined set
server_name="BioThings Core MCP Server"
)
# Or with specific SmartAPI IDs
merged_server = await get_merged_mcp_server(
smartapi_ids=[
"59dce17363dce279d389100834e43648", # MyGene.info
"09c8782d9f4027712e65b95424adba79", # MyVariant.info
],
server_name="Custom MCP Server"
)
# Show available predefined API sets
print(f"Available API sets: {PREDEFINED_API_SETS}")
# Run server with stdio transport (default for MCP)
merged_server.run()
# Or run with HTTP transport
# merged_server.run(transport="http", host="localhost", port=8000)
if __name__ == "__main__":
asyncio.run(main())
When you use --api_set biothings_core, you get access to these powerful bioinformatics APIs:
59dce17363dce279d389100834e43648): Gene annotation and information09c8782d9f4027712e65b95424adba79): Variant annotation and information8f08d1446e0bb9c2b323713ce83e2bd3): Chemical and drug information671b45c0301c8624abbd26ae78449ca2): Disease information and associations85139f4dccfcefa3ac3042372066916d): Collect, share and save genesOnce the server is running, MCP-compatible clients can discover and use the available tools. Each API endpoint becomes an available MCP tool with:
The server supports multiple configuration methods:
# SmartAPI configuration
export SMARTAPI_ID="59dce17363dce279d389100834e43648"
export SMARTAPI_IDS="id1,id2,id3"
export SMARTAPI_Q="tags.name=biothings"
export SMARTAPI_API_SET="biothings_core"
export SMARTAPI_EXCLUDE_IDS="exclude_id1,exclude_id2"
# Server configuration
export SERVER_NAME="My SmartAPI MCP Server"
export TRANSPORT="http"
export HOST="localhost"
export PORT="8000"
# Then run without arguments
smartapi-mcp
All configuration can be provided via command line arguments (see Quick Start section above).
The following predefined API sets are available:
biothings_core: Core BioThings APIs (MyGene, MyVariant, MyChem, MyDisease, MyGeneSet)biothings_test: Core APIs plus SemmedDB (useful for testing)biothings_all: All BioThings APIs (with some exclusions for stability)# Clone the repository
git clone https://github.com/biothings/smartapi-mcp.git
cd smartapi-mcp
# Install development dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run with coverage
pytest --cov=smartapi_mcp --cov-report=html
# Run specific test file
pytest tests/test_basic.py
# Check and fix linting issues
ruff check .
ruff check . --fix
# Format code
ruff format .
# Build source and wheel distributions
python -m build
# Check the built package
twine check dist/*
# Build the package
python -m build
# Upload to Test PyPI (optional)
twine upload --repository testpypi dist/*
# Upload to PyPI
twine upload dist/*
This repository includes GitHub Actions workflows for automated testing and publishing:
.github/workflows/test.yml): Runs on every push and pull request.github/workflows/publish.yml): Publishes to PyPI on releaseTo publish a new version:
pyproject.toml and smartapi_mcp/__init__.pygit tag v0.2.0 && git push origin v0.2.0You can also manually trigger the publish workflow to upload to Test PyPI:
We welcome contributions! Please see our contributing guidelines for details.
git checkout -b feature/amazing-feature)pytest)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)WARNING: No tools or resources were registered. This might indicate an issue with the API specification or authentication.
Solution: This usually happens when:
Try with a known working API set: smartapi-mcp --api_set biothings_core
Check your Python version: Requires Python 3.10+
python --version
Verify installation:
pip show smartapi-mcp
If using HTTP transport mode and clients can't connect:
netstat -an | grep :8000--host 0.0.0.0--log-level DEBUGThis project is licensed under the Apache License 2.0 - see the LICENSE file for details.
If you use SmartAPI MCP Server in your research or applications, please cite:
SmartAPI MCP Server: Bridging Bioinformatics APIs with Model Context Protocol
BioThings Team. (2024). https://github.com/biothings/smartapi-mcp
For questions and support:
SmartAPI MCP Server is developed and maintained by the BioThings Team at The Scripps Research Institute.
Выполни в терминале:
claude mcp add smartapi-mcp-server -- npx Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development