@utaba/ucm-mcp-server
Version:
Universal Context Manager MCP Server - AI Productivity Platform
41 lines • 1.56 kB
JavaScript
import { McpError, McpErrorCode } from '../../utils/McpErrorHandler.js';
export class BaseToolController {
ucmClient;
logger;
publishingAuthorId;
constructor(ucmClient, logger, publishingAuthorId) {
this.ucmClient = ucmClient;
this.logger = logger;
this.publishingAuthorId = publishingAuthorId;
}
async execute(params) {
try {
this.validateParams(params);
return await this.handleExecute(params);
}
catch (error) {
// Sanitize error for logging to avoid circular reference issues with axios errors
const sanitizedError = {
message: error?.message,
name: error?.name,
status: error?.response?.status,
statusText: error?.response?.statusText,
data: error?.response?.data,
url: error?.config?.url
};
this.logger.error('BaseToolController', `Tool ${this.name} execution failed`, '', sanitizedError);
throw error;
}
}
validateParams(params) {
// Basic validation - can be overridden by specific tools
if (this.inputSchema.required) {
for (const field of this.inputSchema.required) {
if (params[field] === undefined || params[field] === null) {
throw new McpError(McpErrorCode.InvalidParams, `Required parameter '${field}' is missing`);
}
}
}
}
}
//# sourceMappingURL=BaseToolController.js.map