Skip to main content
Glama

DetachRelation

Remove relationships between records in RushDB by specifying source, target IDs, and relation type to manage graph database connections.

Instructions

Remove a relationship between records (single or multiple targets)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceIdYesID of the source record
targetIdNoID of one target record (deprecated if targetIds provided)
targetIdsNoIDs of multiple target records
relationTypeNoType of the relationship to remove
directionNoDirection of the relationshipoutgoing
transactionIdNoOptional transaction ID for atomic relation removal

Implementation Reference

  • The core handler function that executes the DetachRelation tool logic, detaching relationships using the db.records.detach method.
    export async function DetachRelation(params: {
      sourceId: string
      targetId?: string
      targetIds?: string[]
      relationType?: string
      direction?: 'outgoing' | 'incoming' | 'bidirectional'
      transactionId?: string
    }) {
      const { sourceId, targetId, targetIds, relationType, direction = 'outgoing', transactionId } = params
    
      const options: any = {}
      if (relationType) {
        options.typeOrTypes = relationType
      }
      if (direction) {
        options.direction = direction
      }
    
      const targets: string[] =
        targetIds && targetIds.length > 0 ? targetIds
        : targetId ? [targetId]
        : []
      if (targets.length === 0) {
        return { success: false, message: 'No targetId(s) provided' }
      }
    
      await db.records.detach({ source: sourceId, target: targets, options }, transactionId)
    
      return {
        success: true,
        message: `Relationship detached from '${sourceId}' to ${targets.length} target record(s)`
      }
    }
  • The input schema definition for the DetachRelation tool used in tool listing and validation.
    name: 'DetachRelation',
    description: 'Remove a relationship between records (single or multiple targets)',
    inputSchema: {
      type: 'object',
      properties: {
        sourceId: { type: 'string', description: 'ID of the source record' },
        targetId: {
          type: 'string',
          description: 'ID of one target record (deprecated if targetIds provided)'
        },
        targetIds: {
          type: 'array',
          items: { type: 'string' },
          description: 'IDs of multiple target records'
        },
        relationType: { type: 'string', description: 'Type of the relationship to remove' },
        direction: {
          type: 'string',
          enum: ['outgoing', 'incoming', 'bidirectional'],
          description: 'Direction of the relationship',
          default: 'outgoing'
        },
        transactionId: { type: 'string', description: 'Optional transaction ID for atomic relation removal' }
      },
      required: ['sourceId']
    }
  • index.ts:239-255 (registration)
    The switch case registration in the CallToolRequestSchema handler that dispatches calls to the DetachRelation function.
    case 'DetachRelation':
      const detachResult = await DetachRelation({
        sourceId: args.sourceId as string,
        targetId: args.targetId as string | undefined,
        targetIds: args.targetIds as string[] | undefined,
        relationType: args.relationType as string | undefined,
        direction: args.direction as 'outgoing' | 'incoming' | 'bidirectional' | undefined,
        transactionId: args.transactionId as string | undefined
      })
      return {
        content: [
          {
            type: 'text',
            text: detachResult.message
          }
        ]
      }
  • index.ts:33-33 (registration)
    Import statement registering the DetachRelation handler for use in the MCP server.
    import { DetachRelation } from './tools/DetachRelation.js'
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose whether this requires specific permissions, if the removal is reversible, what happens to related data, error conditions, or rate limits. 'Remove' implies a mutation, but behavioral details are minimal.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and immediately clarifies scope (single or multiple targets). Every word earns its place.

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

Completeness2/5

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

For a mutation tool with 6 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after removal, error handling, permissions needed, or system impact. The context signals indicate complexity that isn't addressed in the description.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema fully documents all 6 parameters. The description adds no additional parameter semantics beyond implying support for single/multiple targets, which is already covered by targetId vs. targetIds in the schema. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Remove') and resource ('relationship between records'), specifying it can handle single or multiple targets. It distinguishes from sibling tools like AttachRelation (which creates relationships) and DeleteRecord (which deletes entire records). However, it doesn't explicitly mention what types of records are involved or the system context.

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

Usage Guidelines3/5

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

The description implies usage when needing to remove relationships rather than delete records or create relationships, but doesn't explicitly state when to use this tool versus alternatives like DeleteRecord or UpdateRecord. No prerequisites, exclusions, or specific scenarios are mentioned.

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/rush-db/RushDB'

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