sonatype-mcp
Version:
Model Context Protocol server for Sonatype Nexus Repository Manager
54 lines (53 loc) • 1.71 kB
JavaScript
import { formatMCPError } from '../../utils/errors.js';
import { z } from 'zod';
import { validateInput } from '../../utils/validation.js';
const deleteComponentSchema = z.object({
id: z.string().min(1, 'Component ID is required')
}).strict();
/**
* Delete component tool
*/
export function createDeleteComponentTool(componentService) {
return {
name: 'nexus_delete_component',
description: 'Delete a component (requires write mode)',
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Component ID to delete',
minLength: 1
}
},
required: ['id'],
additionalProperties: false
},
handler: async (params) => {
try {
const { id } = validateInput(deleteComponentSchema, params);
await componentService.deleteComponent(id);
return {
content: [
{
type: 'text',
text: `Component '${id}' has been deleted successfully.`
}
]
};
}
catch (error) {
const mcpError = formatMCPError(error);
return {
content: [
{
type: 'text',
text: `Error deleting component: ${mcpError.message}`
}
],
isError: true
};
}
}
};
}