Unofficial NCBI Datasets FastMCP Server
by MarcDasilva
README.md
# Unofficial NCBI Datasets FastMCP Server
A **FastMCP** (Python) MCP server that exposes the [NCBI Datasets v2 REST API](https://www.ncbi.nlm.nih.gov/datasets/docs/v2/) as tools and resources — genomes, genes, taxonomy, and assemblies. Suitable for local use (stdio) or hosted deployment (HTTP).
**This project is a modification and import of the previous TypeScript NCBI Datasets MCP server**, reimplemented in Python with FastMCP and the stable NCBI Datasets v2 API. Original implementation: [Augmented-Nature/NCBI-Datasets-MCP-Server](https://github.com/Augmented-Nature/NCBI-Datasets-MCP-Server) (developed by [Augmented Nature](https://augmentednature.ai)).
## Features
- **FastMCP 2.x** — Python MCP server with tools and URI resources
- **NCBI Datasets v2** — Uses the stable v2 API (not v2alpha)
- **Hostable** — Run over stdio (e.g. Claude Desktop) or HTTP for remote clients
- **Configurable** — Base URL, API key, and timeouts via environment variables
## Installation
```bash
cd /path/to/NCBI-Datasets-MCP-Server
pip install -e .
# or: pip install .
```
## Configuration
Copy `.env.example` to `.env` and set as needed:
| Variable | Description |
|----------------|-------------|
| `NCBI_API_KEY` | Optional. [NCBI API key](https://www.ncbi.nlm.nih.gov/account/settings/) for higher rate limits. |
| `NCBI_BASE_URL`| Optional. Default: `https://api.ncbi.nlm.nih.gov/datasets/v2` |
| `NCBI_TIMEOUT` | Optional. Request timeout in seconds (default: 30). |
| `MCP_TRANSPORT`| Set to `http` to run an HTTP server instead of stdio. |
| `MCP_HOST` | When using HTTP, bind address (default: `0.0.0.0`). |
| `MCP_PORT` | When using HTTP, port (default: `8000`). |
## Running the server
### Stdio (default) — for Cursor, Claude Desktop, or other MCP clients
```bash
ncbi-datasets-mcp
# or (from project dir after pip install -e .)
python -m unofficial_ncbi_mcp
```
Configure your MCP client to run this command; use optional `env.NCBI_API_KEY` for higher NCBI rate limits.
### HTTP — for remote hosting
```bash
MCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=8000 ncbi-datasets-mcp
```
Or with the FastMCP CLI (if you use `fastmcp run`):
```bash
fastmcp run src/ncbi_datasets_mcp/server.py:mcp --transport http --host 0.0.0.0 --port 8000
```
The MCP endpoint is at `http://<host>:<port>/mcp`. Point your MCP client at this URL when using HTTP transport.
## Tools
| Tool | Description |
|------|-------------|
| **Genomes** | |
| `search_genomes` | Search genome assemblies by taxonomy ID and filters (assembly level/source). |
| `get_genome_info` | Get detailed info for a genome assembly by accession. |
| `get_genome_summary` | Get summary statistics for a genome assembly. |
| `download_genome_data` | Get download URLs and metadata for genome data. |
| **Genes** | |
| `search_genes` | Search genes by symbol, organism, tax_id, or chromosome. |
| `get_gene_info` | Get gene details by Gene ID or symbol + organism. |
| `get_gene_sequences` | Get sequences for a gene (genomic/transcript/protein). |
| **Taxonomy** | |
| `search_taxonomy` | Search taxonomy by organism name or keywords. |
| `get_taxonomy_info` | Get taxon details by taxonomy ID. |
| `get_taxonomic_lineage` | Get full taxonomic lineage. |
| `get_organism_info` | Get organism info and available genome datasets. |
| **Assemblies** | |
| `search_assemblies` | Search assemblies by query/tax_id and filters. |
| `get_assembly_info` | Get assembly metadata and statistics. |
| `batch_assembly_info` | Get info for multiple assemblies (max 100). |
## Resources (URI templates)
| URI | Description |
|-----|-------------|
| `ncbi://genome/{accession}` | Genome assembly information. |
| `ncbi://gene/{gene_id}` | Gene information. |
| `ncbi://taxonomy/{tax_id}` | Taxonomic classification and lineage. |
| `ncbi://assembly/{assembly_accession}` | Assembly metadata and statistics. |
| `ncbi://search/genome/{query}` | Search genome assemblies by query. |
## Incorporate into your agent workflow
You don’t run the server yourself for normal agent use — your MCP client starts it when needed.
### Cursor
1. **Install once** (in this project):
`cd /path/to/NCBI-Datasets-MCP-Server && pip install -e .`
2. **Add to MCP config** — in Cursor: **Settings → MCP** (or edit `~/.cursor/mcp.json`):
```json
{
"mcpServers": {
"ncbi-datasets": {
"command": "ncbi-datasets-mcp",
"args": [],
"cwd": "/path/to/NCBI-Datasets-MCP-Server",
"env": { "NCBI_API_KEY": "your_key_here" }
}
}
}
```
3. **Restart Cursor** (or reload the window). Your agent can then use tools like `search_genomes`, `get_gene_info`, `search_taxonomy`, etc.
### Other MCP clients (Claude Desktop, etc.)
Use the same idea: add an MCP server entry that runs `ncbi-datasets-mcp` (or `python -m unofficial_ncbi_mcp` with `cwd` set). Optional: set `env.NCBI_API_KEY` for higher NCBI rate limits.
### HTTP (optional)
To run the server as a long-lived HTTP process (e.g. for remote clients):
`MCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=8000 ncbi-datasets-mcp`
Then point your client at `http://<host>:8000/mcp`.
## API rate limits
- **Without API key:** 3 requests per second (NCBI default).
- **With API key:** 10 requests per second (see [NCBI API key](https://www.ncbi.nlm.nih.gov/account/settings/)).
## Data sources
- [NCBI Datasets v2 REST API](https://www.ncbi.nlm.nih.gov/datasets/docs/v2/) — genomes, assemblies, genome reports
- NCBI Gene and Taxonomy services via the same Datasets API surface
## License
MIT — see [LICENSE](LICENSE).
## Hosting
Yes — the server can be hosted over HTTP.
**Option 1: Direct run (VPS, cloud VM, or local)**
```bash
MCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=8000 ncbi-datasets-mcp
```
MCP endpoint: `http://<your-host>:8000/mcp`. Point your MCP client at this URL.
**Option 2: Docker**
A `Dockerfile` is included. Build and run:
```bash
docker build -t ncbi-datasets-mcp .
docker run -p 8000:8000 -e NCBI_API_KEY=your_key ncbi-datasets-mcp
```
MCP endpoint: `http://localhost:8000/mcp` (or your server’s host/port). Optional: pass `NCBI_API_KEY` for higher NCBI rate limits.
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues