Documentation Index
Fetch the complete documentation index at: https://docs.scmcphub.org/llms.txt
Use this file to discover all available pages before exploring further.
BaseMCPManager Reference
TheBaseMCPManager is the foundational class for creating MCP (Model Context Protocol) servers in the scmcphub ecosystem. It provides a standardized way to manage and organize multiple MCP modules, with built-in filtering capabilities for both modules and tools.
Overview
BaseMCPManager serves as an abstract base class that handles:
- Module registration and management
- Tool filtering (include/exclude)
- Module filtering (include/exclude)
- Backend integration
- FastMCP lifecycle management
Class Definition
Constructor
__init__(name, instructions=None, include_modules=None, exclude_modules=None, include_tools=None, exclude_tools=None, include_tags=None, exclude_tags=None, backend=None)
Initializes a new BaseMCPManager instance.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | Required | Name of the MCP server |
instructions | Optional[str] | None | Instructions for the MCP server |
include_modules | Optional[List[str]] | None | List of module names to include. If None, all modules are included |
exclude_modules | Optional[List[str]] | None | List of module names to exclude. If None, no modules are excluded |
include_tools | Optional[List[str]] | None | Dictionary mapping module names to lists of tool names to include |
exclude_tools | Optional[List[str]] | None | Dictionary mapping module names to lists of tool names to exclude |
include_tags | Optional[List[str]] | None | List of tags to include |
exclude_tags | Optional[List[str]] | None | List of tags to exclude |
backend | Optional[NotebookManager] | None | Backend manager class (e.g., AdataManager, NotebookManager) |
Instance Attributes
| Attribute | Type | Description |
|---|---|---|
exec_backend | NotebookManager | Backend instance for execution |
mcp | FastMCP | The main FastMCP instance |
include_modules | Optional[List[str]] | Modules to include |
exclude_modules | Optional[List[str]] | Modules to exclude |
include_tools | Optional[List[str]] | Tools to include per module |
exclude_tools | Optional[List[str]] | Tools to exclude per module |
available_modules | Dict[str, Any] | Dictionary of available modules |
Methods
init_mcp()
Abstract method - Must be implemented by subclasses.
Initializes the available_modules dictionary with module instances.
register_mcp()
Registers modules based on include/exclude filters and imports them into the main MCP server.
exec_lifespan(server)
Async context manager that provides the execution backend during the server’s lifespan.
Usage Examples
Basic Implementation
With Module Filtering
With Tool Filtering
With Tag Filtering
Complete Example
Real-World Examples
ScanpyMCPManager
CellrankMCPManager
Best Practices
1. Module Naming Convention
Use consistent module names across your MCP server:io- Input/Output operationspp- Preprocessingtl- Toolspl- Plottingul- Utilitiesauto- Auto-completion toolsnb- Notebook integration
2. Backend Selection
Choose the appropriate backend based on your use case:AdataManager- For AnnData-based operations/tool-modeNotebookManager- For notebook-based execution/code-mode
3. Filtering Strategy
- Use
include_moduleswhen you want to limit to specific modules - Use
exclude_moduleswhen you want to exclude specific modules from a larger set - Use
include_toolsfor fine-grained control over which tools are available - Use
exclude_toolsto remove specific tools from modules