feat: migrate JsonRpcMessage/Request/Response/Error/Notification from internal mcp crates to rmcp versions (#3564)

This commit is contained in:
Alex Hancock
2025-07-22 13:45:00 -04:00
committed by GitHub
parent 246ba19256
commit 3e5c9b8505
27 changed files with 256 additions and 246 deletions
@@ -7,10 +7,11 @@ use crate::agents::subagent_execution_tool::task_execution_tracker::{
use crate::agents::subagent_execution_tool::tasks::process_task;
use crate::agents::subagent_execution_tool::workers::spawn_worker;
use crate::agents::subagent_task_config::TaskConfig;
use mcp_core::protocol::JsonRpcMessage;
use rmcp::model::JsonRpcMessage;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
use tokio::sync::mpsc;
use tokio::sync::mpsc::Sender;
use tokio::time::Instant;
const EXECUTION_STATUS_COMPLETED: &str = "completed";
@@ -46,7 +47,7 @@ pub async fn execute_single_task(
pub async fn execute_tasks_in_parallel(
tasks: Vec<Task>,
notifier: mpsc::Sender<JsonRpcMessage>,
notifier: Sender<JsonRpcMessage>,
task_config: TaskConfig,
) -> ExecutionResponse {
let task_execution_tracker = Arc::new(TaskExecutionTracker::new(
@@ -6,14 +6,14 @@ use crate::agents::subagent_execution_tool::{
tasks_manager::TasksManager,
};
use crate::agents::subagent_task_config::TaskConfig;
use mcp_core::protocol::JsonRpcMessage;
use rmcp::model::JsonRpcMessage;
use serde_json::{json, Value};
use tokio::sync::mpsc;
use tokio::sync::mpsc::Sender;
pub async fn execute_tasks(
input: Value,
execution_mode: ExecutionMode,
notifier: mpsc::Sender<JsonRpcMessage>,
notifier: Sender<JsonRpcMessage>,
task_config: TaskConfig,
tasks_manager: &TasksManager,
) -> Result<Value, String> {
@@ -8,7 +8,7 @@ use crate::agents::{
subagent_execution_tool::task_types::ExecutionMode,
subagent_execution_tool::tasks_manager::TasksManager, tool_execution::ToolCallResult,
};
use mcp_core::protocol::JsonRpcMessage;
use rmcp::model::JsonRpcMessage;
use tokio::sync::mpsc;
use tokio_stream;
@@ -1,5 +1,5 @@
use mcp_core::protocol::{JsonRpcMessage, JsonRpcNotification};
use serde_json::json;
use rmcp::model::{JsonRpcMessage, JsonRpcNotification, JsonRpcVersion2_0, Notification};
use rmcp::object;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::{mpsc, RwLock};
@@ -12,6 +12,7 @@ use crate::agents::subagent_execution_tool::notification_events::{
use crate::agents::subagent_execution_tool::task_types::{Task, TaskInfo, TaskResult, TaskStatus};
use crate::agents::subagent_execution_tool::utils::{count_by_status, get_task_name};
use serde_json::Value;
use tokio::sync::mpsc::Sender;
#[derive(Debug, Clone, PartialEq)]
pub enum DisplayMode {
@@ -67,7 +68,7 @@ impl TaskExecutionTracker {
pub fn new(
tasks: Vec<Task>,
display_mode: DisplayMode,
notifier: mpsc::Sender<JsonRpcMessage>,
notifier: Sender<JsonRpcMessage>,
) -> Self {
let task_map = tasks
.into_iter()
@@ -155,11 +156,14 @@ impl TaskExecutionTracker {
if let Err(e) =
self.notifier
.try_send(JsonRpcMessage::Notification(JsonRpcNotification {
jsonrpc: "2.0".to_string(),
method: "notifications/message".to_string(),
params: Some(json!({
"data": event.to_notification_data()
})),
jsonrpc: JsonRpcVersion2_0,
notification: Notification {
method: "notifications/message".to_string(),
params: object!({
"data": event.to_notification_data()
}),
extensions: Default::default(),
},
}))
{
tracing::warn!("Failed to send live output notification: {}", e);
@@ -228,11 +232,14 @@ impl TaskExecutionTracker {
if let Err(e) = self
.notifier
.try_send(JsonRpcMessage::Notification(JsonRpcNotification {
jsonrpc: "2.0".to_string(),
method: "notifications/message".to_string(),
params: Some(json!({
"data": event.to_notification_data()
})),
jsonrpc: JsonRpcVersion2_0,
notification: Notification {
method: "notifications/message".to_string(),
params: object!({
"data": event.to_notification_data()
}),
extensions: Default::default(),
},
}))
{
tracing::warn!("Failed to send tasks update notification: {}", e);
@@ -289,11 +296,14 @@ impl TaskExecutionTracker {
if let Err(e) = self
.notifier
.try_send(JsonRpcMessage::Notification(JsonRpcNotification {
jsonrpc: "2.0".to_string(),
method: "notifications/message".to_string(),
params: Some(json!({
"data": event.to_notification_data()
})),
jsonrpc: JsonRpcVersion2_0,
notification: Notification {
method: "notifications/message".to_string(),
params: object!({
"data": event.to_notification_data()
}),
extensions: Default::default(),
},
}))
{
tracing::warn!("Failed to send tasks complete notification: {}", e);