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'

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/1pxone/RushDB'

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