MCP server
MCP server development guide for scmcphub
The basic development way to create a mcp server is using mcp/fastmcp
you can refer to their documentation for detailed guide. Here we just introduce the API in scmcphub, which is designed to reuse existing tools and further reduce the difficulty of MCP development.
BaseMCPManager
The BaseMCPManager
is the core class for creating MCP servers in scmcphub. It provides a standardized way to manage multiple MCP modules with built-in filtering capabilities.
For a complete reference documentation, see BaseMCPManager Reference.
Key Features
- Module Management: Automatically handles module registration and organization
- Filtering: Built-in support for including/excluding modules and tools
- Backend Integration: Seamless integration with different backend managers
- Tag-based Filtering: Support for filtering tools based on tags
- Async Support: Proper async/await handling for server lifespan
Basic Usage
For detailed usage examples, best practices, and troubleshooting, see the complete BaseMCPManager reference.
Backend Access Functions
The get_ads
and get_nbm
functions are essential for accessing backend managers within MCP tools. These functions provide access to the appropriate backend based on the execution mode.
For complete documentation, see Backend Functions Reference.
Quick Overview
get_ads()
- Tool Mode Backend
- Purpose: Access
AdataManager
for AnnData operations - Mode: Tool Mode (
tool-mode
) - Returns:
AdataManager
instance
get_nbm()
- Code Mode Backend
- Purpose: Access
NotebookManager
for Jupyter notebook operations - Mode: Code Mode (
code-mode
) - Returns:
NotebookManager
instance
Usage Examples
Tool Mode Example
Code Mode Example
Backend Selection
The choice between get_ads
and get_nbm
depends on your server configuration:
- AdataManager Backend: Use
get_ads()
for tool-mode - NotebookManager Backend: Use
get_nbm()
for code-mode
For detailed information about backend managers, context system, error handling, and best practices, see the complete Backend Functions reference.
AdataManager
The AdataManager
is the primary backend manager for handling AnnData objects in tool mode. It provides centralized management of multiple AnnData objects with different data types and sample IDs.
For complete documentation, see AdataManager Reference.
Quick Overview
Key Features
- Multi-type Support: Manages different types of AnnData (exp, activity, cnv, splicing)
- Sample ID Management: Tracks and organizes data by sample identifiers
- Active Sample Tracking: Maintains the currently active sample for operations
- Data Consistency: Ensures proper data access and storage patterns
Basic Usage
Data Types
The AdataManager supports these default data types:
- exp: Expression data (default)
- activity: Activity scores from pathway analysis
- cnv: Copy number variation data
- splicing: Alternative splicing data
You can also add custom data types during initialization:
For detailed information about methods, data structures, best practices, and troubleshooting, see the complete AdataManager reference.
NotebookManager
The NotebookManager
is the primary backend manager for handling Jupyter notebooks in code mode. It provides centralized management of multiple notebook instances with different kernels, making it essential for interactive analysis workflows.
For complete documentation, see NotebookManager Reference.
Quick Overview
Key Features
- Multiple Notebook Support: Manages multiple Jupyter notebook instances simultaneously
- Kernel Management: Handles different Jupyter kernels (Python, R, etc.)
- Active Notebook Tracking: Maintains the currently active notebook for operations
- Code Execution: Provides a unified interface for code execution across notebooks
- Notebook Lifecycle: Manages creation, deletion, and switching between notebooks
Basic Usage
Multi-Kernel Support
The NotebookManager supports various Jupyter kernels:
Integration with MCP Tools
For detailed information about methods, JupyterClientExecutor integration, best practices, and troubleshooting, see the complete NotebookManager reference.