The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
style: apply rustfmt formatting to mcp server module
Steven Enamakel440c33c7877d
diff --git a/crates/openhuman-core/src/mcp/server/handler.rs b/crates/openhuman-core/src/mcp/server/handler.rsindex 616f011474..f76b58ec48 100644--- a/crates/openhuman-core/src/mcp/server/handler.rs+++ b/crates/openhuman-core/src/mcp/server/handler.rs@@ -80,9 +80,7 @@ fn reply_error(error: ToolCallError) -> ServerHostReply {match error {ToolCallError::InvalidParams(message) => ServerHostReply::InvalidParams { message },ToolCallError::Internal(message) => ServerHostReply::Internal { message },- ToolCallError::ResourceNotFound(message) => {- ServerHostReply::ResourceNotFound { message }- }+ ToolCallError::ResourceNotFound(message) => ServerHostReply::ResourceNotFound { message },}}diff --git a/crates/openhuman-core/src/mcp/server/handler_tests.rs b/crates/openhuman-core/src/mcp/server/handler_tests.rsindex 66df14ca8b..6052c55009 100644--- a/crates/openhuman-core/src/mcp/server/handler_tests.rs+++ b/crates/openhuman-core/src/mcp/server/handler_tests.rs@@ -3,7 +3,9 @@ use super::*;#[test]fn host_tool_errors_keep_their_category_and_diagnostic() {assert_eq!(- reply_error(ToolCallError::InvalidParams("argument was empty".to_owned())),+ reply_error(ToolCallError::InvalidParams(+ "argument was empty".to_owned()+ )),ServerHostReply::InvalidParams {message: "argument was empty".to_owned()}diff --git a/crates/openhuman-core/src/mcp/server/http.rs b/crates/openhuman-core/src/mcp/server/http.rsindex c3cefa4dc0..02970b5000 100644--- a/crates/openhuman-core/src/mcp/server/http.rs+++ b/crates/openhuman-core/src/mcp/server/http.rs@@ -1,26 +1,21 @@//! OpenHuman's thin Streamable HTTP adapter over TinyMCP's server contract.-use std::{- collections::HashMap,- convert::Infallible,- net::SocketAddr,- sync::Arc,- time::Duration,-};+use std::{collections::HashMap, convert::Infallible, net::SocketAddr, sync::Arc, time::Duration};use axum::{body::Bytes,extract::State,http::{header::AUTHORIZATION, HeaderMap, HeaderName, HeaderValue, StatusCode},- response::{sse::{Event, KeepAlive, Sse}, IntoResponse, Response},+ response::{+ sse::{Event, KeepAlive, Sse},+ IntoResponse, Response,+ },routing::post,Router,};use futures_util::stream;use serde_json::{Map, Value};-use tinymcp_bus::{- ServerHttpSessionMethod, ServerHttpSessionRequest, HEADER_SESSION_ID,-};+use tinymcp_bus::{ServerHttpSessionMethod, ServerHttpSessionRequest, HEADER_SESSION_ID};use crate::{config::Config, modules::client::ModuleCallError};@@ -83,7 +78,12 @@ async fn handle_post(State(state): State<HttpState>, headers: HeaderMap, body: B};let requested_session_id = header_value(&headers, HEADER_SESSION_ID).map(str::to_owned);let session = if let Some(requested_session_id) = requested_session_id.as_deref() {- state.sessions.lock().await.get(requested_session_id).cloned()+ state+ .sessions+ .lock()+ .await+ .get(requested_session_id)+ .cloned()} else {None};@@ -163,7 +163,12 @@ async fn http_session_request(}let requested_session_id = header_value(headers, HEADER_SESSION_ID).map(str::to_owned);let session = if let Some(requested_session_id) = requested_session_id.as_deref() {- state.sessions.lock().await.get(requested_session_id).cloned()+ state+ .sessions+ .lock()+ .await+ .get(requested_session_id)+ .cloned()} else {None};@@ -183,12 +188,13 @@ async fn http_session_request(};let response = response_from_metadata(metadata, String::new());if method == ServerHttpSessionMethod::Get && response.status() == StatusCode::OK {- return Sse::new(stream::pending::<Result<Event, Infallible>>()).keep_alive(- KeepAlive::new()- .interval(Duration::from_secs(10))- .text("keepalive"),- )- .into_response();+ return Sse::new(stream::pending::<Result<Event, Infallible>>())+ .keep_alive(+ KeepAlive::new()+ .interval(Duration::from_secs(10))+ .text("keepalive"),+ )+ .into_response();}if method == ServerHttpSessionMethod::Delete && response.status() == StatusCode::NO_CONTENT {if let Some(requested_session_id) = requested_session_id {@@ -235,8 +241,8 @@ fn response_from_metadata(metadata: tinymcp_bus::ServerHttpResponseMetadata,body: String,) -> Response {- let status = StatusCode::from_u16(metadata.status_code)- .unwrap_or(StatusCode::INTERNAL_SERVER_ERROR);+ let status =+ StatusCode::from_u16(metadata.status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR);let mut response = if let Some(error_body) = metadata.error_body {(status, error_body).into_response()} else if body.is_empty() {@@ -254,7 +260,9 @@ fn response_from_metadata(}if let Some(content_type) = metadata.content_type {if let Ok(value) = HeaderValue::from_str(&content_type) {- response.headers_mut().insert(axum::http::header::CONTENT_TYPE, value);+ response+ .headers_mut()+ .insert(axum::http::header::CONTENT_TYPE, value);}}responsediff --git a/crates/openhuman-core/src/mcp/server/module.rs b/crates/openhuman-core/src/mcp/server/module.rsindex 9ba592a950..cf3da62c42 100644--- a/crates/openhuman-core/src/mcp/server/module.rs+++ b/crates/openhuman-core/src/mcp/server/module.rs@@ -49,8 +49,7 @@ pub(super) enum ServerError {#[async_trait]pub(super) trait ServerPort: Send + Sync {async fn open(&self, config: ServerSessionConfig) -> Result<String, ModuleCallError>;- async fn open_http(&self, config: ServerHttpSessionConfig)- -> Result<String, ModuleCallError>;+ async fn open_http(&self, config: ServerHttpSessionConfig) -> Result<String, ModuleCallError>;async fn submit(&self,session: &str,@@ -79,13 +78,12 @@ struct TinyMcpPort {#[async_trait]impl ServerPort for TinyMcpPort {async fn open(&self, config: ServerSessionConfig) -> Result<String, ModuleCallError> {- self.client.call(MODULE, names::methods::SERVER_OPEN, (config,)).await+ self.client+ .call(MODULE, names::methods::SERVER_OPEN, (config,))+ .await}- async fn open_http(- &self,- config: ServerHttpSessionConfig,- ) -> Result<String, ModuleCallError> {+ async fn open_http(&self, config: ServerHttpSessionConfig) -> Result<String, ModuleCallError> {self.client.call(MODULE, names::methods::SERVER_OPEN_HTTP, (config,)).await@@ -147,7 +145,6 @@ impl ServerPort for TinyMcpPort {.call(MODULE, names::methods::SERVER_HTTP_SESSION, (request,)).await}-}pub(super) struct ServerSession {@@ -290,11 +287,7 @@ impl ServerSession {}};self.port- .submit(- &self.id,- pending.headers.clone(),- pending.input.clone(),- )+ .submit(&self.id, pending.headers.clone(), pending.input.clone()).await.map_err(ServerError::Module)?;@@ -394,10 +387,7 @@ impl ServerSession {}pub(super) async fn close(&self) -> Result<(), ServerError> {- self.port- .close(&self.id)- .await- .map_err(ServerError::Module)+ self.port.close(&self.id).await.map_err(ServerError::Module)}pub(super) async fn http_session(@@ -409,10 +399,11 @@ impl ServerSession {.await.map_err(ServerError::Module)}-}-pub(super) fn headers_object(headers: impl Iterator<Item = (String, String)>) -> Map<String, Value> {+pub(super) fn headers_object(+ headers: impl Iterator<Item = (String, String)>,+) -> Map<String, Value> {headers.map(|(name, value)| (name, Value::String(value))).collect()diff --git a/crates/openhuman-core/src/mcp/server/module_tests.rs b/crates/openhuman-core/src/mcp/server/module_tests.rsindex 8ac4ccad01..f8a393d03a 100644--- a/crates/openhuman-core/src/mcp/server/module_tests.rs+++ b/crates/openhuman-core/src/mcp/server/module_tests.rs@@ -24,10 +24,7 @@ impl ServerPort for FixturePort {Ok(config.session_id)}- async fn open_http(- &self,- config: ServerHttpSessionConfig,- ) -> Result<String, ModuleCallError> {+ async fn open_http(&self, config: ServerHttpSessionConfig) -> Result<String, ModuleCallError> {self.open(config.server).await}@@ -96,7 +93,6 @@ impl ServerPort for FixturePort {) -> Result<ServerHttpResponseMetadata, ModuleCallError> {unreachable!()}-}#[tokio::test]@@ -114,7 +110,10 @@ async fn server_session_completes_host_resource_callback() {.await.unwrap();- assert!(matches!(snapshot.state, ServerOperationState::Complete { .. }));+ assert!(matches!(+ snapshot.state,+ ServerOperationState::Complete { .. }+ ));let state = port.0.lock().unwrap();assert!(matches!(state.completed,diff --git a/crates/openhuman-core/src/mcp/server/stdio.rs b/crates/openhuman-core/src/mcp/server/stdio.rsindex f96d1293f0..7677273819 100644--- a/crates/openhuman-core/src/mcp/server/stdio.rs+++ b/crates/openhuman-core/src/mcp/server/stdio.rs@@ -7,9 +7,9 @@ use std::net::SocketAddr;use crate::{config::Config, core::logging::CliLogDefault};-use super::module::ServerSession;#[cfg(feature = "http-server")]use super::http::{run_http, HttpServerConfig};+use super::module::ServerSession;#[derive(Debug, Clone, Copy, PartialEq, Eq)]enum McpTransport {