Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(mcp): reuse tinymcp_bus config types for tool exposure and identity

Steven Enamakeld103e83f4d07
diff --git a/crates/openhuman-core/src/config/schema/tools/mcp.rs b/crates/openhuman-core/src/config/schema/tools/mcp.rs
index 4bafc8e141..5e8a332029 100644
--- a/crates/openhuman-core/src/config/schema/tools/mcp.rs
+++ b/crates/openhuman-core/src/config/schema/tools/mcp.rs
@@ -89,51 +89,33 @@ impl From<tinymcp_bus::McpServerConfig> for McpServerConfig {
}
}
-/// How a configured MCP server's tools enter the model's catalogue.
-#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum McpToolExposure {
- /// Found through `tool_search`, then callable by name.
- #[default]
- Deferred,
- /// Sent to the model every turn.
- Direct,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
-#[serde(default)]
-pub struct McpClientIdentityConfig {
- /// Client name sent during `initialize.clientInfo.name`.
- #[serde(default = "default_mcp_client_name")]
- pub name: String,
- /// Client title sent during `initialize.clientInfo.title`.
- #[serde(default = "default_mcp_client_title")]
- pub title: String,
- /// Client version sent during `initialize.clientInfo.version`.
- #[serde(default = "default_mcp_client_version")]
- pub version: String,
-}
-
-fn default_mcp_client_name() -> String {
- "openhuman-core".into()
-}
-
-fn default_mcp_client_title() -> String {
- "OpenHuman Core MCP Client".into()
-}
-
-fn default_mcp_client_version() -> String {
- env!("CARGO_PKG_VERSION").into()
+// The contract's shapes for how tools enter the catalogue and how the client
+// identifies itself. OpenHuman only supplies its own identity as the default.
+pub use tinymcp_bus::{McpClientIdentityConfig, McpToolExposure};
+
+/// OpenHuman's identity block: the config default for `[mcp_client.client_identity]`.
+pub(crate) fn default_client_identity() -> McpClientIdentityConfig {
+ McpClientIdentityConfig {
+ name: "openhuman-core".into(),
+ title: "OpenHuman Core MCP Client".into(),
+ version: env!("CARGO_PKG_VERSION").into(),
+ ..McpClientIdentityConfig::default()
+ }
}
-impl Default for McpClientIdentityConfig {
- fn default() -> Self {
- Self {
- name: default_mcp_client_name(),
- title: default_mcp_client_title(),
- version: default_mcp_client_version(),
- }
+/// Deserializes the identity table over OpenHuman's defaults, so a partial
+/// table (say only `name`) keeps OpenHuman's title and version rather than the
+/// module's.
+fn deserialize_client_identity<'de, D>(de: D) -> Result<McpClientIdentityConfig, D::Error>
+where
+ D: serde::Deserializer<'de>,
+{
+ let overlay = serde_json::Value::deserialize(de)?;
+ let mut base = serde_json::to_value(default_client_identity()).map_err(serde::de::Error::custom)?;
+ if let (Some(base), serde_json::Value::Object(overlay)) = (base.as_object_mut(), overlay) {
+ base.extend(overlay);
}
+ serde_json::from_value(base).map_err(serde::de::Error::custom)
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
@@ -148,7 +130,10 @@ pub struct McpClientConfig {
#[serde(default)]
pub servers: Vec<McpServerConfig>,
/// Identity block sent during initialize.
- #[serde(default)]
+ #[serde(
+ default = "default_client_identity",
+ deserialize_with = "deserialize_client_identity"
+ )]
pub client_identity: McpClientIdentityConfig,
/// Optional auth/overrides for the MCP *registry* browse APIs (Smithery +
/// the official modelcontextprotocol/registry). Each value falls back to
@@ -162,7 +147,7 @@ impl Default for McpClientConfig {
Self {
enabled: defaults::default_true(),
servers: Vec::new(),
- client_identity: McpClientIdentityConfig::default(),
+ client_identity: default_client_identity(),
registry_auth: McpRegistryAuthConfig::default(),
}
}
diff --git a/crates/openhuman-core/src/mcp/module_client.rs b/crates/openhuman-core/src/mcp/module_client.rs
index d45ba73185..de6f8ab90c 100644
--- a/crates/openhuman-core/src/mcp/module_client.rs
+++ b/crates/openhuman-core/src/mcp/module_client.rs
@@ -377,12 +377,7 @@ impl McpConfiguredClient {
family: server.name.clone(),
display_name: server.name.clone(),
tools,
- default_exposure: match declared.expose {
- crate::config::McpToolExposure::Direct => tinymcp_bus::McpToolExposure::Direct,
- crate::config::McpToolExposure::Deferred => {
- tinymcp_bus::McpToolExposure::Deferred
- }
- },
+ default_exposure: declared.expose,
direct_tools: declared.direct_tools.clone(),
});
}