refactor: drop Manage prefix from consolidated smart MCP tools
This commit is contained in:
1 parent
e45db33297
commit
961abb01e7
8 files changed
+914
-100
No files matched your search
@@ -162,6 +162,56 @@ impl McpTool for GetEnvironmentDetailsHandler {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EnvironmentHandler;
|
||||
|
||||
#[async_trait]
|
||||
impl McpTool for EnvironmentHandler {
|
||||
fn name(&self) -> &'static str {
|
||||
"environment"
|
||||
}
|
||||
|
||||
fn schema(&self) -> Value {
|
||||
crate::mcp::tool_def::<EnvironmentTool>(
|
||||
"environment",
|
||||
"Consolidated environment & infrastructure management",
|
||||
)
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
let req: EnvironmentTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let ns = req.namespace.unwrap_or_else(|| crate::models::default_namespace());
|
||||
match req.action {
|
||||
EnvAction::UpdateFingerprint => {
|
||||
let tool_versions = req.tool_versions.unwrap_or_default();
|
||||
UpdateEnvFingerprintHandler.execute(serde_json::json!({"namespace": ns, "tool_versions": tool_versions}), state).await
|
||||
}
|
||||
EnvAction::ReadFingerprint => {
|
||||
ReadEnvFingerprintHandler.execute(serde_json::json!({"namespace": ns}), state).await
|
||||
}
|
||||
EnvAction::LogRequirement => {
|
||||
let key = req.key.ok_or_else(|| {
|
||||
crate::error::AppError::Internal("key is required for 'log_requirement' action".to_string())
|
||||
})?;
|
||||
let desc = req.description.unwrap_or_default();
|
||||
let secret = req.is_secret.unwrap_or(false);
|
||||
LogEnvRequirementHandler.execute(serde_json::json!({"key": key, "description": desc, "is_secret": secret, "namespace": ns}), state).await
|
||||
}
|
||||
EnvAction::Register => {
|
||||
let name = req.name.ok_or_else(|| {
|
||||
crate::error::AppError::Internal("name is required for 'register' action".to_string())
|
||||
})?;
|
||||
let url = req.url.unwrap_or_default();
|
||||
let desc = req.description.unwrap_or_default();
|
||||
let vpn = req.requires_vpn.unwrap_or(false);
|
||||
RegisterEnvironmentHandler.execute(serde_json::json!({"name": name, "url": url, "description": desc, "requires_vpn": vpn, "namespace": ns}), state).await
|
||||
}
|
||||
EnvAction::GetDetails => {
|
||||
GetEnvironmentDetailsHandler.execute(serde_json::json!({"namespace": ns}), state).await
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in new issue
Block a user