Skip to main content
Glama
dev-in-black

OpenProject MCP Server

by dev-in-black

create_relation

Establish connections between work packages to define dependencies, hierarchies, or associations in OpenProject. Specify relation types like blocks, precedes, duplicates, or relates to organize task relationships.

Instructions

Create a relation between two work packages.

Args:
    from_id: Source work package ID
    to_id: Target work package ID
    relation_type: Type of relation (relates, duplicates, blocks, precedes, follows, includes, partof, requires)
    lag: Optional lag in days for precedes/follows relations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_idYes
to_idYes
relation_typeYes
lagNo

Implementation Reference

  • Core implementation of the create_relation tool, handling API call to create relation between work packages.
    async def create_relation(
        from_id: int,
        to_id: int,
        relation_type: RelationType,
        lag: int | None = None,
    ) -> dict[str, Any]:
        """Create a relation between two work packages.
    
        Args:
            from_id: Source work package ID
            to_id: Target work package ID
            relation_type: Type of relation. Options:
                - relates: General relation
                - duplicates: Source duplicates target
                - duplicated: Source is duplicated by target
                - blocks: Source blocks target
                - blocked: Source is blocked by target
                - precedes: Source precedes target (with optional lag in days)
                - follows: Source follows target (with optional lag in days)
                - includes: Source includes target (parent-child)
                - partof: Source is part of target (child-parent)
                - requires: Source requires target
                - required: Source is required by target
            lag: Optional lag in days for precedes/follows relations
    
        Returns:
            Created relation object
        """
        client = OpenProjectClient()
    
        try:
            payload: dict[str, Any] = {
                "_links": {
                    "from": build_link(f"/api/v3/work_packages/{from_id}"),
                    "to": build_link(f"/api/v3/work_packages/{to_id}"),
                },
                "type": relation_type,
            }
    
            if lag is not None:
                payload["lag"] = lag
    
            result = await client.post("relations", data=payload)
            return result
        finally:
            await client.close()
  • MCP tool registration for create_relation, which delegates to the relations module implementation.
    @mcp.tool()
    async def create_relation(
        from_id: int,
        to_id: int,
        relation_type: str,
        lag: int | None = None,
    ):
        """Create a relation between two work packages.
    
        Args:
            from_id: Source work package ID
            to_id: Target work package ID
            relation_type: Type of relation (relates, duplicates, blocks, precedes, follows, includes, partof, requires)
            lag: Optional lag in days for precedes/follows relations
        """
        return await relations.create_relation(
            from_id=from_id,
            to_id=to_id,
            relation_type=relation_type,  # type: ignore
            lag=lag,
        )
  • Type definition for valid relation_type values used in create_relation.
    RelationType = Literal[
        "relates",
        "duplicates",
        "duplicated",
        "blocks",
        "blocked",
        "precedes",
        "follows",
        "includes",
        "partof",
        "requires",
        "required",
    ]

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