UNPKG

unity-editor-mcp

Version:

MCP server for Unity Editor integration - enables AI assistants to control Unity Editor

56 lines (50 loc) 1.55 kB
/** * Configuration for Unity Editor MCP Server */ export const config = { // Unity connection settings unity: { host: process.env.UNITY_HOST || 'localhost', port: parseInt(process.env.UNITY_PORT, 10) || 6400, reconnectDelay: 1000, // Initial reconnect delay in ms maxReconnectDelay: 30000, // Maximum reconnect delay reconnectBackoffMultiplier: 2, commandTimeout: 30000, // Command timeout in ms }, // Server settings server: { name: 'unity-editor-mcp-server', version: '0.1.0', description: 'MCP server for Unity Editor integration', }, // Logging settings logging: { level: process.env.LOG_LEVEL || 'info', prefix: '[Unity Editor MCP]', } }; /** * Logger utility * IMPORTANT: In MCP servers, all stdout output must be JSON-RPC protocol messages. * Logging must go to stderr to avoid breaking the protocol. */ export const logger = { info: (message, ...args) => { if (['info', 'debug'].includes(config.logging.level)) { console.error(`${config.logging.prefix} ${message}`, ...args); } }, warn: (message, ...args) => { if (['info', 'debug', 'warn'].includes(config.logging.level)) { console.error(`${config.logging.prefix} WARN: ${message}`, ...args); } }, error: (message, ...args) => { console.error(`${config.logging.prefix} ERROR: ${message}`, ...args); }, debug: (message, ...args) => { if (config.logging.level === 'debug') { console.error(`${config.logging.prefix} DEBUG: ${message}`, ...args); } } };