Skip to content

Commit

Permalink
wired into cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Kvadratni committed Jan 8, 2025
1 parent d63f81e commit 534fedd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
9 changes: 5 additions & 4 deletions crates/goose-cli/src/commands/mcp.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use anyhow::Result;
use goose_mcp::DeveloperRouter;
use goose_mcp::{DeveloperRouter, JetBrainsRouter};
use mcp_server::router::RouterService;
use mcp_server::{ByteTransport, Server};
use mcp_server::{ByteTransport, Server, BoundedService};
use tokio::io::{stdin, stdout};

pub async fn run_server(name: &str) -> Result<()> {
tracing::info!("Starting MCP server");

let router = match name {
"developer" => Some(RouterService(DeveloperRouter::new())),
let router: Option<Box<dyn BoundedService>> = match name {
"developer" => Some(Box::new(RouterService(DeveloperRouter::new()))),
"jetbrains" => Some(Box::new(RouterService(JetBrainsRouter::new()))),
_ => None,
};

Expand Down
25 changes: 3 additions & 22 deletions crates/goose-mcp/src/jetbrains/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use mcp_core::{Tool, Resource, Content};
use mcp_core::handler::{ToolError, ResourceError};
use mcp_core::protocol::{ServerCapabilities, ToolsCapability, ResourcesCapability};

Check failure on line 5 in crates/goose-mcp/src/jetbrains/router.rs

View workflow job for this annotation

GitHub Actions / build

unused imports: `ResourcesCapability` and `ToolsCapability`
use mcp_server::Router;
use mcp_server::router::CapabilitiesBuilder;
use serde_json::Value;
use tracing::{info, warn, debug};
use std::future::Future;
Expand Down Expand Up @@ -110,27 +111,7 @@ impl Router for JetBrainsRouter {
}

fn capabilities(&self) -> ServerCapabilities {
// Trigger initialization when capabilities are requested
if !self.initialized.load(Ordering::SeqCst) {
debug!("Capabilities requested before initialization, spawning init task");
let router = self.clone();
tokio::spawn(async move {
if let Err(e) = router.initialize().await {
debug!("Background initialization failed: {}", e);
}
});
}

ServerCapabilities {
tools: Some(ToolsCapability {
list_changed: Some(true),
}),
resources: Some(ResourcesCapability {
list_changed: Some(false),
subscribe: Some(false),
}),
prompts: None,
}
CapabilitiesBuilder::new().with_tools(true).build()
}

fn list_tools(&self) -> Vec<Tool> {
Expand Down Expand Up @@ -199,4 +180,4 @@ impl Router for JetBrainsRouter {
Err(ResourceError::NotFound(format!("Resource not found: {}", uri)))
})
}
}
}

0 comments on commit 534fedd

Please sign in to comment.