import { writeFileSync } from 'node:fs';
const openApiSpec = {
openapi: '3.1.0',
info: {
version: '1.0.0',
title: 'VyOS MCP Server API',
description:
'Complete Model Context Provider API for VyOS network operating system automation and management',
contact: {
name: 'VyOS MCP Server',
url: 'https://github.com/bitbuilder-io/vyos-mcp',
},
license: {
name: 'MIT',
url: 'https://opensource.org/licenses/MIT',
},
},
servers: [
{
url: 'http://localhost:3000',
description: 'Local development server',
},
],
tags: [
{
name: 'Authentication',
description: 'VyOS system connection and authentication',
},
{
name: 'Configuration',
description: 'VyOS configuration management operations',
},
{
name: 'Operational',
description: 'VyOS operational mode commands',
},
{
name: 'System',
description: 'System-level operations and information',
},
{
name: 'Interfaces',
description: 'Network interface configuration and management',
},
{
name: 'Routing',
description: 'Routing protocol configuration and management',
},
{
name: 'Network Tools',
description: 'Network diagnostic and testing tools',
},
{
name: 'Monitoring',
description: 'System and network monitoring',
},
],
paths: {
'/connect': {
post: {
tags: [
'Authentication',
],
summary: 'Connect to VyOS',
description: 'Connect to a VyOS system using API credentials',
operationId: 'vyos-connect',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: [
'host',
'apiKey',
],
properties: {
host: {
type: 'string',
format: 'uri',
description: 'VyOS system hostname or IP address',
},
apiKey: {
type: 'string',
minLength: 1,
description: 'VyOS API authentication key',
},
timeout: {
type: 'number',
default: 30000,
description: 'Request timeout in milliseconds',
},
verifySSL: {
type: 'boolean',
default: false,
description: 'Verify SSL certificates',
},
},
},
},
},
},
responses: {
'200': {
description: 'Successfully connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'500': {
description: 'Connection failed',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/system/info': {
post: {
tags: [
'System',
],
summary: 'Get system information',
description:
'Get VyOS system information including version, hostname, and hardware details',
operationId: 'vyos-system-info',
responses: {
'200': {
description: 'System information retrieved successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to retrieve system information',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/config/show': {
post: {
tags: [
'Configuration',
],
summary: 'Show configuration',
description:
'Retrieve VyOS configuration for specified path or entire configuration',
operationId: 'vyos-show-config',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
path: {
type: 'array',
items: {
type: 'string',
},
description: 'Configuration path to retrieve',
},
format: {
type: 'string',
enum: [
'json',
'commands',
],
default: 'json',
description: 'Output format',
},
},
},
},
},
},
responses: {
'200': {
description: 'Configuration retrieved successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to retrieve configuration',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/config/set': {
post: {
tags: [
'Configuration',
],
summary: 'Set configuration',
description: 'Set configuration value at specified path',
operationId: 'vyos-set-config',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: [
'path',
],
properties: {
path: {
type: 'array',
items: {
type: 'string',
},
description: 'Configuration path to set',
},
value: {
type: 'string',
description: 'Value to set (omit for valueless nodes)',
},
comment: {
type: 'string',
description: 'Configuration comment',
},
},
},
},
},
},
responses: {
'200': {
description: 'Configuration set successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to set configuration',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/config/delete': {
post: {
tags: [
'Configuration',
],
summary: 'Delete configuration',
description: 'Delete configuration at specified path',
operationId: 'vyos-delete-config',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: [
'path',
],
properties: {
path: {
type: 'array',
items: {
type: 'string',
},
description: 'Configuration path to delete',
},
},
},
},
},
},
responses: {
'200': {
description: 'Configuration deleted successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to delete configuration',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/config/commit': {
post: {
tags: [
'Configuration',
],
summary: 'Commit configuration',
description: 'Commit pending configuration changes',
operationId: 'vyos-commit',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
comment: {
type: 'string',
description: 'Commit comment',
},
confirmTimeout: {
type: 'number',
description: 'Auto-rollback timeout in minutes',
},
},
},
},
},
},
responses: {
'200': {
description: 'Configuration committed successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to commit configuration',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/config/save': {
post: {
tags: [
'Configuration',
],
summary: 'Save configuration',
description: 'Save current configuration to startup config',
operationId: 'vyos-save-config',
responses: {
'200': {
description: 'Configuration saved successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to save configuration',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/interface/configure': {
post: {
tags: [
'Interfaces',
],
summary: 'Configure interface',
description: 'Configure network interface settings',
operationId: 'vyos-configure-interface',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: [
'name',
],
properties: {
name: {
type: 'string',
description: 'Interface name (e.g., eth0, wg0)',
},
address: {
type: 'string',
description: 'IP address with CIDR',
},
description: {
type: 'string',
description: 'Interface description',
},
enabled: {
type: 'boolean',
default: true,
description: 'Interface administrative state',
},
mtu: {
type: 'number',
description: 'Maximum transmission unit',
},
vlan: {
type: 'number',
description: 'VLAN ID for VLAN interfaces',
},
},
},
},
},
},
responses: {
'200': {
description: 'Interface configured successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to configure interface',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/network/ping': {
post: {
tags: [
'Network Tools',
],
summary: 'Ping host',
description: 'Execute ping connectivity test',
operationId: 'vyos-ping',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: [
'host',
],
properties: {
host: {
type: 'string',
description: 'Target hostname or IP address',
},
count: {
type: 'number',
default: 3,
description: 'Number of packets to send',
},
interval: {
type: 'number',
default: 1,
description: 'Interval between packets',
},
timeout: {
type: 'number',
default: 5,
description: 'Timeout for each packet',
},
size: {
type: 'number',
default: 56,
description: 'Packet size in bytes',
},
source: {
type: 'string',
description: 'Source IP address',
},
},
},
},
},
},
responses: {
'200': {
description: 'Ping executed successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Ping failed',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/monitoring/interfaces': {
post: {
tags: [
'Monitoring',
],
summary: 'Get interface statistics',
description: 'Get network interface statistics and status',
operationId: 'vyos-interface-stats',
responses: {
'200': {
description: 'Interface statistics retrieved successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Failed to get interface statistics',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
'/system/health': {
post: {
tags: [
'System',
],
summary: 'System health check',
description: 'Comprehensive system health assessment',
operationId: 'vyos-health-check',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
includeInterfaces: {
type: 'boolean',
default: true,
description: 'Check interface status',
},
includeRouting: {
type: 'boolean',
default: true,
description: 'Check routing protocols',
},
includeServices: {
type: 'boolean',
default: true,
description: 'Check system services',
},
includeResources: {
type: 'boolean',
default: true,
description: 'Check system resources',
},
},
},
},
},
},
responses: {
'200': {
description: 'Health check completed successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/SuccessResponse',
},
},
},
},
'400': {
description: 'Not connected to VyOS system',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
'500': {
description: 'Health check failed',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/ErrorResponse',
},
},
},
},
},
},
},
},
components: {
schemas: {
SuccessResponse: {
type: 'object',
properties: {
content: {
type: 'array',
items: {
type: 'object',
properties: {
type: {
type: 'string',
enum: [
'text',
],
},
text: {
type: 'string',
},
},
},
},
},
},
ErrorResponse: {
type: 'object',
properties: {
content: {
type: 'array',
items: {
type: 'object',
properties: {
type: {
type: 'string',
enum: [
'text',
],
},
text: {
type: 'string',
},
},
},
},
},
},
},
},
};
const outputFile = './openapi.json';
writeFileSync(outputFile, JSON.stringify(openApiSpec, null, 2));
console.log(`OpenAPI v3.1 specification generated: ${outputFile}`);
console.log(
'OpenAPI specification contains full VyOS API coverage with comprehensive tools for:',
);
console.log('- Authentication and connection management');
console.log('- Configuration operations (show, set, delete, commit, save)');
console.log('- Operational commands (show, reset, generate)');
console.log('- System management (info, reboot, poweroff, health)');
console.log('- Interface configuration and monitoring');
console.log('- Routing management and monitoring');
console.log('- Network diagnostic tools (ping, traceroute)');
console.log('- Comprehensive monitoring and statistics');