get_entity_relationships
Retrieve all relationships for a specific entity to analyze corporate connections and influence networks, with options to filter by category and sort by date or amount.
Instructions
Get all relationships this entity has with other entities
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The entity ID | |
| category_id | No | Filter relationships by category (1-12) | |
| sort | No | Sort order for relationships | recent |
| page | No | Page number for pagination |
Implementation Reference
- src/tools/entity-tools.ts:253-279 (handler)The handler function that executes the get_entity_relationships tool logic, calling the LittleSis API and returning formatted results or errors.export async function handleGetEntityRelationships(args: any) { try { const result = await LittleSisApi.getEntityRelationships(args.id, { category_id: args.category_id, sort: args.sort, page: args.page }); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching entity relationships: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/entity-tools.ts:87-115 (schema)The Tool object definition including input schema and description for get_entity_relationships.export const getEntityRelationshipsTool: Tool = { name: 'get_entity_relationships', description: 'Get all relationships this entity has with other entities', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'The entity ID' }, category_id: { type: 'number', description: 'Filter relationships by category (1-12)' }, sort: { type: 'string', enum: ['amount', 'oldest', 'recent'], description: 'Sort order for relationships', default: 'recent' }, page: { type: 'number', description: 'Page number for pagination', minimum: 1 } }, required: ['id'] } };
- src/index.ts:72-81 (registration)Registration of the get_entity_relationships handler in the toolHandlers mapping used by the MCP server.const toolHandlers = { get_entity: handleGetEntity, get_entities: handleGetEntities, search_entities: handleSearchEntities, get_entity_extensions: handleGetEntityExtensions, get_entity_relationships: handleGetEntityRelationships, get_entity_connections: handleGetEntityConnections, get_entity_lists: handleGetEntityLists, get_relationship: handleGetRelationship, };
- src/api.ts:72-81 (helper)The LittleSisApi helper method that performs the actual API request for entity relationships.static async getEntityRelationships(id: number, params?: EntityRelationshipsParams): Promise<LittleSisApiResponse<Relationship[]>> { const searchParams = new URLSearchParams(); if (params?.category_id) searchParams.append('category_id', params.category_id.toString()); if (params?.sort) searchParams.append('sort', params.sort); if (params?.page) searchParams.append('page', params.page.toString()); const paramString = searchParams.toString(); const endpoint = `/entities/${id}/relationships${paramString ? '?' + paramString : ''}`; return makeApiRequest<Relationship[]>(endpoint); }