chore(mcp): convert computercontroller server to use the rust sdk (#4772)

This commit is contained in:
Alex Hancock
2025-09-24 10:03:00 -04:00
committed by GitHub
parent 0d25cea181
commit dba0f4eaef
9 changed files with 983 additions and 1192 deletions
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -10,11 +10,12 @@ pub static APP_STRATEGY: Lazy<AppStrategyArgs> = Lazy::new(|| AppStrategyArgs {
pub mod autovisualiser;
pub mod computercontroller;
pub mod developer;
pub mod mcp_server_runner;
mod memory;
pub mod tutorial;
pub use autovisualiser::AutoVisualiserRouter;
pub use computercontroller::ComputerControllerRouter;
pub use computercontroller::ComputerControllerServer;
pub use developer::rmcp_developer::DeveloperServer;
pub use memory::MemoryServer;
pub use tutorial::TutorialServer;
+45
View File
@@ -0,0 +1,45 @@
use crate::{
AutoVisualiserRouter, ComputerControllerServer, DeveloperServer, MemoryServer, TutorialServer,
};
use anyhow::{anyhow, Result};
use rmcp::{transport::stdio, ServiceExt};
/// Run an MCP server by name
///
/// This function handles the common logic for starting MCP servers.
/// The caller is responsible for setting up logging before calling this function.
pub async fn run_mcp_server(name: &str) -> Result<()> {
if name == "googledrive" || name == "google_drive" {
return Err(anyhow!(
"the built-in Google Drive extension has been removed"
));
}
tracing::info!("Starting MCP server");
match name {
"autovisualiser" => serve_and_wait(AutoVisualiserRouter::new()).await,
"computercontroller" => serve_and_wait(ComputerControllerServer::new()).await,
"developer" => serve_and_wait(DeveloperServer::new()).await,
"memory" => serve_and_wait(MemoryServer::new()).await,
"tutorial" => serve_and_wait(TutorialServer::new()).await,
_ => {
tracing::warn!("Unknown MCP server name: {}", name);
Err(anyhow!("Unknown MCP server name: {}", name))
}
}
}
/// Helper function to run any MCP server with common error handling
async fn serve_and_wait<S>(server: S) -> Result<()>
where
S: rmcp::ServerHandler,
{
let service = server.serve(stdio()).await.inspect_err(|e| {
tracing::error!("serving error: {:?}", e);
})?;
service.waiting().await?;
Ok(())
}