BioMCP Architecture Diagrams¶
This page describes BioMCP's architecture, data flows, and workflows.
System Architecture Overview¶
BioMCP consists of three main layers:
Client Layer¶
- CLI Interface: Command-line tool for direct interaction
- Claude Desktop: AI assistant integration via MCP protocol
- Python SDK: Programmatic access for custom applications
- Custom MCP Clients: Any MCP-compatible client
BioMCP Core¶
- MCP Server: Handles protocol communication
- Request Router: Directs queries to appropriate handlers
- Cache Layer: Intelligent caching for API responses
- Domain Handlers: Specialized processors for each data type
- Articles Handler (PubMed/PubTator3)
- Trials Handler (ClinicalTrials.gov, NCI)
- Variants Handler (MyVariant.info)
- Genes Handler (MyGene.info)
External APIs¶
- PubMed/PubTator3: Biomedical literature
- ClinicalTrials.gov: US clinical trials registry
- NCI CTS API: National Cancer Institute trials
- MyVariant.info: Genetic variant annotations
- MyGene.info: Gene information
- cBioPortal: Cancer genomics data
- AlphaGenome: Variant effect predictions
Data Flow Architecture¶
- User Request: Query submitted via CLI, Claude, or SDK
- Cache Check: System checks for cached results
- API Request: If cache miss, fetch from external API
- Result Processing: Normalize and enrich data
- Cache Storage: Store results for future use
- Response Delivery: Return formatted results to user
Key Workflows¶
Search Workflow¶
- Think Tool: Plan search strategy
- Execute Search: Query relevant data sources
- Enrich Results: Add contextual information
- Combine Data: Merge results from multiple sources
- Format Output: Present in user-friendly format
Article Search Pipeline¶
- Query Processing: Parse user input
- Entity Recognition: Normalize gene/disease names
- PubTator3 Search: Query literature database
- Preprint Integration: Include bioRxiv/medRxiv if enabled
- cBioPortal Enrichment: Add cancer genomics data for genes
- Result Merging: Combine all data sources
Clinical Trial Matching¶
- Patient Profile: Parse eligibility criteria
- Location Filter: Geographic constraints
- Molecular Profile: Mutation requirements
- Prior Treatments: Treatment history matching
- Scoring Algorithm: Rank trials by relevance
- Contact Extraction: Retrieve site information
Variant Interpretation¶
- Input Parsing: Process VCF/MAF files
- Batch Processing: Group variants efficiently
- Annotation Gathering:
- Clinical significance from MyVariant.info
- Population frequency data
- In silico predictions
- Literature evidence
- Clinical trial associations
- AlphaGenome Integration: Regulatory predictions (optional)
- Tier Classification: Categorize by clinical relevance
- Report Generation: Create interpretation summary
Architecture Patterns¶
Caching Strategy¶
- Multi-tier Cache: Memory → Disk → External
- Smart TTL: Domain-specific expiration times
- Cache Key Generation: Include all query parameters
- Invalidation Logic: Clear on errors or updates
Error Handling¶
- Retry Logic: Exponential backoff for transient errors
- Rate Limiting: Respect API limits with queuing
- Graceful Degradation: Return partial results when possible
- Clear Error Messages: Help users troubleshoot issues
Authentication Flow¶
- Check for user-provided API key
- Fall back to environment variable
- Use public access if no key available
- Handle authentication errors gracefully
Performance Optimization¶
- Request Batching: Combine multiple queries
- Parallel Execution: Concurrent API calls
- Connection Pooling: Reuse HTTP connections
- Result Streaming: Return data as available
Deployment Options¶
Local Development¶
- Single process with in-memory cache
- Direct file system access
- Simple configuration
Docker Deployment¶
- Containerized application
- Volume-mounted cache
- Environment-based configuration
Cloud Deployment¶
- Load-balanced instances
- Shared Redis cache
- Auto-scaling capabilities
- Monitoring integration
Creating Documentation Diagrams¶
For visual diagrams, we recommend:
-
ASCII Art: Universal compatibility
-
Use tools like asciiflow.com
-
Store in
docs/assets/
directory -
Screenshots: For complex UIs
-
Annotate with arrows/labels
-
Save as PNG in
docs/assets/
-
External Tools:
- draw.io for flowcharts
- Lucidchart for professional diagrams
- Export as static images
ASCII System Architecture¶
┌─────────────────────────────────────────────────────────────────────────┐
│ USER INTERFACES │
├────────────────┬───────────────────┬───────────────┬───────────────────┤
│ │ │ │ │
│ CLI Tool │ Claude Desktop │ Python SDK │ Custom Client │
│ (biomcp) │ (MCP Client) │ (async) │ (your app) │
│ │ │ │ │
└────────┬───────┴─────────┬─────────┴───────┬───────┴───────────┬───────┘
│ │ │ │
└─────────────────┴─────────────────┴───────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ BioMCP CORE SERVER │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │
│ │ Router │ │ Rate Limiter │ │ Cache Manager│ │ Logger │ │
│ │ │ │ │ │ │ │ │ │
│ └──────┬──────┘ └──────────────┘ └──────────────┘ └────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Domain Handlers │ │
│ ├─────────────┬─────────────┬─────────────┬──────────────────────┤ │
│ │ Articles │ Trials │ Variants │ Genes/Drugs/Disease │ │
│ │ Handler │ Handler │ Handler │ Handler │ │
│ └──────┬──────┴──────┬──────┴──────┬──────┴──────────┬───────────┘ │
│ │ │ │ │ │
└─────────┼─────────────┼─────────────┼─────────────────┼─────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────┐
│ EXTERNAL DATA SOURCES │
├─────────────┬─────────────┬─────────────┬──────────────────────────────┤
│ │ │ │ │
│ PubMed/ │ Clinical │ MyVariant │ BioThings Suite │
│ PubTator3 │ Trials.gov │ .info │ (MyGene/MyDisease/MyChem) │
│ │ + NCI │ │ │
│ │ │ │ │
├─────────────┴─────────────┴─────────────┴──────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ cBioPortal │ │ AlphaGenome │ │ Europe PMC │ │
│ │ (Cancer) │ │ (Predictions)│ │ (Preprints) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
See also: Quick Architecture Reference
Next Steps¶
- View the Quick Architecture Guide for a concise overview
- Check Developer Guides for implementation details
- See API Reference for detailed specifications