Skip to content

Commit 1813bb7

Browse files
authored
chore(mcp): migrate to rmcp (#2700)
* client struct definition * clean up unused code * adds mechanism for checking if server is alive * prefetches prompts if applicable * fixes agent swap fixes agent swap * only applies process group leader promo for unix * removes unused import for windows * renames abstractions for different stages of mcp config
1 parent f1a7664 commit 1813bb7

38 files changed

+890
-3344
lines changed

Cargo.lock

Lines changed: 92 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ winnow = "=0.6.2"
129129
winreg = "0.55.0"
130130
schemars = "1.0.4"
131131
jsonschema = "0.30.0"
132+
rmcp = { version = "0.6.0", features = ["client", "transport-child-process"] }
132133

133134
[workspace.lints.rust]
134135
future_incompatible = "warn"

crates/chat-cli/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ workspace = true
1515
default = []
1616
wayland = ["arboard/wayland-data-control"]
1717

18-
[[bin]]
19-
name = "test_mcp_server"
20-
path = "test_mcp_server/test_server.rs"
21-
test = true
22-
doc = false
23-
2418
[dependencies]
2519
amzn-codewhisperer-client.workspace = true
2620
amzn-codewhisperer-streaming-client.workspace = true
@@ -123,6 +117,7 @@ whoami.workspace = true
123117
winnow.workspace = true
124118
schemars.workspace = true
125119
jsonschema.workspace = true
120+
rmcp.workspace = true
126121

127122
[target.'cfg(unix)'.dependencies]
128123
nix.workspace = true

crates/chat-cli/src/cli/chat/cli/clear.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::cli::chat::{
1717

1818
#[deny(missing_docs)]
1919
#[derive(Debug, PartialEq, Args)]
20+
/// Arguments for the clear command that erases conversation history and context.
2021
pub struct ClearArgs;
2122

2223
impl ClearArgs {

crates/chat-cli/src/cli/chat/cli/compact.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ How it works
3131
Compaction will be automatically performed whenever the context window overflows.
3232
To disable this behavior, run: `q settings chat.disableAutoCompaction true`"
3333
)]
34+
/// Arguments for the `/compact` command that summarizes conversation history to free up context
35+
/// space.
36+
///
37+
/// This command creates an AI-generated summary of the conversation while preserving essential
38+
/// information, code, and tool executions. It's useful for long-running conversations that
39+
/// may reach memory constraints.
3440
pub struct CompactArgs {
3541
/// The prompt to use when generating the summary
3642
prompt: Vec<String>,

crates/chat-cli/src/cli/chat/cli/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Notes:
3838
• Agent rules apply only to the current agent
3939
• Context changes are NOT preserved between chat sessions. To make these changes permanent, edit the agent config file."
4040
)]
41+
/// Subcommands for managing context rules and files in Amazon Q chat sessions
4142
pub enum ContextSubcommand {
4243
/// Display the context rule configuration and matched files
4344
Show {
@@ -52,17 +53,20 @@ pub enum ContextSubcommand {
5253
#[arg(short, long)]
5354
force: bool,
5455
#[arg(required = true)]
56+
/// Paths or glob patterns to remove from context rules
5557
paths: Vec<String>,
5658
},
5759
/// Remove specified rules
5860
#[command(alias = "rm")]
5961
Remove {
62+
/// Paths or glob patterns to remove from context rules
6063
#[arg(required = true)]
6164
paths: Vec<String>,
6265
},
6366
/// Remove all rules
6467
Clear,
6568
#[command(hide = true)]
69+
/// Display information about agent format hooks (deprecated)
6670
Hooks,
6771
}
6872

crates/chat-cli/src/cli/chat/cli/editor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use crate::cli::chat::{
1515

1616
#[deny(missing_docs)]
1717
#[derive(Debug, PartialEq, Args)]
18+
/// Command-line arguments for the editor functionality
1819
pub struct EditorArgs {
20+
/// Initial text to populate in the editor
1921
pub initial_text: Vec<String>,
2022
}
2123

crates/chat-cli/src/cli/chat/cli/hooks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ Notes:
286286
• 'conversation_start' hooks run on the first user prompt and are attached once to the conversation history sent to Amazon Q
287287
• 'per_prompt' hooks run on each user prompt and are attached to the prompt, but are not stored in conversation history"
288288
)]
289+
/// Arguments for the hooks command that displays configured context hooks
289290
pub struct HooksArgs;
290291

291292
impl HooksArgs {

crates/chat-cli/src/cli/chat/cli/mcp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ use crate::cli::chat::{
1414
ChatState,
1515
};
1616

17+
/// Arguments for the MCP (Model Context Protocol) command.
18+
///
19+
/// This struct handles MCP-related functionality, allowing users to view
20+
/// the status of MCP servers and their loading progress.
1721
#[deny(missing_docs)]
1822
#[derive(Debug, PartialEq, Args)]
1923
pub struct McpArgs;

crates/chat-cli/src/cli/chat/cli/model.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ impl ModelInfo {
6060
self.model_name.as_deref().unwrap_or(&self.model_id)
6161
}
6262
}
63+
64+
/// Command-line arguments for model selection operations
6365
#[deny(missing_docs)]
6466
#[derive(Debug, PartialEq, Args)]
6567
pub struct ModelArgs;
66-
6768
impl ModelArgs {
6869
pub async fn execute(self, os: &Os, session: &mut ChatSession) -> Result<ChatState, ChatError> {
6970
Ok(select_model(os, session).await?.unwrap_or(ChatState::PromptUser {

0 commit comments

Comments
 (0)