refactor: drop Manage prefix from consolidated smart MCP tools

This commit is contained in:
Riz Ashraf committed 2026-10-05 11:11:41 +01:00
1 parent e45db33297
commit 961abb01e7
8 files changed
+914 -100

No files matched your search

+197
View File
@@ -475,6 +475,203 @@ impl McpTool for ClearPrChecklistHandler {
}
}
pub struct PinnedFilesHandler;
#[async_trait]
impl McpTool for PinnedFilesHandler {
fn name(&self) -> &'static str {
"pinned_files"
}
fn schema(&self) -> Value {
crate::mcp::tool_def::<PinnedFilesTool>(
"pinned_files",
"Consolidated pinned files focus management (pin, unpin, list)",
)
}
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
let req: PinnedFilesTool = 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 {
PinnedFileAction::Pin => {
let path = req.path.ok_or_else(|| {
crate::error::AppError::Internal("path is required for 'pin' action".to_string())
})?;
PinFileHandler.execute(serde_json::json!({"file_path": path, "namespace": ns}), state).await
}
PinnedFileAction::Unpin => {
let path = req.path.ok_or_else(|| {
crate::error::AppError::Internal("path is required for 'unpin' action".to_string())
})?;
UnpinFileHandler.execute(serde_json::json!({"file_path": path, "namespace": ns}), state).await
}
PinnedFileAction::List => {
ListPinnedFilesHandler.execute(serde_json::json!({"namespace": ns}), state).await
}
}
}
}
pub struct ContextWorkspacesHandler;
#[async_trait]
impl McpTool for ContextWorkspacesHandler {
fn name(&self) -> &'static str {
"context_workspaces"
}
fn schema(&self) -> Value {
crate::mcp::tool_def::<ContextWorkspacesTool>(
"context_workspaces",
"Consolidated context workspace state management (save, load, list, delete, diff)",
)
}
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
let req: ContextWorkspacesTool = 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 {
ContextWorkspaceAction::Save => {
let name = req.name.ok_or_else(|| {
crate::error::AppError::Internal("name is required for 'save' action".to_string())
})?;
let pinned_files = req.pinned_files.unwrap_or_default();
let active_task_ids = req.active_task_ids.unwrap_or_default();
SaveContextWorkspaceHandler.execute(
serde_json::json!({
"name": name,
"namespace": ns,
"pinned_files": pinned_files,
"active_task_ids": active_task_ids
}),
state,
).await
}
ContextWorkspaceAction::Load => {
let name = req.name.ok_or_else(|| {
crate::error::AppError::Internal("name is required for 'load' action".to_string())
})?;
LoadContextWorkspaceHandler.execute(serde_json::json!({"name": name, "namespace": ns}), state).await
}
ContextWorkspaceAction::List => {
ListContextWorkspacesHandler.execute(serde_json::json!({"namespace": ns}), state).await
}
ContextWorkspaceAction::Delete => {
let name = req.name.ok_or_else(|| {
crate::error::AppError::Internal("name is required for 'delete' action".to_string())
})?;
DeleteContextWorkspaceHandler.execute(serde_json::json!({"name": name, "namespace": ns}), state).await
}
ContextWorkspaceAction::Diff => {
let name = req.name.ok_or_else(|| {
crate::error::AppError::Internal("name is required for 'diff' action".to_string())
})?;
let other = req.other_name.ok_or_else(|| {
crate::error::AppError::Internal("other_name is required for 'diff' action".to_string())
})?;
DiffContextWorkspacesHandler.execute(serde_json::json!({"workspace_a": name, "workspace_b": other, "namespace": ns}), state).await
}
}
}
}
pub struct PrChecklistHandler;
#[async_trait]
impl McpTool for PrChecklistHandler {
fn name(&self) -> &'static str {
"pr_checklist"
}
fn schema(&self) -> Value {
crate::mcp::tool_def::<PrChecklistTool>(
"pr_checklist",
"Consolidated PR checklist management (add, get, clear)",
)
}
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
let req: PrChecklistTool = 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 {
PrChecklistAction::Add => {
let desc = req.description.ok_or_else(|| {
crate::error::AppError::Internal("description is required for 'add' action".to_string())
})?;
AddPrChecklistItemHandler.execute(serde_json::json!({"description": desc, "namespace": ns}), state).await
}
PrChecklistAction::Get => {
GetPrChecklistHandler.execute(serde_json::json!({"namespace": ns}), state).await
}
PrChecklistAction::Clear => {
ClearPrChecklistHandler.execute(serde_json::json!({"namespace": ns}), state).await
}
}
}
}
pub struct SnippetsHandler;
#[async_trait]
impl McpTool for SnippetsHandler {
fn name(&self) -> &'static str {
"snippets"
}
fn schema(&self) -> Value {
crate::mcp::tool_def::<SnippetsTool>(
"snippets",
"Consolidated reusable code snippets management (store, search, delete, tag)",
)
}
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
let req: SnippetsTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
match req.action {
SnippetAction::Store => {
let name = req.query.or(req.id).ok_or_else(|| {
crate::error::AppError::Internal("name is required for 'store' action".to_string())
})?;
let lang = req.language.unwrap_or_else(|| "text".to_string());
let code = req.code.unwrap_or_default();
let desc = req.description.unwrap_or_default();
StoreSnippetHandler.execute(
serde_json::json!({
"name": name,
"language": lang,
"code": code,
"description": desc,
"tags": req.tags
}),
state,
).await
}
SnippetAction::Search => {
let q = req.query.unwrap_or_default();
if req.hybrid.unwrap_or(false) {
crate::handlers::meta::SearchSnippetsHybridHandler.execute(serde_json::json!({"query": q, "tags": req.tags}), state).await
} else {
SearchSnippetsHandler.execute(serde_json::json!({"query": q, "tags": req.tags}), state).await
}
}
SnippetAction::Delete => {
let id = req.id.or(req.query).ok_or_else(|| {
crate::error::AppError::Internal("id/name is required for 'delete' action".to_string())
})?;
DeleteSnippetHandler.execute(serde_json::json!({"name": id}), state).await
}
SnippetAction::Tag => {
let id = req.id.or(req.query).ok_or_else(|| {
crate::error::AppError::Internal("id/name is required for 'tag' action".to_string())
})?;
let tags = req.tags.unwrap_or_default();
TagSnippetHandler.execute(serde_json::json!({"name": id, "tags": tags}), state).await
}
}
}
}
use crate::handlers::utils::*;
#[cfg(test)]