FindRelationships
Discover and analyze connections between data entities in your database using search conditions, sorting, and pagination to understand data relationships.
Instructions
Find relationships in the database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of relationships to return | |
| orderBy | No | Sorting configuration: key = field, value = asc|desc | |
| skip | No | Number of relationships to skip | |
| where | No | Search conditions for finding relationships |
Implementation Reference
- tools/FindRelationships.ts:17-32 (handler)The main handler function that executes the tool logic: destructures params, builds search query, calls db.relationships.find, and returns results.export async function FindRelationships(params: { where?: Record<string, any> limit?: number skip?: number orderBy?: Record<string, 'asc' | 'desc'> }) { const { where, limit = 10, skip = 0, orderBy } = params const searchQuery: any = { limit, skip } if (where) searchQuery.where = where if (orderBy && Object.keys(orderBy).length > 0) searchQuery.orderBy = orderBy const result = await db.relationships.find(searchQuery) if (result.success && result.data) return result.data return [] }
- tools.ts:239-256 (schema)Defines the tool's name, description, and input schema for validation (where, limit, skip, orderBy).{ name: 'FindRelationships', description: 'Find relationships in the database', inputSchema: { type: 'object', properties: { where: { type: 'object', description: 'Search conditions for finding relationships' }, limit: { type: 'number', description: 'Maximum number of relationships to return', default: 10 }, skip: { type: 'number', description: 'Number of relationships to skip', default: 0 }, orderBy: { type: 'object', description: 'Sorting configuration: key = field, value = asc|desc', additionalProperties: { type: 'string', enum: ['asc', 'desc'] } } }, required: [] } },
- index.ts:257-271 (registration)Registers and invokes the FindRelationships tool in the MCP server's CallToolRequest handler switch statement.case 'FindRelationships': const relations = await FindRelationships({ where: args.where as Record<string, any> | undefined, limit: args.limit as number | undefined, skip: args.skip as number | undefined, orderBy: args.orderBy as Record<string, 'asc' | 'desc'> | undefined }) return { content: [ { type: 'text', text: relations.length > 0 ? JSON.stringify(relations, null, 2) : 'No relations found' } ] }