list_entities
Retrieve and manage knowledge graph entities from remote memory storage with filtering, sorting, and pagination options.
Instructions
엔티티 목록을 조회합니다 (필터링, 정렬, 페이지네이션 지원)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityType | No | 특정 엔티티 타입으로 필터링 | |
| sortBy | No | 정렬 기준 (기본값: createdAt) | |
| sortOrder | No | 정렬 순서 (기본값: desc) | |
| dateFrom | No | 시작 날짜 (ISO 8601 형식) | |
| dateTo | No | 종료 날짜 (ISO 8601 형식) | |
| limit | No | 페이지 크기 (기본값: 50) | |
| offset | No | 시작 위치 (기본값: 0) |
Implementation Reference
- src/index.ts:579-604 (handler)MCP tool handler for list_entities: delegates to memoryManager.listEntities and formats JSON response with pagination info.private async handleListEntities(args: any) { const result = this.memoryManager.listEntities({ entityType: args.entityType, sortBy: args.sortBy, sortOrder: args.sortOrder, dateFrom: args.dateFrom, dateTo: args.dateTo, limit: args.limit, offset: args.offset, }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, entities: result.entities, count: result.entities.length, total: result.total, offset: args.offset || 0, limit: args.limit || 50, hasMore: (args.offset || 0) + result.entities.length < result.total, }, null, 2), }], }; }
- src/index.ts:242-276 (schema)Input schema defining parameters for filtering, sorting, and paginating entities.inputSchema: { type: 'object', properties: { entityType: { type: 'string', description: '특정 엔티티 타입으로 필터링' }, sortBy: { type: 'string', enum: ['createdAt', 'updatedAt', 'name'], description: '정렬 기준 (기본값: createdAt)' }, sortOrder: { type: 'string', enum: ['asc', 'desc'], description: '정렬 순서 (기본값: desc)' }, dateFrom: { type: 'string', description: '시작 날짜 (ISO 8601 형식)' }, dateTo: { type: 'string', description: '종료 날짜 (ISO 8601 형식)' }, limit: { type: 'number', description: '페이지 크기 (기본값: 50)' }, offset: { type: 'number', description: '시작 위치 (기본값: 0)' } }, },
- src/index.ts:239-277 (registration)Registration of the list_entities tool in the tools list returned by ListToolsRequestSchema, including name, description, and schema.{ name: 'list_entities', description: '엔티티 목록을 조회합니다 (필터링, 정렬, 페이지네이션 지원)', inputSchema: { type: 'object', properties: { entityType: { type: 'string', description: '특정 엔티티 타입으로 필터링' }, sortBy: { type: 'string', enum: ['createdAt', 'updatedAt', 'name'], description: '정렬 기준 (기본값: createdAt)' }, sortOrder: { type: 'string', enum: ['asc', 'desc'], description: '정렬 순서 (기본값: desc)' }, dateFrom: { type: 'string', description: '시작 날짜 (ISO 8601 형식)' }, dateTo: { type: 'string', description: '종료 날짜 (ISO 8601 형식)' }, limit: { type: 'number', description: '페이지 크기 (기본값: 50)' }, offset: { type: 'number', description: '시작 위치 (기본값: 0)' } }, }, },
- src/memory-graph.ts:148-197 (helper)Core helper method implementing entity listing with filtering by type/date, sorting, and pagination.listEntities(options?: { entityType?: string; sortBy?: 'createdAt' | 'updatedAt' | 'name'; sortOrder?: 'asc' | 'desc'; dateFrom?: string; dateTo?: string; limit?: number; offset?: number; }): { entities: Entity[]; total: number } { let entities = Array.from(this.graph.entities.values()); // EntityType 필터링 if (options?.entityType) { entities = entities.filter(e => e.entityType === options.entityType); } // 날짜 범위 필터링 if (options?.dateFrom) { entities = entities.filter(e => e.createdAt >= options.dateFrom!); } if (options?.dateTo) { entities = entities.filter(e => e.createdAt <= options.dateTo!); } // 정렬 const sortBy = options?.sortBy || 'createdAt'; const sortOrder = options?.sortOrder || 'desc'; entities.sort((a, b) => { let aVal: string, bVal: string; if (sortBy === 'name') { aVal = a.name; bVal = b.name; } else { aVal = a[sortBy]; bVal = b[sortBy]; } const comparison = aVal.localeCompare(bVal); return sortOrder === 'asc' ? comparison : -comparison; }); const total = entities.length; // 페이지네이션 if (options?.offset !== undefined || options?.limit !== undefined) { const offset = options.offset || 0; const limit = options.limit || 50; entities = entities.slice(offset, offset + limit); } return { entities, total };