UNPKG

@utaba/ucm-mcp-server

Version:

Universal Context Manager MCP Server - AI Productivity Platform

136 lines 5.59 kB
import { BaseToolController } from '../base/BaseToolController.js'; export class SearchArtifactsTool extends BaseToolController { constructor(ucmClient, logger, publishingAuthorId) { super(ucmClient, logger, publishingAuthorId); } get name() { return 'ucm_search_artifacts'; } get description() { return `Search artifacts by text across multiple metadata fields with privacy filtering. Searches namespace, filename, description, and tags fields. ${this.publishingAuthorId ? "Your author value is '" + this.publishingAuthorId + "'" : ''}`; } get inputSchema() { return { type: 'object', properties: { searchText: { type: 'string', description: 'Text to search across namespace, repository, category, subcategory, filename, description, and tags (case-insensitive)', minLength: 1, maxLength: 200 }, namespace: { type: 'string', description: 'Optional namespace filter (e.g., "utaba/main/commands/user")', maxLength: 200 }, author: { type: 'string', description: `Optional. Leave empty to search your own author and public authors. '(e.g., "' + this.publishingAuthorId + '")' : ''}`, maxLength: 50 }, repository: { type: 'string', description: 'Optional repository filter', maxLength: 200 }, category: { type: 'string', description: 'Optional category filter (e.g., "commands", "services", "patterns")', maxLength: 50 }, subcategory: { type: 'string', description: 'Optional subcategory filter (e.g., "user", "auth", "database")', maxLength: 50 }, filename: { type: 'string', description: 'Optional filename filter (e.g., "CreateUserCommand.ts")', maxLength: 100 }, tags: { type: 'string', description: 'Optional tags filter - comma-separated list of tags to search for', maxLength: 500 }, offset: { type: 'number', description: 'Number of items to skip for pagination (default: 0)', minimum: 0 }, limit: { type: 'number', description: 'Maximum number of items to return (default: 20, max: 100)', minimum: 1, maximum: 100 } }, required: [] }; } async handleExecute(params) { const { searchText, namespace, author, repository, category, subcategory, filename, tags, offset, limit } = params; this.logger.debug('SearchArtifactsTool', `Searching with filters`, '', { searchText, namespace, author, repository, category, subcategory, filename, tags, offset: offset || 0, limit: limit || 20 }); try { // Call the new search API endpoint const response = await this.ucmClient.searchArtifactsByText({ searchText, namespace, author, repository, // Don't default to 'main' - let it search all repositories when undefined category, subcategory, filename, tags, offset: offset || 0, limit: limit || 20 }); this.logger.info('SearchArtifactsTool', `Found ${response.data.length} artifacts matching filters`, '', { totalResults: response.pagination.total, filters: { searchText, namespace, author, repository, category, subcategory, filename, tags } }); // Return structured search results (only include filters that were actually provided) const appliedFilters = {}; if (searchText) appliedFilters.searchText = searchText; if (namespace) appliedFilters.namespace = namespace; if (author) appliedFilters.author = author; if (repository) appliedFilters.repository = repository; if (category) appliedFilters.category = category; if (subcategory) appliedFilters.subcategory = subcategory; if (filename) appliedFilters.filename = filename; if (tags) appliedFilters.tags = tags; return { filters: appliedFilters, results: response.data, pagination: response.pagination, hasMore: response.pagination.hasMore, _links: response._links }; } catch (error) { this.logger.error('SearchArtifactsTool', `Failed to search with provided filters`, '', error); throw error; } } } //# sourceMappingURL=SearchArtifactsTool.js.map