Skip to main content
Glama
elias-michaias

Onyx Documentation MCP Server

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
NameRequiredDescriptionDefault
codeYesOnyx code to build
directoryNoDirectory to build in (defaults to current working directory).
filenameNoFilename for the Onyx filemain.onyx
timeoutNoBuild timeout in seconds

Implementation Reference

  • 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); } }
  • 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'] } },
  • 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);

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/elias-michaias/onyx_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server