feat: initial implementation of VirtFusion MCP server
Complete MCP server wrapping all 84 VirtFusion Admin API endpoints: - Core HTTP client with Bearer auth and error handling - 17 tool modules organized by API category - Endpoint drift detection scripts and Gitea Actions CI/CD - Comprehensive README with configuration examples - CLAUDE.md for AI assistant onboarding Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
38
src/tools/media.ts
Normal file
38
src/tools/media.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { z } from 'zod';
|
||||
import { VirtFusionClient } from '../client.js';
|
||||
import { formatErrorResponse } from '../errors.js';
|
||||
|
||||
export function registerMediaTools(server: McpServer, client: VirtFusionClient): void {
|
||||
server.tool(
|
||||
'media_get_iso',
|
||||
'Retrieve details of a specific ISO image',
|
||||
{
|
||||
isoId: z.number().describe('The ISO image ID'),
|
||||
},
|
||||
async ({ isoId }) => {
|
||||
try {
|
||||
const result = await client.get(`/media/iso/${isoId}`);
|
||||
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
||||
} catch (error) {
|
||||
return formatErrorResponse(error);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
'media_get_templates_by_package',
|
||||
'List OS templates available for a specific package',
|
||||
{
|
||||
serverPackageId: z.number().describe('The server package ID'),
|
||||
},
|
||||
async ({ serverPackageId }) => {
|
||||
try {
|
||||
const result = await client.get(`/media/templates/fromServerPackageSpec/${serverPackageId}`);
|
||||
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
||||
} catch (error) {
|
||||
return formatErrorResponse(error);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user