set_parent_work_package
Assign or remove a parent work package to establish hierarchical relationships between tasks in OpenProject.
Instructions
Set or remove the parent of a work package.
Args:
work_package_id: Child work package ID
parent_id: Parent work package ID (use None to remove parent)
lock_version: Current lock version (get from work package first)
notify: Whether to send notifications (default: True)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| work_package_id | Yes | ||
| parent_id | Yes | ||
| lock_version | Yes | ||
| notify | No |
Implementation Reference
- Core handler function that uses OpenProjectClient to PATCH the work package endpoint, constructing a payload to set or clear the parent link while handling lock version and notifications.async def set_parent_work_package( work_package_id: int, parent_id: int | None, lock_version: int, notify: bool = True, ) -> dict[str, Any]: """Set or remove the parent of a work package. Args: work_package_id: Child work package ID parent_id: Parent work package ID (use None to remove parent) lock_version: Current lock version (get from work package first) notify: Whether to send notifications (default: True) Returns: Updated work package object """ client = OpenProjectClient() try: payload: dict[str, Any] = { "lockVersion": lock_version, "_links": {}, } if parent_id is None: # Remove parent by setting it to null payload["_links"]["parent"] = None else: # Set parent payload["_links"]["parent"] = build_link( f"/api/v3/work_packages/{parent_id}" ) params = {"notify": str(notify).lower()} result = await client.patch( f"work_packages/{work_package_id}?notify={params['notify']}", data=payload ) return result finally: await client.close()
- src/openproject_mcp/server.py:177-196 (registration)MCP tool decorator registration in the server, which proxies arguments to the core implementation in work_packages module.async def set_parent_work_package( work_package_id: int, parent_id: int | None, lock_version: int, notify: bool = True, ): """Set or remove the parent of a work package. Args: work_package_id: Child work package ID parent_id: Parent work package ID (use None to remove parent) lock_version: Current lock version (get from work package first) notify: Whether to send notifications (default: True) """ return await work_packages.set_parent_work_package( work_package_id=work_package_id, parent_id=parent_id, lock_version=lock_version, notify=notify, )