MCP Main Module¶
Entry point and CLI for the MCP server application.
Overview¶
The MCP main module provides the command-line interface and entry point for running the Shannot MCP server. It handles argument parsing, executor initialization, and server lifecycle management.
Key Components:
entrypoint()- Main entry point forshannot-mcpcommandparse_args()- Command-line argument parser- Server initialization - Sets up executor and server based on arguments
- Logging configuration - Configures logging for debugging
Command-Line Interface¶
Basic Usage¶
# Start MCP server with default settings
shannot-mcp
# Use specific profile
shannot-mcp --profile diagnostics
# Use multiple profiles
shannot-mcp --profile minimal --profile diagnostics
# Enable verbose logging
shannot-mcp --verbose
# Use remote executor target
shannot-mcp --target production
Command-Line Options¶
Options:
--profile PATH, -p Profile to use (can be specified multiple times)
--target NAME, -t Remote executor target from config
--verbose, -v Enable verbose logging
--help, -h Show help message
Usage Patterns¶
Local Execution¶
The server will: 1. Create a LocalExecutor 2. Load the diagnostics profile 3. Start listening on stdio for MCP requests
Remote Execution¶
# Execute on remote system configured as "production"
shannot-mcp --target production --profile diagnostics
The server will:
1. Load configuration from ~/.config/shannot/config.toml
2. Create SSHExecutor for "production" target
3. Connect to remote system
4. Execute commands remotely in sandbox
Multiple Profiles¶
Each profile is available as a separate MCP resource and can be used by the LLM client.
Debugging¶
# Enable verbose logging for troubleshooting
shannot-mcp --verbose --profile diagnostics 2> /tmp/shannot-mcp.log
Logs will show: - Profile loading - Executor initialization - Tool invocations - Command executions - Errors and warnings
Integration with LLM Clients¶
Claude Desktop Integration¶
Add to claude_desktop_config.json:
Or use the installer:
Claude Code Integration¶
Add to Claude Code config:
{
"mcpServers": {
"shannot": {
"command": "shannot-mcp",
"args": ["--profile", "diagnostics", "--verbose"]
}
}
}
Or use the installer:
Remote System Monitoring¶
Monitor production systems from Claude:
{
"mcpServers": {
"shannot-prod": {
"command": "shannot-mcp",
"args": ["--target", "production", "--profile", "diagnostics"]
},
"shannot-staging": {
"command": "shannot-mcp",
"args": ["--target", "staging", "--profile", "diagnostics"]
}
}
}
Now Claude can run diagnostics on both production and staging.
Server Lifecycle¶
The MCP server runs until: - The LLM client disconnects - SIGINT (Ctrl+C) is received - An unrecoverable error occurs
On shutdown: - Executor connections are closed - Resources are cleaned up - Exit code 0 indicates clean shutdown
Error Handling¶
Common errors and solutions:
Profile not found:
→ Ensure profile exists at~/.config/shannot/custom.json or specify full path
Target not found:
→ Add target to~/.config/shannot/config.toml
Bubblewrap not found:
→ Install bubblewrap:apt install bubblewrap (Linux only)
SSH connection failed:
→ Check SSH configuration, keys, and network connectivityRelated Documentation¶
- MCP Server Module - Server implementation details
- MCP Integration Guide - Complete MCP setup guide
- Configuration - Configuring remote targets
- Troubleshooting - Common issues and solutions
API Reference¶
mcp_main
¶
Entry point for Shannot MCP server.
This module provides the main entry point for running the MCP server. It can be invoked via: - python -m shannot.mcp_main - shannot-mcp (if installed as separate package)
Classes¶
Functions¶
setup_logging(verbose=False)
¶
Configure logging for the MCP server.
Source code in shannot/mcp_main.py
main(argv=None)
async
¶
Main entry point for MCP server.