MCP Integration
BioCortex supports the Model Context Protocol (MCP) — an open standard for connecting AI agents to external tool servers. Any MCP-compatible server (local or remote) can extend BioCortex’s tool set without modifying the core framework.Architecture
Components
| Component | File | Responsibility |
|---|---|---|
MCPManager | biocortex/mcp/manager.py | Start/stop/restart MCP servers. Mount them to the gateway. |
UnifiedMCPGateway | biocortex/mcp/gateway.py | Single FastMCP HTTP server; each MCP server is mounted with a namespace prefix. |
MCPProvider | biocortex/mcp/provider.py | Agent-side client. Lists tools (with TTL cache) and calls them. |
MCPServerConfig | biocortex/mcp/config.py | Config data structures and mcp.json loading with hierarchical merging. |
Configuration
Create anmcp.json in .biocortex/ inside your project directory, or ~/.biocortex/mcp.json for global settings.
Config priority (highest → lowest):~/.biocortex/mcp.json → .biocortex/mcp.json (project) → package defaults
Full Schema
| Field | Default | Description |
|---|---|---|
host | 127.0.0.1 | Gateway bind address. |
port | 3100 | Gateway HTTP port (auto-increments if occupied). |
cache_ttl | 60 | Seconds to cache the tool list before re-querying. |
auto_start | [] | Server names to start automatically when BioCortex launches. |
servers | {} | Map of server name → config (see below). |
| Field | Description |
|---|---|
type | stdio (local subprocess) or http (remote endpoint). |
command | (stdio only) Shell command to launch the server. |
uri | (http only) Full URL of the MCP endpoint. |
env | (stdio only) Extra environment variables for the subprocess. |
description | Optional human-readable description. |
Server Types
STDIO Servers
BioCortex spawns and manages the subprocess. Logs are written to~/.biocortex/logs/mcp/<name>.log.
- Starting the process before the first tool call
- Pre-warming the connection (reduces first-call latency)
- Restarting on crash
- Graceful shutdown when BioCortex exits
HTTP Servers
BioCortex connects to an already-running HTTP endpoint. No process management.Pre-configured Servers
The following servers ship in BioCortex’s default config. None areauto_start by default; enable them individually.
| Name | Install | Tools |
|---|---|---|
biomcp | pip install biomcp-python | Gene/protein/variant/clinical trial search (NCBI, ClinVar, ClinicalTrials.gov) |
context7 | npm i -g @upstash/context7-mcp | Library/API documentation search |
filesystem | npm i -g @modelcontextprotocol/server-filesystem | Local file read/write/list |
pubmed | pip install mcp-server-pubmed | PubMed article search |
Managing MCP Servers from the CLI
All MCP operations are available via the/mcp slash command inside biocortex cli:
Tool Namespacing
When a server namedbiomcp is mounted, all its tools are prefixed with biomcp_:
| Server tool name | Exposed as |
|---|---|
search_genes | biomcp_search_genes |
search_variants | biomcp_search_variants |
Agent Integration
When MCP servers are running, their tools are automatically included in the agent’s LLM prompt as structured tool documentation:Python API
Logging
Per-server STDIO logs are written to~/.biocortex/logs/mcp/<name>.log. This makes it easy to debug individual servers without polluting the main BioCortex output.
Installing the MCP Dependency
MCP support requires thefastmcp package:
requirements.txt and pyproject.toml and is installed automatically with pip install -e ..
Next Steps
- CLI Reference —
/mcpcommands and slash commands overview. - Adding Tools and Agents — Building BioCortex-native tools.
- Configuration — Full environment variable reference.