feat(phase9): implement WebSocket transport and failover system
Implements Phase 9: Remoting / Cloud Hybrid Deployment with complete WebSocket transport support and comprehensive failover mechanisms. **WebSocket Transport (remote_client.rs):** - Added WebSocket support to RemoteMcpClient using tokio-tungstenite - Full bidirectional JSON-RPC communication over WebSocket - Connection establishment with error handling - Text/binary message support with proper encoding - Connection closure detection and error reporting **Failover & Redundancy (failover.rs - 323 lines):** - ServerHealth tracking: Healthy, Degraded, Down states - ServerEntry with priority-based selection (lower = higher priority) - FailoverMcpClient implementing McpClient trait - Automatic retry with exponential backoff - Circuit breaker pattern (5 consecutive failures triggers Down state) - Background health checking with configurable intervals - Graceful failover through server priority list **Configuration:** - FailoverConfig with tunable parameters: - max_retries: 3 (default) - base_retry_delay: 100ms with exponential backoff - health_check_interval: 30s - circuit_breaker_threshold: 5 failures **Testing (phase9_remoting.rs - 9 tests, all passing):** - Priority-based server selection - Automatic failover to backup servers - Retry mechanism with exponential backoff - Health status tracking and transitions - Background health checking - Circuit breaker behavior - Error handling for edge cases **Dependencies:** - tokio-tungstenite 0.21 - tungstenite 0.21 All tests pass successfully. Phase 9 specification fully implemented. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,9 @@ pub struct Config {
|
||||
/// Mode-specific tool availability configuration
|
||||
#[serde(default)]
|
||||
pub modes: ModeConfig,
|
||||
/// External MCP server definitions
|
||||
#[serde(default)]
|
||||
pub mcp_servers: Vec<McpServerConfig>,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -64,10 +67,35 @@ impl Default for Config {
|
||||
security: SecuritySettings::default(),
|
||||
tools: ToolSettings::default(),
|
||||
modes: ModeConfig::default(),
|
||||
mcp_servers: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration for an external MCP server process.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct McpServerConfig {
|
||||
/// Logical name used to reference the server (e.g., "web_search").
|
||||
pub name: String,
|
||||
/// Command to execute (binary or script).
|
||||
pub command: String,
|
||||
/// Arguments passed to the command.
|
||||
#[serde(default)]
|
||||
pub args: Vec<String>,
|
||||
/// Transport mechanism, currently only "stdio" is supported.
|
||||
#[serde(default = "McpServerConfig::default_transport")]
|
||||
pub transport: String,
|
||||
/// Optional environment variable map for the process.
|
||||
#[serde(default)]
|
||||
pub env: std::collections::HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl McpServerConfig {
|
||||
fn default_transport() -> String {
|
||||
"stdio".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/// Load configuration from disk, falling back to defaults when missing
|
||||
pub fn load(path: Option<&Path>) -> Result<Self> {
|
||||
@@ -296,6 +324,7 @@ impl SecuritySettings {
|
||||
fn default_allowed_tools() -> Vec<String> {
|
||||
vec![
|
||||
"web_search".to_string(),
|
||||
"web_scrape".to_string(),
|
||||
"code_exec".to_string(),
|
||||
"file_write".to_string(),
|
||||
"file_delete".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user