Skip to main content
Glama

Add Issue Relationship

add_relationship

Link MantisBT issues with relationships like duplicates, dependencies, or blockers to track connections between bugs and tasks.

Instructions

Add a relationship between two MantisBT issues.

Relationship types — use either type_id (numeric) or type_name (string):

  • 0 / "duplicate_of" — this issue is a duplicate of target

  • 1 / "related_to" — this issue is related to target

  • 2 / "parent_of" — this issue depends on target (target must be done first); alias: "depends_on"

  • 3 / "child_of" — this issue blocks target (target can't proceed until this is done); alias: "blocks"

  • 4 / "has_duplicate" — this issue has target as a duplicate

Directionality note: "A child_of B" means A blocks B. "A parent_of B" means A depends on B.

Dash variants (e.g. "related-to") are also accepted for type_name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issue_idYesThe source issue ID (the one the relationship is added to)
target_idYesThe target issue ID
type_idNoRelationship type ID: 0=duplicate_of, 1=related_to, 2=parent_of (depends on), 3=child_of (blocks), 4=has_duplicate. Use either type_id or type_name.
type_nameNoRelationship type name as alternative to type_id. Accepted: "duplicate_of", "related_to", "parent_of" (or "depends_on"), "child_of" (or "blocks"), "has_duplicate". Dash variants (e.g. "related-to") also work.

Implementation Reference

  • The handler function for the 'add_relationship' tool. It validates inputs, resolves type names to IDs, and performs the API call to add the relationship.
    async ({ issue_id, target_id, type_id, type_name }) => {
      // Resolve type_id from type_name when type_id is not provided
      let resolvedTypeId = type_id;
      if (resolvedTypeId === undefined) {
        if (type_name === undefined) {
          return { content: [{ type: 'text', text: errorText('Either type_id or type_name must be provided') }], isError: true };
        }
        const normalized = type_name.toLowerCase().replace(/-/g, '_');
        resolvedTypeId = RELATIONSHIP_NAME_TO_ID[normalized];
        if (resolvedTypeId === undefined) {
          return {
            content: [{ type: 'text', text: errorText(`Unknown relationship type name: "${type_name}". Valid values: duplicate_of, related_to, parent_of, child_of, has_duplicate`) }],
            isError: true,
          };
        }
      }
    
      try {
        const body = {
          issue: { id: target_id },
          type: { id: resolvedTypeId },
        };
        const result = await client.post<unknown>(`issues/${issue_id}/relationships`, body);
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
        };
      } catch (error) {
        const msg = error instanceof Error ? error.message : String(error);
        return { content: [{ type: 'text', text: errorText(msg) }], isError: true };
      }
    }
  • Registration of the 'add_relationship' tool including description and input schema.
      server.registerTool(
        'add_relationship',
        {
          title: 'Add Issue Relationship',
          description: `Add a relationship between two MantisBT issues.
    
    Relationship types — use either type_id (numeric) or type_name (string):
    - ${RELATIONSHIP_TYPES.DUPLICATE_OF} / "duplicate_of"  — this issue is a duplicate of target
    - ${RELATIONSHIP_TYPES.RELATED_TO}   / "related_to"    — this issue is related to target
    - ${RELATIONSHIP_TYPES.PARENT_OF}    / "parent_of"     — this issue depends on target (target must be done first); alias: "depends_on"
    - ${RELATIONSHIP_TYPES.CHILD_OF}     / "child_of"      — this issue blocks target (target can't proceed until this is done); alias: "blocks"
    - ${RELATIONSHIP_TYPES.HAS_DUPLICATE} / "has_duplicate" — this issue has target as a duplicate
    
    Directionality note: "A child_of B" means A blocks B. "A parent_of B" means A depends on B.
    
    Dash variants (e.g. "related-to") are also accepted for type_name.`,
          inputSchema: z.object({
            issue_id: z.coerce.number().int().positive().describe('The source issue ID (the one the relationship is added to)'),
            target_id: z.coerce.number().int().positive().describe('The target issue ID'),
            type_id: z.coerce.number().int().min(0).max(4).optional().describe(
              'Relationship type ID: 0=duplicate_of, 1=related_to, 2=parent_of (depends on), 3=child_of (blocks), 4=has_duplicate. Use either type_id or type_name.'
            ),
            type_name: z.string().optional().describe(
              'Relationship type name as alternative to type_id. Accepted: "duplicate_of", "related_to", "parent_of" (or "depends_on"), "child_of" (or "blocks"), "has_duplicate". Dash variants (e.g. "related-to") also work.'
            ),
          }),
          annotations: {
            readOnlyHint: false,
            destructiveHint: false,
            idempotentHint: false,
          },
        },
        async ({ issue_id, target_id, type_id, type_name }) => {
          // Resolve type_id from type_name when type_id is not provided
          let resolvedTypeId = type_id;
          if (resolvedTypeId === undefined) {
            if (type_name === undefined) {
              return { content: [{ type: 'text', text: errorText('Either type_id or type_name must be provided') }], isError: true };
            }
            const normalized = type_name.toLowerCase().replace(/-/g, '_');
            resolvedTypeId = RELATIONSHIP_NAME_TO_ID[normalized];
            if (resolvedTypeId === undefined) {
              return {
                content: [{ type: 'text', text: errorText(`Unknown relationship type name: "${type_name}". Valid values: duplicate_of, related_to, parent_of, child_of, has_duplicate`) }],
                isError: true,
              };
            }
          }
    
          try {
            const body = {
              issue: { id: target_id },
              type: { id: resolvedTypeId },
            };
            const result = await client.post<unknown>(`issues/${issue_id}/relationships`, body);
            return {
              content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
            };
          } catch (error) {
            const msg = error instanceof Error ? error.message : String(error);
            return { content: [{ type: 'text', text: errorText(msg) }], isError: true };
          }
        }
      );
Behavior4/5

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

The description adds significant behavioral context beyond annotations: it details the five relationship types with their semantic meanings (duplicate_of vs has_duplicate), explains directional implications (parent/child dependencies), and notes that dash variants are accepted. It does not mention the consequence of duplicate calls (idempotentHint: false), which would have been helpful.

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 the core purpose front-loaded, followed by the relationship type reference table, directionality clarification, and input format notes. While dense, every section serves a distinct purpose; the relationship type enumeration is necessary given the complexity of the domain.

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 write operation with 4 parameters and no output schema, the description adequately covers the domain complexity. It fully documents the valid values for optional parameters (type_id/type_name) and their semantics. The only gap is lack of mention of the return value or success confirmation behavior.

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

Parameters4/5

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

With 100% schema description coverage, the baseline is 3. The description adds value by organizing the type mappings in a scannable format (numeric ID + string name + semantic explanation) and clarifying the directionality implications (blocks vs depends_on) that raw parameter descriptions don't fully convey.

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 opens with a clear, specific action ('Add a relationship between two MantisBT issues') that combines verb and resource. It effectively distinguishes itself from siblings like remove_relationship, add_note, and add_monitor by focusing specifically on issue-to-issue relationships.

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 crucial usage guidance through the directionality note ('A child_of B means A blocks B') and the explicit instruction to 'use either type_id or type_name.' While it doesn't explicitly state when to use this versus remove_relationship, the detailed relationship type definitions prevent misuse by clarifying semantic intent.

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/dpesch/mantisbt-mcp-server'

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