Skip to main content
Glama
dev-in-black

OpenProject MCP Server

by dev-in-black

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
NameRequiredDescriptionDefault
work_package_idYes
parent_idYes
lock_versionYes
notifyNo

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()
  • 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,
        )

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/dev-in-black/openproject-mcp'

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