Skip to main content
Glama

editDependencies

Modify task dependencies in batch with transactional safety. Use 'set' to replace all dependencies or 'update' to add/remove specific ones, with full validation before applying changes.

Instructions

以批量、事务性的方式编辑一个或多个任务的依赖关系。

此工具允许 'set' 或 'update' 操作,所有编辑将在应用前进行全面验证。 如果任何指令失败,整个操作将回滚。

Args: edits (List[DependencyEdit]): 一个包含编辑指令对象的列表,每个对象的结构如下: - task_id (int): 要修改的任务ID。 - action (Literal["set", "update"]): 要执行的操作。 - dependencies (Optional[List[int]]): 当 action 为 'set' 时,提供新的完整依赖ID列表。 - add (Optional[List[int]]): 当 action 为 'update' 时,提供要添加的依赖ID列表。 - remove (Optional[List[int]]): 当 action 为 'update' 时,提供要移除的依赖ID列表。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
editsYes

Implementation Reference

  • MCP tool handler for 'editDependencies', decorated with @mcp.tool() for automatic registration, processes Pydantic inputs and delegates to PlanManager method.
    def editDependencies(edits: List[DependencyEdit]) -> ToolResponse[dict]:
        """
        以批量、事务性的方式编辑一个或多个任务的依赖关系。
    
        此工具允许 'set' 或 'update' 操作,所有编辑将在应用前进行全面验证。
        如果任何指令失败,整个操作将回滚。
    
        Args:
            edits (List[DependencyEdit]): 一个包含编辑指令对象的列表,每个对象的结构如下:
              - task_id (int): 要修改的任务ID。
              - action (Literal["set", "update"]): 要执行的操作。
              - dependencies (Optional[List[int]]): 当 action 为 'set' 时,提供新的完整依赖ID列表。
              - add (Optional[List[int]]): 当 action 为 'update' 时,提供要添加的依赖ID列表。
              - remove (Optional[List[int]]): 当 action 为 'update' 时,提供要移除的依赖ID列表。
        """
        edit_dicts = [edit.model_dump(exclude_none=True) for edit in edits]
        return plan_manager.edit_dependencies_in_batch(edit_dicts)
  • Pydantic BaseModel defining the input schema for each edit operation in the editDependencies tool.
    class DependencyEdit(BaseModel):
        """
        用于editDependencies工具,定义单个依赖编辑操作的模型。
        """
        task_id: int = Field(..., description="要修改的任务ID。")
        action: Literal["set", "update"] = Field(..., description="要执行的操作:'set' 或 'update'。")
        dependencies: Optional[List[int]] = Field(default=None, description="当action为'set'时,提供新的完整依赖ID列表。")
        add: Optional[List[int]] = Field(default=None, description="当action为'update'时,提供要添加的依赖ID列表。")
        remove: Optional[List[int]] = Field(default=None, description="当action为'update'时,提供要移除的依赖ID列表。")
  • Core batch dependency editing logic in PlanManager, including validation of tasks/dependencies, update operations (set/update), circular dependency detection, and transactional application.
    def edit_dependencies_in_batch(self, edits: List[Dict]) -> Dict:
        """
        以批量方式编辑多个任务的依赖关系
        该操作是事务性的:所有编辑指令在应用前都会被验证。
        """
        try:
            # --- 验证阶段 ---
            original_tasks_copy = deepcopy(self.plan_data["tasks"])
            temp_tasks_map = {task['id']: task for task in original_tasks_copy}
            
            for edit in edits:
                task_id = edit.get("task_id")
                action = edit.get("action")
    
                if task_id is None or action is None:
                    raise ValueError("Each edit must contain 'task_id' and 'action'")
    
                task_to_edit = temp_tasks_map.get(task_id)
                if not task_to_edit:
                    raise ValueError(f"Task {task_id} not found in plan")
    
                if action == "set":
                    new_deps = edit.get("dependencies", [])
                    for dep_id in new_deps:
                        if dep_id not in temp_tasks_map:
                            raise ValueError(f"Dependency task {dep_id} not found")
                    task_to_edit["dependencies"] = new_deps
    
                elif action == "update":
                    add_deps = edit.get("add", [])
                    remove_deps = edit.get("remove", [])
                    
                    current_deps_set = set(task_to_edit["dependencies"])
                    
                    for dep_id in add_deps:
                        if dep_id not in temp_tasks_map:
                            raise ValueError(f"Dependency task to add ({dep_id}) not found")
                        current_deps_set.add(dep_id)
                    
                    current_deps_set.difference_update(remove_deps)
                    task_to_edit["dependencies"] = list(current_deps_set)
                    
                else:
                    raise ValueError(f"Invalid action '{action}' for task {task_id}")
    
            # --- 循环依赖检测阶段 ---
            temp_tasks_list = list(temp_tasks_map.values())
            for task in temp_tasks_list:
                if self._detect_circular_dependency(task["id"], task["dependencies"], tasks_list=temp_tasks_list):
                    raise ValueError(f"Circular dependency detected for task {task['id']} after applying edits.")
    
            # --- 应用阶段 ---
            self.plan_data["tasks"] = temp_tasks_list
            self._update_timestamp()
            
            results = [{"task_id": edit["task_id"], "new_dependencies": temp_tasks_map[edit["task_id"]]["dependencies"]} for edit in edits]
    
            return {
                "success": True,
                "message": "Tasks dependencies updated successfully.",
                "data": results
            }
        except ValueError as e:
            return {"success": False, "message": str(e), "data": None}
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: batch/transactional nature, validation before application, and atomic rollback on failure. It also explains the two operation modes ('set' vs 'update'). However, it doesn't mention permission requirements, rate limits, or what happens to existing dependencies during updates.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by detailed parameter documentation. Every sentence adds value, though the parameter section is quite detailed (which is necessary given the 0% schema coverage). The information is front-loaded with the most important behavioral characteristics first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description provides substantial context about behavior, parameters, and transactional guarantees. It covers the essential aspects well, though it could benefit from mentioning return values or error responses since there's no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by providing comprehensive parameter documentation. It explains the structure of the 'edits' list, defines all fields (task_id, action, dependencies, add, remove), clarifies when each optional field is required based on action type, and provides semantic meaning beyond basic types.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('edit dependencies') and resources ('tasks'), and distinguishes it from siblings by emphasizing batch/transactional operations. It explicitly mentions 'set' and 'update' actions, which differentiates it from tools like addTask or completeTask that handle different task modifications.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool (batch/transactional dependency editing) and implicitly distinguishes it from single-task operations. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools (like whether visualizeDependencies is complementary or when to use addTask instead).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/donway19/MCPlanManager'

If you have feedback or need assistance with the MCP directory API, please join our Discord server