UNPKG

@utaba/ucm-mcp-server

Version:

Universal Context Manager MCP Server - AI Productivity Platform

56 lines 2.28 kB
import { BaseToolController } from '../base/BaseToolController.js'; import { ResponseChunker } from '../../utils/ResponseChunker.js'; import { McpError, McpErrorCode } from '../../utils/McpErrorHandler.js'; export class GetChunkTool extends BaseToolController { constructor(ucmClient, logger, publishingAuthorId) { super(ucmClient, logger, publishingAuthorId); } get name() { return 'ucm_get_chunk'; } get description() { return 'Retrieve the next chunk of a large UCM artifact response'; } get inputSchema() { return { type: 'object', properties: { chunkId: { type: 'string', description: 'The chunk ID to retrieve', minLength: 1 }, sequence: { type: 'number', description: 'The sequence number of the chunk to retrieve', minimum: 0 } }, required: ['chunkId', 'sequence'] }; } async handleExecute(params) { const { chunkId, sequence } = params; this.logger.debug('GetChunkTool', `Retrieving chunk: ${chunkId} sequence ${sequence}`); // Get chunk info first const chunkInfo = ResponseChunker.getChunkInfo(chunkId); if (!chunkInfo.exists) { throw new McpError(McpErrorCode.InvalidParams, `Chunk with ID '${chunkId}' not found. It may have expired.`); } // Validate sequence range if (sequence < 0 || (chunkInfo.total && sequence >= chunkInfo.total)) { throw new McpError(McpErrorCode.InvalidParams, `Sequence ${sequence} is out of range. Valid range is 0-${(chunkInfo.total || 1) - 1}`); } // Get the chunk const nextChunk = ResponseChunker.getNextChunk(chunkId, sequence); if (!nextChunk) { throw new McpError(McpErrorCode.InternalError, 'Failed to retrieve chunk'); } this.logger.info('GetChunkTool', `Chunk retrieved: ${chunkId} sequence ${sequence}`, '', { hasMore: nextChunk.hasMore, total: nextChunk.chunk.total }); return nextChunk; } } //# sourceMappingURL=GetChunkTool.js.map