The runtime crate already had typed MCP config parsing, bootstrap metadata, and stdio JSON-RPC transport primitives, but it lacked the stateful layer that owns configured subprocesses and routes discovered tools back to the right server. This change adds a thin lazy McpServerManager in mcp_stdio, keeps unsupported transports explicit, and locks the behavior with subprocess-backed discovery, routing, reuse, shutdown, and error tests. Constraint: Keep the change narrow to the runtime crate and stdio transport only Constraint: Reuse existing MCP config/bootstrap/process helpers instead of adding new dependencies Rejected: Eagerly spawn all configured servers at construction | unnecessary startup cost and failure coupling Rejected: Spawn a fresh process per request | defeats lifecycle management and tool routing cache Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep higher-level runtime/session integration separate until a caller needs this manager surface Tested: cargo fmt --all; cargo clippy -p runtime --all-targets -- -D warnings; cargo test -p runtime Not-tested: Integration into conversation/runtime flows outside direct manager APIs
77 lines
3.2 KiB
Rust
77 lines
3.2 KiB
Rust
mod bash;
|
|
mod bootstrap;
|
|
mod compact;
|
|
mod config;
|
|
mod conversation;
|
|
mod file_ops;
|
|
mod json;
|
|
mod mcp;
|
|
mod mcp_client;
|
|
mod mcp_stdio;
|
|
mod oauth;
|
|
mod permissions;
|
|
mod prompt;
|
|
mod remote;
|
|
mod session;
|
|
mod usage;
|
|
|
|
pub use bash::{execute_bash, BashCommandInput, BashCommandOutput};
|
|
pub use bootstrap::{BootstrapPhase, BootstrapPlan};
|
|
pub use compact::{
|
|
compact_session, estimate_session_tokens, format_compact_summary,
|
|
get_compact_continuation_message, should_compact, CompactionConfig, CompactionResult,
|
|
};
|
|
pub use config::{
|
|
ConfigEntry, ConfigError, ConfigLoader, ConfigSource, McpClaudeAiProxyServerConfig,
|
|
McpConfigCollection, McpOAuthConfig, McpRemoteServerConfig, McpSdkServerConfig,
|
|
McpServerConfig, McpStdioServerConfig, McpTransport, McpWebSocketServerConfig, OAuthConfig,
|
|
RuntimeConfig, RuntimeFeatureConfig, ScopedMcpServerConfig, CLAUDE_CODE_SETTINGS_SCHEMA_NAME,
|
|
};
|
|
pub use conversation::{
|
|
ApiClient, ApiRequest, AssistantEvent, ConversationRuntime, RuntimeError, StaticToolExecutor,
|
|
ToolError, ToolExecutor, TurnSummary,
|
|
};
|
|
pub use file_ops::{
|
|
edit_file, glob_search, grep_search, read_file, write_file, EditFileOutput, GlobSearchOutput,
|
|
GrepSearchInput, GrepSearchOutput, ReadFileOutput, StructuredPatchHunk, TextFilePayload,
|
|
WriteFileOutput,
|
|
};
|
|
pub use mcp::{
|
|
mcp_server_signature, mcp_tool_name, mcp_tool_prefix, normalize_name_for_mcp,
|
|
scoped_mcp_config_hash, unwrap_ccr_proxy_url,
|
|
};
|
|
pub use mcp_client::{
|
|
McpClaudeAiProxyTransport, McpClientAuth, McpClientBootstrap, McpClientTransport,
|
|
McpRemoteTransport, McpSdkTransport, McpStdioTransport,
|
|
};
|
|
pub use mcp_stdio::{
|
|
spawn_mcp_stdio_process, JsonRpcError, JsonRpcId, JsonRpcRequest, JsonRpcResponse,
|
|
ManagedMcpTool, McpInitializeClientInfo, McpInitializeParams, McpInitializeResult,
|
|
McpInitializeServerInfo, McpListResourcesParams, McpListResourcesResult, McpListToolsParams,
|
|
McpListToolsResult, McpReadResourceParams, McpReadResourceResult, McpResource,
|
|
McpResourceContents, McpServerManager, McpServerManagerError, McpStdioProcess, McpTool,
|
|
McpToolCallContent, McpToolCallParams, McpToolCallResult, UnsupportedMcpServer,
|
|
};
|
|
pub use oauth::{
|
|
code_challenge_s256, generate_pkce_pair, generate_state, loopback_redirect_uri,
|
|
OAuthAuthorizationRequest, OAuthRefreshRequest, OAuthTokenExchangeRequest, OAuthTokenSet,
|
|
PkceChallengeMethod, PkceCodePair,
|
|
};
|
|
pub use permissions::{
|
|
PermissionMode, PermissionOutcome, PermissionPolicy, PermissionPromptDecision,
|
|
PermissionPrompter, PermissionRequest,
|
|
};
|
|
pub use prompt::{
|
|
load_system_prompt, prepend_bullets, ContextFile, ProjectContext, PromptBuildError,
|
|
SystemPromptBuilder, FRONTIER_MODEL_NAME, SYSTEM_PROMPT_DYNAMIC_BOUNDARY,
|
|
};
|
|
pub use remote::{
|
|
inherited_upstream_proxy_env, no_proxy_list, read_token, upstream_proxy_ws_url,
|
|
RemoteSessionContext, UpstreamProxyBootstrap, UpstreamProxyState, DEFAULT_REMOTE_BASE_URL,
|
|
DEFAULT_SESSION_TOKEN_PATH, DEFAULT_SYSTEM_CA_BUNDLE, NO_PROXY_HOSTS, UPSTREAM_PROXY_ENV_KEYS,
|
|
};
|
|
pub use session::{ContentBlock, ConversationMessage, MessageRole, Session, SessionError};
|
|
pub use usage::{
|
|
format_usd, pricing_for_model, ModelPricing, TokenUsage, UsageCostEstimate, UsageTracker,
|
|
};
|