UNPKG

@utaba/ucm-mcp-server

Version:

Universal Context Manager MCP Server - AI Productivity Platform

63 lines 2.84 kB
import { BaseToolController } from '../base/BaseToolController.js'; import { parsePath } from '../../utils/PathUtils.js'; export class GetArtifactVersionsTool extends BaseToolController { constructor(ucmClient, logger, publishingAuthorId) { super(ucmClient, logger, publishingAuthorId); } get name() { return 'ucm_get_artifact_versions'; } get description() { return 'Get all available versions of a specific UCM artifact'; } get inputSchema() { return { type: 'object', properties: { path: { type: 'string', description: `Full artifact path without version (e.g., "${this.publishingAuthorId || '01234567890'}/main/commands/user/CreateUserCommand.ts")`, minLength: 1, maxLength: 200 } }, required: ['path'] }; } async handleExecute(params) { let { path } = params; this.logger.debug('GetArtifactVersionsTool', `Retrieving versions for artifact: ${path}`); try { // Parse the path to extract components if (!path) path = ""; const pathComponents = parsePath(path); // Validate that path contains all required components including repository if (!pathComponents.author || !pathComponents.repository || !pathComponents.category || !pathComponents.subcategory || !pathComponents.filename) { throw new Error(`Invalid artifact path. Expected format: {author}/{repository}/{category}/{subcategory}/{filename}. ` + `Received: ${path}`); } // Get versions from API const versions = await this.ucmClient.getArtifactVersions(pathComponents.author, pathComponents.repository, pathComponents.category, pathComponents.subcategory, pathComponents.filename); // Return the versions data return { path, author: pathComponents.author, repository: pathComponents.repository, category: pathComponents.category, subcategory: pathComponents.subcategory, filename: pathComponents.filename, versions: versions }; } catch (error) { this.logger.error('GetArtifactVersionsTool', 'Failed to retrieve artifact versions', error); if (error.message?.includes('404') || error.message?.includes('not found')) { throw new Error(`Artifact not found: ${path}`); } throw new Error(`Failed to retrieve artifact versions: ${error.message || 'Unknown error'}`); } } } //# sourceMappingURL=GetArtifactVersionsTool.js.map