@omega.js/mcp-router 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,98 @@
1
+ Copyright (c) 2026 ITW Creative Works
2
+
3
+ Licensor: ITW Creative Works
4
+ Software: @omega.js/mcp-router
5
+
6
+ Elastic License 2.0
7
+
8
+ URL: https://www.elastic.co/licensing/elastic-license
9
+
10
+ ## Acceptance
11
+
12
+ By using the software, you agree to all of the terms and conditions below.
13
+
14
+ ## Copyright License
15
+
16
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
17
+ non-sublicensable, non-transferable license to use, copy, distribute, make
18
+ available, and prepare derivative works of the software, in each case subject to
19
+ the limitations and conditions below.
20
+
21
+ ## Limitations
22
+
23
+ You may not provide the software to third parties as a hosted or managed
24
+ service, where the service provides users with access to any substantial set of
25
+ the features or functionality of the software.
26
+
27
+ You may not move, change, disable, or circumvent the license key functionality
28
+ in the software, and you may not remove or obscure any functionality in the
29
+ software that is protected by the license key.
30
+
31
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
32
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
33
+ to applicable law.
34
+
35
+ ## Patents
36
+
37
+ The licensor grants you a license, under any patent claims the licensor can
38
+ license, or becomes able to license, to make, have made, use, sell, offer for
39
+ sale, import and have imported the software, in each case subject to the
40
+ limitations and conditions in this license. This license does not cover any
41
+ patent claims that you cause to be infringed by modifications or additions to
42
+ the software. If you or your company make any written claim that the software
43
+ infringes or contributes to infringement of any patent, your patent license for
44
+ the software granted under these terms ends immediately. If your company makes
45
+ such a claim, your patent license ends immediately for work on behalf of your
46
+ company.
47
+
48
+ ## Notices
49
+
50
+ You must ensure that anyone who gets a copy of any part of the software from you
51
+ also gets a copy of these terms.
52
+
53
+ If you modify the software, you must include in any modified copies of the
54
+ software prominent notices stating that you have modified the software.
55
+
56
+ ## No Other Rights
57
+
58
+ These terms do not imply any licenses other than those expressly granted in
59
+ these terms.
60
+
61
+ ## Termination
62
+
63
+ If you use the software in violation of these terms, such use is not licensed,
64
+ and your licenses will automatically terminate. If the licensor provides you
65
+ with a notice of your violation, and you cease all violation of this license no
66
+ later than 30 days after you receive that notice, your licenses will be
67
+ reinstated retroactively. However, if you violate these terms after such
68
+ reinstatement, any additional violation of these terms will cause your licenses
69
+ to terminate automatically and permanently.
70
+
71
+ ## No Liability
72
+
73
+ *As far as the law allows, the software comes as is, without any warranty or
74
+ condition, and the licensor will not be liable to you for any damages arising
75
+ out of these terms or the use or nature of the software, under any kind of
76
+ legal claim.*
77
+
78
+ ## Definitions
79
+
80
+ The **licensor** is the entity offering these terms, and the **software** is the
81
+ software the licensor makes available under these terms, including any portion
82
+ of it.
83
+
84
+ **you** refers to the individual or entity agreeing to these terms.
85
+
86
+ **your company** is any legal entity, sole proprietorship, or other kind of
87
+ organization that you work for, plus all organizations that have control over,
88
+ are under the control of, or are under common control with that
89
+ organization. **control** means ownership of substantially all the assets of an
90
+ entity, or the power to direct its management and policies by vote, contract, or
91
+ otherwise. Control can be direct or indirect.
92
+
93
+ **your licenses** are all the licenses granted to you for the software under
94
+ these terms.
95
+
96
+ **use** means anything you do with the software requiring one of your licenses.
97
+
98
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @omega.js/mcp-router
2
+
3
+ One MCP endpoint for a whole session, and it stays cheap.
4
+
5
+ An MCP client that declares five servers pays for five: every one is launched, every one's full tool schema sits in the context window from the first token. The router flips that around. It is a single stdio MCP server that proxies many **upstream** servers: tool schemas come from a cache on disk, upstream processes are spawned **lazily** on the first tool call that actually needs one, and a session turns upstreams on and off for itself without touching disk or restarting anything.
6
+
7
+ Tools surface to the client as `<upstream>__<tool>` — inside Claude Code that reads `mcp__mcp-router__chrome-devtools__click`.
8
+
9
+ A child is as short-lived as its use: it starts on the first call that needs it, and it is closed once nothing has called it for 15 minutes — with everything it started, not just the pid the router holds — after which the next call spawns a fresh one. A call in flight is never closed under, and a call that lands while a close is running is served by a fresh child rather than failing. When the host goes away, by a signal or simply by closing the router's stdin, the router closes every upstream, waits out the grace that kills what they started, and exits.
10
+
11
+ The omega Claude plugin launches the router straight from the monorepo checkout it ships in, and on a bare clone the bin installs its own dependencies on first launch — no install step for a user, no publish for a dev editing the checkout.
12
+
13
+ ## What ships with it
14
+
15
+ Four defaults, ready on install day:
16
+
17
+ | Upstream | What it does | Default |
18
+ |---|---|---|
19
+ | `chrome-devtools` | A private, isolated, throwaway-profile Chrome per session | auto |
20
+ | `chrome-devtools-electron` | Attaches to an already-running omega desktop dev app on `$OMEGA_CDP_PORT` | auto |
21
+ | `chrome-devtools-extension` | Chrome for Testing with the unpacked extension at `$OMEGA_EXTENSION_PATH` pre-loaded | on-demand |
22
+ | `omega-extension` | The extension automation server inside `@omega.js/manager` | auto |
23
+
24
+ An `on-demand` upstream stays invisible until a session asks for it — that is how a noisy 34-tool server costs nothing until it is wanted.
25
+
26
+ ## The meta-tools (per session, from inside the client)
27
+
28
+ - `router__list_upstreams` — every upstream, its on-disk enabled state, whether it is locked, whether it is active in this session, its cached tool count, and — when a child is running — that child's `pid` and how long it has been idle (`idle_ms`).
29
+ - `router__enable_upstream {name, env?}` — activate for THIS session, unless the upstream is locked. `env` sets vars on the child (passing it restarts a running child so they take effect).
30
+ - `router__disable_upstream {name}` — deactivate and stop the child. Disk is untouched.
31
+ - `router__refresh_upstream {name}` — spawn once, re-read the tool list, and cache it.
32
+
33
+ ## Config layering
34
+
35
+ Two layers, and only one of them is ever written:
36
+
37
+ 1. **Bundled defaults** — `servers/<name>/config.json` inside this package. Read-only: for a consumer they live in `node_modules`.
38
+ 2. **Your overlay** — `~/.omega/mcp-router/servers/<name>/config.json`, plus `~/.omega/mcp-router/.env` for secrets.
39
+
40
+ The merge is **shallow and field-level**: an overlay entry's top-level keys win over the bundled entry's, and everything else survives.
41
+
42
+ ```jsonc
43
+ // ~/.omega/mcp-router/servers/chrome-devtools/config.json
44
+ { "enabled": false } // turns the bundled default off, keeps its command + tools cache
45
+ ```
46
+ ```jsonc
47
+ // ~/.omega/mcp-router/servers/playwright/config.json
48
+ { "enabled": true, "default": "on-demand", "command": "npx", "args": ["-y", "@playwright/mcp@latest", "--isolated"] }
49
+ ```
50
+ ```jsonc
51
+ // ~/.omega/mcp-router/servers/playwright/config.json
52
+ { "enabled": false, "locked": true } // stays off: every enable is refused, `--force` is the only way past
53
+ ```
54
+
55
+ `"locked": true` holds an upstream off. `omega-mcp enable` refuses it (exit 1, naming the field) unless you pass `--force`, and the per-chat `router__enable_upstream` refuses it with no override at all. Disabling, removing, and refreshing a locked upstream stay allowed: the lock is against waking it, not against turning it off.
56
+
57
+ A name that only exists in the overlay is simply a private upstream of yours. Nothing you do forks the defaults, and an upgrade of this package never clobbers your overrides.
58
+
59
+ ## The CLI
60
+
61
+ `omega-mcp` manages the registry. Every command reads the merged view and writes the overlay.
62
+
63
+ ```bash
64
+ omega-mcp list # every upstream, its source (bundled / yours), state, tool count
65
+ omega-mcp enable chrome-devtools-extension # writes {"enabled": true} to your overlay, then caches the schema
66
+ omega-mcp disable chrome-devtools # writes {"enabled": false}
67
+ omega-mcp enable playwright --force # the only way past a {"locked": true} entry
68
+ omega-mcp add my-server npx -y my-mcp@latest
69
+ omega-mcp remove my-server # a bundled default cannot be removed — disable it instead
70
+ omega-mcp refresh chrome-devtools # re-fetch and cache the tool schemas
71
+ ```
72
+
73
+ Registering the router with a client is not this CLI's job: the omega Claude plugin declares it once, in its `.mcp.json`.
74
+
75
+ ## Environment
76
+
77
+ | Variable | What it does |
78
+ |---|---|
79
+ | `OMEGA_CDP_PORT` | The port `chrome-devtools-electron` attaches to (default `9222`) |
80
+ | `OMEGA_EXTENSION_PATH` | The unpacked extension directory `chrome-devtools-extension` loads |
81
+ | `MCP_ROUTER_SERVERS_DIR` | Overrides the overlay servers dir (tests, power users) |
82
+ | `MCP_ROUTER_ENV_FILE` | Overrides the overlay `.env` path |
83
+ | `MCP_ROUTER_SPAWN_TIMEOUT_MS` | How long a cold spawn (or either refresh surface's one-shot: `router__refresh_upstream` and `omega-mcp refresh` share one helper) gets to finish the MCP handshake before it is given up on (default `30000`) |
84
+ | `MCP_ROUTER_IDLE_MS` | How long an upstream's child may sit with no call before the router closes it; the sweep runs at a quarter of it, floored at a second (default `900000`) |
85
+
86
+ ### Placeholders
87
+
88
+ An upstream's `command`, `args`, and `env` may carry `${NAME}` placeholders, resolved from `~/.omega/mcp-router/.env` first and then the environment — so a token lives in the `.env`, never in a config file. **`${NAME:-default}` takes the same lookups** and falls back to the literal default when they all miss, so an optional value needs no `sh -c` wrapper around the command; other shell forms (`${VAR:+…}`) pass through untouched.
89
+
90
+ One name is reserved: **`${MCP_ROUTER_ROOT}`** always resolves to this package's root directory, before any `.env` or environment lookup. It is how a bundled upstream points at a launcher script the package ships with, wherever the package is installed.
91
+
92
+ ## Docs
93
+
94
+ The full guide — architecture, the launchers, the plugin wiring, the noted gaps — is [docs/mcp-router/index.md](../../docs/mcp-router/index.md) in the OMEGA monorepo.
95
+
96
+ ## License
97
+
98
+ [Elastic License 2.0](LICENSE). The source is free to use and modify; a license key unlocks payments in production deploys and removes the attribution (local dev and test payments are always free); and you may not offer `@omega.js/mcp-router` to third parties as a hosted or managed service.
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The router bin — `npx -y @omega.js/mcp-router` picks the bin whose name
4
+ * matches the unscoped package name, so THIS is the one the plugin's
5
+ * .mcp.json launches. Requiring the module starts the stdio server.
6
+ */
7
+
8
+ if (!require('../src/ensure-deps.js').ensureDeps()) process.exit(1);
9
+ require('../src/router.js');
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The management CLI bin — `omega-mcp list|enable|disable|add|remove|refresh`.
4
+ * Requiring the module runs the command named by argv.
5
+ */
6
+
7
+ if (!require('../src/ensure-deps.js').ensureDeps()) process.exit(1);
8
+ require('../src/cli.js').main();
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@omega.js/mcp-router",
3
+ "version": "0.1.0",
4
+ "description": "One lazy MCP endpoint for every OMEGA session \u2014 a stdio server that proxies many upstream MCP servers and surfaces each upstream's tools only once it is activated",
5
+ "private": false,
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "main": "./src/router.js",
10
+ "bin": {
11
+ "mcp-router": "./bin/mcp-router.js",
12
+ "omega-mcp": "./bin/omega-mcp.js"
13
+ },
14
+ "files": [
15
+ "bin/",
16
+ "src/",
17
+ "servers/",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "test": "node --require @omega.js/devkit/test/stdout-guard --test test/*.test.js"
22
+ },
23
+ "dependencies": {
24
+ "@modelcontextprotocol/sdk": "^1.29.0",
25
+ "ws": "^8.21.0"
26
+ },
27
+ "devDependencies": {
28
+ "@omega.js/devkit": "*"
29
+ },
30
+ "engines": {
31
+ "node": ">=22"
32
+ },
33
+ "keywords": [
34
+ "omega",
35
+ "mcp",
36
+ "mcp-server",
37
+ "model-context-protocol",
38
+ "claude"
39
+ ],
40
+ "author": "ITW Creative Works",
41
+ "license": "Elastic-2.0"
42
+ }