What Is the Main Script in OmniRoute? CLI Entry Point Explained

The main script in OmniRoute is the executable entry point at bin/omniroute.mjs that bootstraps the application, parses command-line flags, and launches the HTTP API, MCP server, or Electron desktop interface depending on runtime arguments.

The OmniRoute main script serves as the unified command-line interface (CLI) that transforms the codebase into a runnable service. Located at bin/omniroute.mjs, it handles environment initialization and runtime mode selection for the open-source LLM routing platform.

Core Responsibilities of the Main Script

The omniroute.mjs file fulfills three primary architectural duties that determine how the application behaves in different deployment contexts.

Bootstrapping the Runtime Environment

When executed, the script loads the Node.js runtime environment and parses incoming command-line arguments. It initializes the Next.js server for web-based operation or spawns the Electron process when desktop mode is requested. This bootstrap phase ensures all necessary environment variables and module paths are configured before the target service starts.

Selecting the Execution Mode

The main script acts as a router for runtime modes, determining which service layer to activate based on flags passed by the user:

  • --dev or dev: Starts the development server with live reload and hot-module replacement for the HTTP API.
  • --build or start: Compiles the production bundle and initializes the unified LLM routing endpoint.
  • --mcp: Launches the MCP (Model Context Protocol) server, exposing 94 built-in tools over the MCP protocol.
  • --electron: Spawns the cross-platform desktop UI by launching the Electron main process.

Providing Operational Utilities

Beyond service initialization, the script wires up auxiliary operational helpers. These include snapshot and restore utilities for database state management, cold-start benchmarking scripts for performance testing, and password reset workflows used in deployment pipelines.

How to Use the OmniRoute CLI

Developers interact with the main script through standard terminal commands. Below are the common invocation patterns:

Start the development server with live reload:

omniroute dev

Build for production and start the API server:

omniroute start

Launch the MCP server to expose built-in tools:

omniroute --mcp

Run the Electron desktop application:

omniroute --electron

Key Source Files in the Architecture

Understanding the main script requires familiarity with the file structure it coordinates:

  • bin/omniroute.mjs: The CLI entry point that parses flags and delegates to the appropriate runtime.
  • src/app/api/v1/**/route.ts: API route handlers instantiated when the script starts in HTTP server mode.
  • open-sse/mcp-server/**: MCP tool implementations activated when running with the --mcp flag.
  • electron/main.js: The Electron main process loaded when the script receives --electron.
  • scripts/**: Helper utilities for snapshots, rollbacks, and benchmarking that the CLI can invoke.

Summary

  • The main script (bin/omniroute.mjs) is the single executable entry point for the OmniRoute platform.
  • It bootstraps the Node.js runtime and initializes either the Next.js server or Electron process.
  • The script selects execution modes via CLI flags, supporting HTTP API, MCP server, and desktop UI operation.
  • It provides operational utilities including database snapshots, cold-start benchmarks, and deployment helpers.

Frequently Asked Questions

What file contains the OmniRoute main script?

The main script is located at bin/omniroute.mjs in the repository root. This file serves as the CLI entry point that Node.js executes when you run the omniroute command.

How do I start the OmniRoute MCP server?

Execute omniroute --mcp from your terminal. This flag instructs the main script to initialize the MCP server, which exposes 94 built-in tools over the Model Context Protocol rather than starting the HTTP API.

Can I run OmniRoute as a desktop application?

Yes. Pass the --electron flag to the main script (omniroute --electron) to launch the cross-platform desktop UI. The script will spawn the Electron main process defined in electron/main.js instead of the web server.

What operational utilities does the main script provide?

The script integrates auxiliary helpers stored in the scripts/ directory, including database snapshot and restore utilities, cold-start benchmarking tools for performance analysis, and password reset scripts used in production deployment pipelines.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →