build_onyx_code
Compile Onyx code into executable files by specifying code, directory, and timeout. Simplifies building Onyx projects directly within your workspace.
Instructions
Build Onyx code file using "onyx build" in a specified directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Onyx code to build | |
| directory | No | Directory to build in (defaults to current working directory) | . |
| filename | No | Filename for the Onyx file | main.onyx |
| timeout | No | Build timeout in seconds |
Implementation Reference
- src/core/mcp-shared.js:377-425 (handler)The main handler function buildOnyxCode that writes the provided Onyx code to a file in the specified directory and executes 'onyx build' command, returning build results including stdout, stderr, and success status.async buildOnyxCode(code, filename = 'main.onyx', directory = '.', timeout = 30) { const toolMessage = `Building Onyx code using "onyx build" in directory: ${directory}`; try { // Resolve the target directory const targetDir = path.resolve(directory); // Check if directory exists try { await fs.access(targetDir); } catch (error) { throw new Error(`Directory does not exist: ${targetDir}`); } // Write the code to the specified file in target directory const filePath = path.join(targetDir, filename); await fs.writeFile(filePath, code, 'utf8'); // Build the Onyx code in target directory const result = await this.executeOnyxCommand(['build', filename], timeout, targetDir); // Format the response with build results const response = { success: result.success, exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr, executionTime: result.executionTime, command: `onyx build ${filename}`, filename: filename, codeLength: code.length, workingDirectory: targetDir }; return this.formatResponse(JSON.stringify(response, null, 2), toolMessage); } catch (error) { const errorResponse = { success: false, error: error.message, command: `onyx build ${filename}`, filename: filename, codeLength: code.length, workingDirectory: directory }; return this.formatResponse(JSON.stringify(errorResponse, null, 2), toolMessage); } }
- src/core/mcp-shared.js:147-160 (schema)Input schema definition for the build_onyx_code tool, specifying parameters: code (required string), filename, directory, and timeout.{ name: 'build_onyx_code', description: 'Build Onyx code file using "onyx build" in a specified directory', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Onyx code to build' }, filename: { type: 'string', description: 'Filename for the Onyx file', default: 'main.onyx' }, directory: { type: 'string', description: 'Directory to build in (defaults to current working directory)', default: '.' }, timeout: { type: 'number', description: 'Build timeout in seconds', default: 30 } }, required: ['code'] } },
- src/core/mcp-shared.js:651-652 (registration)Registration in the tool dispatcher switch statement, mapping 'build_onyx_code' tool calls to the buildOnyxCode handler method.case 'build_onyx_code': return await this.buildOnyxCode(args.code, args.filename, args.directory, args.timeout);