@roxybrowser/openapi 1.0.9 → 1.0.10-beta.1

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/README.md CHANGED
@@ -54,6 +54,108 @@ Add both RoxyBrowser OpenAPI and RoxyBrowser Playwright MCP to your MCP client c
54
54
 
55
55
  **Note:** Replace `YOUR API KEY` and `YOUR API HOST` with your actual RoxyBrowser credentials.
56
56
 
57
+ ## Usage
58
+
59
+ This package supports three ways to run: **CLI**, **in-process (programmatic)**, and **as a library** for custom integration.
60
+
61
+ ### 1. CLI (direct start)
62
+
63
+ Start the MCP server from the command line. Ideal for MCP clients that spawn the server as a subprocess.
64
+
65
+ ```bash
66
+ # After npm install -g @roxybrowser/openapi
67
+ roxy-browser-mcp
68
+
69
+ # Or with npx (no global install)
70
+ npx @roxybrowser/openapi
71
+
72
+ # After cloning and building
73
+ npm run build && node lib/index.js
74
+ ```
75
+
76
+ CLI options (config: **CLI args > environment variables > defaults**):
77
+
78
+ - `-V, --version` — Show version
79
+ - `-h, --help` — Show usage
80
+ - `-H, --api-host <url>` — RoxyBrowser API base URL (default: `http://127.0.0.1:50000`)
81
+ - `-k, --api-key <key>` — API key (required unless set via env)
82
+ - `-t, --timeout <ms>` — Request timeout in milliseconds (default: `30000`)
83
+
84
+ Environment variables (used when an option is not passed): `ROXY_API_HOST`, `ROXY_API_KEY`, `ROXY_TIMEOUT`.
85
+
86
+ Examples:
87
+
88
+ ```bash
89
+ roxy-browser-mcp --api-key "your-key"
90
+ roxy-browser-mcp -k "your-key" -H http://127.0.0.1:50000
91
+ ROXY_API_KEY=your-key roxy-browser-mcp
92
+ ```
93
+
94
+ ### 2. In-process (programmatic start)
95
+
96
+ Run the MCP server inside your own Node process (same process, stdio transport). Useful when you want to start the server from code instead of a separate CLI process.
97
+
98
+ ```ts
99
+ import { runServer } from '@roxybrowser/openapi'
100
+
101
+ // Starts MCP server on stdio; runs until process exits
102
+ await runServer()
103
+ ```
104
+
105
+ Or use the server class for more control:
106
+
107
+ ```ts
108
+ import { RoxyBrowserMCPServer } from '@roxybrowser/openapi'
109
+
110
+ const server = new RoxyBrowserMCPServer()
111
+ await server.run()
112
+ ```
113
+
114
+ Set env vars (`ROXY_API_KEY`, `ROXY_API_HOST`) before calling `runServer()`; config is read at process start and cannot be changed at runtime.
115
+
116
+ ### 3. Library (secondary development)
117
+
118
+ Use the exported tools and API helpers in your own app: call RoxyBrowser APIs without running the MCP server.
119
+
120
+ ```ts
121
+ import {
122
+ listBrowsers,
123
+ openBrowser,
124
+ createBrowser,
125
+ listWorkspaces,
126
+ healthCheck,
127
+ } from '@roxybrowser/openapi'
128
+
129
+ // Set ROXY_API_KEY and ROXY_API_HOST (env) before any request; config is fixed at process start
130
+ // Use tool handlers directly (same as MCP tool calls)
131
+ const listResult = await listBrowsers.handle({ workspaceId: 1 })
132
+ const openResult = await openBrowser.handle({
133
+ workspaceId: 1,
134
+ dirIds: ['browser-dir-id'],
135
+ })
136
+ const createResult = await createBrowser.handle({
137
+ workspaceId: 1,
138
+ windowName: 'My Browser',
139
+ })
140
+ ```
141
+
142
+ Each tool exports:
143
+
144
+ - `.name` — Tool name (e.g. `roxy_list_browsers`)
145
+ - `.schema` — MCP tool schema (`name`, `description`, `inputSchema`)
146
+ - `.handle(args)` — Async handler; pass the same arguments as the MCP tool
147
+
148
+ You can also use the low-level `request()` helper and types:
149
+
150
+ ```ts
151
+ import { request, resolveConfig } from '@roxybrowser/openapi'
152
+ import type { RoxyClientConfig, BrowserListItem, Workspace } from '@roxybrowser/openapi'
153
+
154
+ const res = await request('/browser/list_v3?workspaceId=1', { method: 'GET' })
155
+ ```
156
+
157
+ This allows you to build custom UIs, scripts, or other MCP servers that reuse RoxyBrowser logic.
158
+
57
159
  ## Available Tools
58
160
 
59
161
  ### Workspace
@@ -156,13 +258,17 @@ npm run build
156
258
 
157
259
  ## API Reference
158
260
 
159
- ### Environment Variables
261
+ ### Configuration
262
+
263
+ Config is resolved in this order: **CLI arguments > environment variables > defaults**.
264
+
265
+ | Source | Options / Variables | Description |
266
+ |--------|----------------------|-------------|
267
+ | CLI | `-H, --api-host`, `-k, --api-key`, `-t, --timeout` | Pass when starting the server |
268
+ | Env | `ROXY_API_HOST`, `ROXY_API_KEY`, `ROXY_TIMEOUT` | Used when CLI option not passed |
269
+ | Defaults | `apiHost: http://127.0.0.1:50000`, `timeout: 30000` | Built-in defaults |
160
270
 
161
- | Variable | Required | Default | Description |
162
- |----------|----------|---------|-------------|
163
- | `ROXY_API_KEY` | ✅ Yes | - | API key from RoxyBrowser settings |
164
- | `ROXY_API_HOST` | ✅ Yes | `http://127.0.0.1:50000` | RoxyBrowser API endpoint |
165
- | `ROXY_TIMEOUT` | No | `30000` | Request timeout in milliseconds |
271
+ Config is read from env only; use `resolveConfig()` to read current effective config (env + defaults).
166
272
 
167
273
  ## Troubleshooting
168
274
 
package/lib/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry: parse args (Commander), apply config (CLI > env > defaults), then run MCP server.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG"}
package/lib/cli.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry: parse args (Commander), apply config (CLI > env > defaults), then run MCP server.
4
+ */
5
+ import { Command } from 'commander';
6
+ import { runServer } from './index.js';
7
+ import { ConfigError } from './utils/index.js';
8
+ const PKG_VERSION = '1.0.9';
9
+ const program = new Command();
10
+ program
11
+ .name('roxy-browser-mcp')
12
+ .description('RoxyBrowser MCP Server - Model Context Protocol server for RoxyBrowser automation')
13
+ .version(PKG_VERSION, '-V, --version', 'Show version')
14
+ .option('-H, --api-host <url>', 'RoxyBrowser API base URL', process.env.ROXY_API_HOST ?? 'http://127.0.0.1:50000')
15
+ .option('-k, --api-key <key>', 'API key (or set ROXY_API_KEY)', process.env.ROXY_API_KEY ?? '')
16
+ .option('-t, --timeout <ms>', 'Request timeout in milliseconds', (v) => (v != null && v !== '' ? Number.parseInt(v, 10) : 30_000), process.env.ROXY_TIMEOUT != null ? Number(process.env.ROXY_TIMEOUT) : 30_000)
17
+ .addHelpText('after', `
18
+ Environment (used when option not passed):
19
+ ROXY_API_HOST API base URL (default: http://127.0.0.1:50000)
20
+ ROXY_API_KEY API key (required)
21
+ ROXY_TIMEOUT Timeout in ms (default: 30000)
22
+
23
+ Examples:
24
+ roxy-browser-mcp --api-key "your-key"
25
+ roxy-browser-mcp -k "your-key" -H http://127.0.0.1:50000
26
+ ROXY_API_KEY=your-key roxy-browser-mcp
27
+ `);
28
+ async function main() {
29
+ program.parse();
30
+ const opts = program.opts();
31
+ // Apply CLI args to env so request() sees them (env is the only config source)
32
+ if (opts.apiHost != null && opts.apiHost !== '')
33
+ process.env.ROXY_API_HOST = opts.apiHost;
34
+ if (opts.apiKey != null && opts.apiKey !== '')
35
+ process.env.ROXY_API_KEY = opts.apiKey;
36
+ if (opts.timeout != null)
37
+ process.env.ROXY_TIMEOUT = String(opts.timeout);
38
+ try {
39
+ await runServer();
40
+ }
41
+ catch (error) {
42
+ if (error instanceof ConfigError) {
43
+ console.error(`❌ Configuration Error: ${error.message}`);
44
+ process.exit(1);
45
+ }
46
+ console.error('❌ Unexpected error:', error);
47
+ process.exit(1);
48
+ }
49
+ }
50
+ main();
51
+ //# sourceMappingURL=cli.js.map
package/lib/cli.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE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