sonatype-mcp
Version:
Model Context Protocol server for Sonatype Nexus Repository Manager
50 lines (49 loc) • 1.59 kB
JavaScript
import { validateInput, getComponentSchema } from '../../utils/validation.js';
import { formatMCPError } from '../../utils/errors.js';
/**
* Get component details tool
*/
export function createGetComponentTool(componentService) {
return {
name: 'nexus_get_component',
description: 'Get detailed information about a specific component',
inputSchema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Component ID',
minLength: 1
}
},
required: ['id'],
additionalProperties: false
},
handler: async (params) => {
try {
const { id } = validateInput(getComponentSchema, params);
const component = await componentService.getComponent(id);
return {
content: [
{
type: 'text',
text: JSON.stringify(component, null, 2)
}
]
};
}
catch (error) {
const mcpError = formatMCPError(error);
return {
content: [
{
type: 'text',
text: `Error getting component: ${mcpError.message}`
}
],
isError: true
};
}
}
};
}