@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
95 lines • 5.03 kB
JavaScript
/**
* Get OpenAPI Reference Tool - Individual Module
* @description Delegates to OpenAPIReferenceHandler for API documentation
* @since 2025-08-04
* @author Tool Modularization Team
*
* Migration Status: COMPLETED
* Original Method: OptimizelyMCPTools.getOpenAPIReference
* Complexity: MEDIUM
* Dependencies: openAPIHandler, logger, errorMapper
*/
/**
* Creates the Get OpenAPI Reference tool with injected dependencies
* @param deps - Injected dependencies (storage, logger, errorMapper, etc.)
* @returns Tool definition with handler
*/
export function createGetOpenAPIReferenceTool(deps) {
return {
name: 'get_openapi_reference',
requiresCache: false,
category: 'documentation',
description: 'Provides comprehensive OpenAPI schema information, field details, operation requirements, examples, validation rules, and entity dependencies',
handler: async (args) => {
const { entity_type: entityType, information_type: informationType, operation, field_name: fieldName, project_id: projectId } = args;
try {
deps.logger.debug({
entityType,
informationType,
operation,
fieldName,
projectId
}, 'OptimizelyMCPTools.getOpenAPIReference: Processing OpenAPI reference query');
switch (informationType) {
case 'schema':
return await deps.openAPIHandler.handleSchemaQuery(entityType, projectId);
case 'operations':
if (!operation) {
// Return all available operations for this entity type
const operations = ['create', 'update', 'delete', 'list', 'get'];
const availableOperations = {};
for (const op of operations) {
try {
const opDetails = await deps.openAPIHandler.handleOperationQuery(entityType, op);
availableOperations[op] = opDetails;
}
catch (error) {
// Operation not supported for this entity
availableOperations[op] = null;
}
}
return {
entity_type: entityType,
available_operations: Object.keys(availableOperations).filter(op => availableOperations[op] !== null),
operation_details: availableOperations
};
}
return await deps.openAPIHandler.handleOperationQuery(entityType, operation);
case 'field_details':
if (!fieldName) {
throw new Error('field_name parameter required for field_details information_type');
}
return await deps.openAPIHandler.handleFieldQuery(entityType, fieldName);
case 'dependencies':
if (!operation) {
throw new Error('operation parameter required for dependencies information_type');
}
return await deps.openAPIHandler.handleDependencyQuery(entityType, operation);
case 'examples':
if (!operation) {
throw new Error('operation parameter required for examples information_type');
}
return await deps.openAPIHandler.handleExamplesQuery(entityType, operation);
case 'validation':
if (!operation) {
throw new Error('operation parameter required for validation information_type');
}
return await deps.openAPIHandler.handleValidationQuery(entityType, operation);
case 'relationships':
return await deps.openAPIHandler.handleRelationshipsQuery(entityType);
default:
throw new Error(`Unknown information_type: ${informationType}. Valid types: schema, operations, field_details, dependencies, examples, validation, relationships`);
}
}
catch (error) {
deps.logger.error({
entityType,
informationType,
error: error.message
}, 'OptimizelyMCPTools.getOpenAPIReference: Failed to process query');
throw deps.errorMapper.toMCPError(error, 'Failed to get OpenAPI reference information');
}
}
};
}
//# sourceMappingURL=GetOpenapiReference.js.map