Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions crates/goose-cli/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ use goose::providers::pricing::initialize_pricing_cache;
use goose::session;
use input::InputResult;
use mcp_core::handler::ToolError;
use mcp_core::protocol::JsonRpcMessage;
use mcp_core::protocol::JsonRpcNotification;
use rmcp::model::PromptMessage;
use rmcp::model::{JsonRpcMessage, JsonRpcNotification, Notification, PromptMessage};

use rand::{distributions::Alphanumeric, Rng};
use rustyline::EditMode;
Expand Down Expand Up @@ -1024,10 +1022,11 @@ impl Session {
}
}
Some(Ok(AgentEvent::McpNotification((_id, message)))) => {
if let JsonRpcMessage::Notification(JsonRpcNotification{
method,
params: Some(Value::Object(o)),
..
if let JsonRpcMessage::Notification( JsonRpcNotification {
notification: Notification {
method,
params: o,..
},..
}) = message {
match method.as_str() {
"notifications/message" => {
Expand Down
4 changes: 2 additions & 2 deletions crates/goose-mcp/src/computercontroller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use std::os::unix::fs::PermissionsExt;

use mcp_core::{
handler::{PromptError, ResourceError, ToolError},
protocol::{JsonRpcMessage, ServerCapabilities},
protocol::ServerCapabilities,
tool::{Tool, ToolAnnotations},
};
use mcp_server::router::CapabilitiesBuilder;
use mcp_server::Router;
use rmcp::model::{AnnotateAble, Content, Prompt, RawResource, Resource};
use rmcp::model::{AnnotateAble, Content, JsonRpcMessage, Prompt, RawResource, Resource};

mod docx_tool;
mod pdf_tool;
Expand Down
55 changes: 32 additions & 23 deletions crates/goose-mcp/src/developer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ use tokio::{
use url::Url;

use include_dir::{include_dir, Dir};
use mcp_core::tool::ToolAnnotations;
use mcp_core::{
handler::{PromptError, ResourceError, ToolError},
protocol::{JsonRpcMessage, JsonRpcNotification, ServerCapabilities},
tool::Tool,
protocol::ServerCapabilities,
tool::{Tool, ToolAnnotations},
};

use mcp_server::router::CapabilitiesBuilder;
use mcp_server::Router;
use rmcp::model::{Content, Prompt, PromptArgument, PromptTemplate, Resource};

use rmcp::model::Role;
use rmcp::model::{
Content, JsonRpcMessage, JsonRpcNotification, JsonRpcVersion2_0, Notification, Prompt,
PromptArgument, PromptTemplate, Resource, Role,
};
use rmcp::object;

use self::editor_models::{create_editor_model, EditorModel};
use self::shell::{expand_path, get_shell_config, is_absolute_path, normalize_line_endings};
Expand Down Expand Up @@ -671,15 +674,18 @@ impl DeveloperRouter {
let line = String::from_utf8_lossy(&stdout_buf);

notifier.try_send(JsonRpcMessage::Notification(JsonRpcNotification {
jsonrpc: "2.0".to_string(),
method: "notifications/message".to_string(),
params: Some(json!({
"data": {
"type": "shell",
"stream": "stdout",
"output": line.to_string(),
}
})),
jsonrpc: JsonRpcVersion2_0,
notification: Notification {
method: "notifications/message".to_string(),
params: object!({
"data": {
"type": "shell",
"stream": "stdout",
"output": line.to_string(),
}
}),
extensions: Default::default(),
}
})).ok();

combined_output.push_str(&line);
Expand All @@ -694,15 +700,18 @@ impl DeveloperRouter {
let line = String::from_utf8_lossy(&stderr_buf);

notifier.try_send(JsonRpcMessage::Notification(JsonRpcNotification {
jsonrpc: "2.0".to_string(),
method: "notifications/message".to_string(),
params: Some(json!({
"data": {
"type": "shell",
"stream": "stderr",
"output": line.to_string(),
}
})),
jsonrpc: JsonRpcVersion2_0,
notification: Notification {
method: "notifications/message".to_string(),
params: object!({
"data": {
"type": "shell",
"stream": "stderr",
"output": line.to_string(),
}
}),
extensions: Default::default(),
}
})).ok();

combined_output.push_str(&line);
Expand Down
18 changes: 8 additions & 10 deletions crates/goose-mcp/src/google_drive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ use base64::Engine;
use chrono::NaiveDate;
use indoc::indoc;
use lazy_static::lazy_static;
use mcp_core::protocol::JsonRpcMessage;
use mcp_core::tool::ToolAnnotations;
use oauth_pkce::PkceOAuth2Client;
use regex::Regex;
use rmcp::model::{AnnotateAble, Content, Prompt, RawResource, Resource};
use serde_json::{json, Value};
use std::io::Cursor;
use std::{env, fs, future::Future, path::Path, pin::Pin, sync::Arc};
use storage::CredentialsManager;
use tokio::sync::mpsc;

use mcp_core::{
handler::{PromptError, ResourceError, ToolError},
protocol::ServerCapabilities,
tool::Tool,
};
use mcp_server::router::CapabilitiesBuilder;
use mcp_server::Router;
use oauth_pkce::PkceOAuth2Client;
use regex::Regex;
use rmcp::model::{AnnotateAble, Content, JsonRpcMessage, Prompt, RawResource, Resource};
use serde_json::{json, Value};
use std::io::Cursor;
use std::{env, fs, future::Future, path::Path, pin::Pin, sync::Arc};
use storage::CredentialsManager;
use tokio::sync::mpsc;

use google_docs1::{self, Docs};
use google_drive3::common::ReadSeek;
Expand Down
18 changes: 9 additions & 9 deletions crates/goose-mcp/src/memory/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
use async_trait::async_trait;
use etcetera::{choose_app_strategy, AppStrategy};
use indoc::formatdoc;
use mcp_core::{
handler::{PromptError, ResourceError, ToolError},
protocol::ServerCapabilities,
tool::{Tool, ToolAnnotations, ToolCall},
};
use mcp_server::router::CapabilitiesBuilder;
use mcp_server::Router;
use rmcp::model::JsonRpcMessage;
use rmcp::model::{Content, Prompt, Resource};
use serde_json::{json, Value};
use std::{
collections::HashMap,
Expand All @@ -12,15 +21,6 @@ use std::{
};
use tokio::sync::mpsc;

use mcp_core::{
handler::{PromptError, ResourceError, ToolError},
protocol::{JsonRpcMessage, ServerCapabilities},
tool::{Tool, ToolAnnotations, ToolCall},
};
use mcp_server::router::CapabilitiesBuilder;
use mcp_server::Router;
use rmcp::model::{Content, Prompt, Resource};

// MemoryRouter implementation
#[derive(Clone)]
pub struct MemoryRouter {
Expand Down
11 changes: 5 additions & 6 deletions crates/goose-mcp/src/tutorial/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use anyhow::Result;
use include_dir::{include_dir, Dir};
use indoc::formatdoc;
use rmcp::model::{Content, Prompt, Resource, Role};
use serde_json::{json, Value};
use std::{future::Future, pin::Pin};
use tokio::sync::mpsc;

use mcp_core::{
handler::{PromptError, ResourceError, ToolError},
protocol::{JsonRpcMessage, ServerCapabilities},
protocol::ServerCapabilities,
tool::{Tool, ToolAnnotations},
};
use mcp_server::router::CapabilitiesBuilder;
use mcp_server::Router;
use rmcp::model::{Content, JsonRpcMessage, Prompt, Resource, Role};
use serde_json::{json, Value};
use std::{future::Future, pin::Pin};
use tokio::sync::mpsc;

static TUTORIALS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/src/tutorial/tutorials");

Expand Down
4 changes: 2 additions & 2 deletions crates/goose-server/src/routes/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use goose::{
permission::{Permission, PermissionConfirmation},
session,
};
use mcp_core::{protocol::JsonRpcMessage, ToolResult};
use rmcp::model::Content;
use mcp_core::ToolResult;
use rmcp::model::{Content, JsonRpcMessage};
use serde::{Deserialize, Serialize};
use serde_json::json;
use serde_json::Value;
Expand Down
5 changes: 2 additions & 3 deletions crates/goose/src/agents/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::sync::Arc;
use anyhow::{anyhow, Result};
use futures::stream::BoxStream;
use futures::{stream, FutureExt, Stream, StreamExt, TryStreamExt};
use mcp_core::protocol::JsonRpcMessage;

use crate::agents::extension::{ExtensionConfig, ExtensionError, ExtensionResult, ToolInfo};
use crate::agents::extension_manager::{get_parameter_names, ExtensionManager};
Expand Down Expand Up @@ -45,7 +44,7 @@ use crate::scheduler_trait::SchedulerTrait;
use crate::tool_monitor::{ToolCall, ToolMonitor};
use mcp_core::{protocol::GetPromptResult, tool::Tool, ToolError, ToolResult};
use regex::Regex;
use rmcp::model::{Content, Prompt};
use rmcp::model::{Content, JsonRpcMessage, Prompt};
use serde_json::Value;
use tokio::sync::{mpsc, Mutex, RwLock};
use tokio_util::sync::CancellationToken;
Expand Down Expand Up @@ -775,7 +774,7 @@ impl Agent {
let mcp_notifications = self.get_mcp_notifications().await;
for notification in mcp_notifications {
if let JsonRpcMessage::Notification(notif) = &notification {
if let Some(data) = notif.params.as_ref().and_then(|p| p.get("data")) {
if let Some(data) = notif.notification.params.get("data") {
if let (Some(subagent_id), Some(_message)) = (
data.get("subagent_id").and_then(|v| v.as_str()),
data.get("message").and_then(|v| v.as_str()),
Expand Down
5 changes: 3 additions & 2 deletions crates/goose/src/agents/extension_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,10 @@ mod tests {
use mcp_client::client::Error;
use mcp_client::client::McpClientTrait;
use mcp_core::protocol::{
CallToolResult, GetPromptResult, InitializeResult, JsonRpcMessage, ListPromptsResult,
ListResourcesResult, ListToolsResult, ReadResourceResult,
CallToolResult, GetPromptResult, InitializeResult, ListPromptsResult, ListResourcesResult,
ListToolsResult, ReadResourceResult,
};
use rmcp::model::JsonRpcMessage;
use serde_json::json;
use tokio::sync::mpsc;

Expand Down
32 changes: 18 additions & 14 deletions crates/goose/src/agents/subagent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use crate::{
};
use anyhow::anyhow;
use chrono::{DateTime, Utc};
use mcp_core::protocol::{JsonRpcMessage, JsonRpcNotification};
use mcp_core::{handler::ToolError, tool::Tool};
use rmcp::model::{JsonRpcMessage, JsonRpcNotification, JsonRpcVersion2_0, Notification};
use rmcp::object;
use serde::{Deserialize, Serialize};
use serde_json::{self, json};
// use serde_json::{self};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::{Mutex, RwLock};
use tracing::{debug, error, instrument};
Expand Down Expand Up @@ -112,18 +113,21 @@ impl SubAgent {
/// Send an MCP notification about the subagent's activity
pub async fn send_mcp_notification(&self, notification_type: &str, message: &str) {
let notification = JsonRpcMessage::Notification(JsonRpcNotification {
jsonrpc: "2.0".to_string(),
method: "notifications/message".to_string(),
params: Some(json!({
"level": "info",
"logger": format!("subagent_{}", self.id),
"data": {
"subagent_id": self.id,
"type": notification_type,
"message": message,
"timestamp": Utc::now().to_rfc3339()
}
})),
jsonrpc: JsonRpcVersion2_0,
notification: Notification {
method: "notifications/message".to_string(),
params: object!({
"level": "info",
"logger": format!("subagent_{}", self.id),
"data": {
"subagent_id": self.id,
"type": notification_type,
"message": message,
"timestamp": Utc::now().to_rfc3339()
}
}),
extensions: Default::default(),
},
});

if let Err(e) = self.config.mcp_tx.send(notification).await {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions crates/goose/src/agents/subagent_execution_tool/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading
Loading