@roxybrowser/openapi 1.0.13-beta.6 → 1.0.13

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/lib/cli.js CHANGED
@@ -3,6 +3,7 @@ import { Command } from 'commander';
3
3
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
5
  import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
6
+ import dotenv from 'dotenv';
6
7
 
7
8
  // src/types.ts
8
9
  var ConfigError = class extends Error {
@@ -2121,6 +2122,14 @@ var ListBrowsers = class {
2121
2122
  searchParams.append("page_index", params.pageIndex.toString());
2122
2123
  if (params.pageSize)
2123
2124
  searchParams.append("page_size", params.pageSize.toString());
2125
+ if (params.windowSortNum) {
2126
+ if (params.windowSortNum.includes("-")) {
2127
+ const [_, serialNo] = params.windowSortNum.split("-").map((s) => s.trim());
2128
+ searchParams.append("windowSortNum", serialNo);
2129
+ } else {
2130
+ searchParams.append("windowSortNum", params.windowSortNum);
2131
+ }
2132
+ }
2124
2133
  const result = await request(`/browser/list_v3?${searchParams}`, {
2125
2134
  method: "GET"
2126
2135
  });
@@ -2135,23 +2144,29 @@ var ListBrowsers = class {
2135
2144
  const pageSize = params.pageSize ?? 15;
2136
2145
  const totalPages = Math.max(1, Math.ceil((data.total || 0) / pageSize));
2137
2146
  const hasNextPage = currentPage < totalPages;
2138
- text = `Found ${data.total} browsers in workspace ${params.workspaceId}:
2139
-
2140
- ${data.rows.map((browser) => {
2141
- const serialNo = `${browser.workspaceName?.slice(0, 3).toLocaleUpperCase()}-${browser.windowSortNum}`;
2142
- return `**${browser.windowName || "Unnamed"}** (Serial No: ${serialNo})
2143
- - CoreVersion: ${browser.coreVersion} - DirId: ${browser.dirId}
2144
- - OSVersion: ${browser.osVersion}
2145
- - OS: ${browser.os}
2146
- - Remark: ${browser.windowRemark}`;
2147
- }).join("\n\n")}
2148
-
2149
- Pagination:
2150
- - currentPage: ${currentPage}
2151
- - pageSize: ${pageSize}
2152
- - totalPages: ${totalPages}
2153
- - hasNextPage: ${hasNextPage}
2154
- ${hasNextPage ? `- nextPageHint: Call roxy_list_browsers again with pageIndex=${currentPage + 1}` : "- nextPageHint: No more pages"}`;
2147
+ const readable = [];
2148
+ if (data.total > 0) {
2149
+ readable.push(`Found ${data.total} browsers in workspace ${params.workspaceId}:`);
2150
+ const browserList = data.rows.map((browser) => {
2151
+ const serialNo = `${browser.workspaceName?.slice(0, 3).toLocaleUpperCase()}-${browser.windowSortNum}`;
2152
+ const info = [
2153
+ `Profile Name: **${browser.windowName || "Unnamed"}** (SN: ${serialNo})`,
2154
+ ` - CoreVersion: ${browser.coreVersion}`,
2155
+ ` - OS: ${browser.os} ${browser.osVersion}`
2156
+ ];
2157
+ if (browser.windowRemark) {
2158
+ info.push(` - Remark: ${browser.windowRemark}`);
2159
+ }
2160
+ return info.join("\n");
2161
+ }).join("\n\n");
2162
+ readable.push(browserList);
2163
+ if (totalPages > 1) {
2164
+ readable.push(`Pagination: page=${currentPage}, totalPages=${totalPages}, hasNext=${hasNextPage}`);
2165
+ }
2166
+ } else {
2167
+ readable.push(`No browsers found in workspace ${params.workspaceId}.`);
2168
+ }
2169
+ text = readable.join("\n\n");
2155
2170
  }
2156
2171
  return {
2157
2172
  content: [
@@ -2315,6 +2330,10 @@ var GetBrowserDetail = class {
2315
2330
  dirId: {
2316
2331
  type: "string",
2317
2332
  description: "Browser directory ID"
2333
+ },
2334
+ windowSortNum: {
2335
+ type: "string",
2336
+ description: "Filter by window `Serial No` (e.g. 1, 102)"
2318
2337
  }
2319
2338
  },
2320
2339
  required: ["workspaceId", "dirId"]
@@ -2340,6 +2359,14 @@ var GetBrowserDetail = class {
2340
2359
  const searchParams = new URLSearchParams();
2341
2360
  searchParams.append("workspaceId", params.workspaceId.toString());
2342
2361
  searchParams.append("dirId", params.dirId);
2362
+ if (params.windowSortNum) {
2363
+ if (params.windowSortNum.includes("-")) {
2364
+ const [_, serialNo] = params.windowSortNum.split("-").map((s) => s.trim());
2365
+ searchParams.append("windowSortNum", serialNo);
2366
+ } else {
2367
+ searchParams.append("windowSortNum", params.windowSortNum);
2368
+ }
2369
+ }
2343
2370
  const result = await request(`/browser/detail?${searchParams}`, {
2344
2371
  method: "GET"
2345
2372
  });
@@ -2772,26 +2799,10 @@ ${ws.project_details.map(
2772
2799
  };
2773
2800
  var HealthCheck = class {
2774
2801
  name = "roxy_health_check";
2775
- description = "Check if the target server is alive and healthy. This tool performs a health check to verify server connectivity and status.";
2802
+ description = "Check whether the RoxyBrowser server is running and reachable.";
2776
2803
  inputSchema = {
2777
2804
  type: "object",
2778
- properties: {
2779
- includeWorkspaceCheck: {
2780
- type: "boolean",
2781
- description: "Include workspace connectivity tests (optional, default: true)",
2782
- default: true
2783
- },
2784
- includeBrowserCheck: {
2785
- type: "boolean",
2786
- description: "Include browser availability checks (optional, default: true)",
2787
- default: true
2788
- },
2789
- verbose: {
2790
- type: "boolean",
2791
- description: "Include detailed diagnostic information (optional, default: false)",
2792
- default: false
2793
- }
2794
- }
2805
+ properties: {}
2795
2806
  };
2796
2807
  get schema() {
2797
2808
  return {
@@ -2800,126 +2811,19 @@ var HealthCheck = class {
2800
2811
  inputSchema: this.inputSchema
2801
2812
  };
2802
2813
  }
2803
- async handle(params) {
2804
- const { includeWorkspaceCheck = true, includeBrowserCheck = true, verbose = false } = params || {};
2805
- let healthStatus = "unknown";
2806
- let healthError = "";
2814
+ async handle(_params) {
2815
+ let text = "";
2807
2816
  try {
2808
- const healthResult = await request("/health", {
2817
+ const result = await request("/health", {
2809
2818
  method: "GET"
2810
2819
  });
2811
- if (healthResult.code === 0 || healthResult.code === void 0) {
2812
- healthStatus = "healthy";
2813
- } else {
2814
- healthStatus = "unhealthy";
2815
- healthError = healthResult.msg || "Health check failed";
2816
- }
2820
+ text = result.code === 0 ? "\u2705 **Server is healthy**\n\nThe RoxyBrowser server is running and reachable." : `\u274C **Server health check failed**
2821
+
2822
+ ${result.msg || "Unknown server response"}`;
2817
2823
  } catch (error) {
2818
- healthStatus = "unhealthy";
2819
- healthError = error.message || "Failed to connect to server";
2820
- }
2821
- let text = `## \u{1F50D} \u5065\u5EB7\u68C0\u67E5\u62A5\u544A / Health Check Report
2824
+ text = `\u274C **Server is unavailable**
2822
2825
 
2823
- `;
2824
- text += `### \u{1F310} \u670D\u52A1\u5668\u72B6\u6001 / Server Status
2825
- `;
2826
- text += `- **\u670D\u52A1\u5668\u8FDE\u63A5 / Server Connection**: ${healthStatus === "healthy" ? "\u2705 \u6B63\u5E38" : "\u274C \u5F02\u5E38"}
2827
- `;
2828
- if (healthStatus !== "healthy" && healthError) {
2829
- text += `- **\u9519\u8BEF\u4FE1\u606F / Error**: ${healthError}
2830
- `;
2831
- }
2832
- if (includeWorkspaceCheck && healthStatus === "healthy") {
2833
- try {
2834
- const workspaceResult = await request("/browser/workspace?page_index=1&page_size=5", {
2835
- method: "GET"
2836
- });
2837
- if (workspaceResult.code === 0) {
2838
- const workspaces = workspaceResult.data;
2839
- text += `
2840
- ### \u{1F4C1} \u5DE5\u4F5C\u533A\u4FE1\u606F / Workspace Information
2841
- `;
2842
- text += `- **\u53EF\u7528\u5DE5\u4F5C\u533A / Available Workspaces**: ${workspaces.total}
2843
- `;
2844
- if (workspaces.rows && workspaces.rows.length > 0) {
2845
- text += `- **\u5DE5\u4F5C\u533A\u8BE6\u60C5 / Workspace Details**:
2846
- `;
2847
- workspaces.rows.slice(0, 3).forEach((ws) => {
2848
- const projectCount = ws.project_details?.length || 0;
2849
- text += ` - ${ws.workspaceName} (ID: ${ws.id}) - ${projectCount} projects
2850
- `;
2851
- });
2852
- if (workspaces.total > 3) {
2853
- text += ` - ... and ${workspaces.total - 3} more
2854
- `;
2855
- }
2856
- }
2857
- } else {
2858
- text += `
2859
- ### \u{1F4C1} \u5DE5\u4F5C\u533A\u4FE1\u606F / Workspace Information
2860
- `;
2861
- text += `- **\u72B6\u6001**: \u26A0\uFE0F \u65E0\u6CD5\u83B7\u53D6\u5DE5\u4F5C\u533A\u4FE1\u606F
2862
- `;
2863
- text += `- **\u9519\u8BEF**: ${workspaceResult.msg}
2864
- `;
2865
- }
2866
- } catch (error) {
2867
- text += `
2868
- ### \u{1F4C1} \u5DE5\u4F5C\u533A\u4FE1\u606F / Workspace Information
2869
- `;
2870
- text += `- **\u72B6\u6001**: \u274C \u65E0\u6CD5\u83B7\u53D6\u5DE5\u4F5C\u533A\u4FE1\u606F
2871
- `;
2872
- text += `- **\u9519\u8BEF**: ${error.message || "Unknown error"}
2873
- `;
2874
- }
2875
- }
2876
- if (includeBrowserCheck && healthStatus === "healthy") {
2877
- try {
2878
- const workspaceResult = await request("/browser/workspace?page_index=1&page_size=1", {
2879
- method: "GET"
2880
- });
2881
- if (workspaceResult.code === 0 && workspaceResult.data.rows && workspaceResult.data.rows.length > 0) {
2882
- const firstWorkspace = workspaceResult.data.rows[0];
2883
- const browserResult = await request(`/browser/list_v3?workspaceId=${firstWorkspace.id}&page_index=1&page_size=5`, {
2884
- method: "GET"
2885
- });
2886
- if (browserResult.code === 0) {
2887
- const browsers = browserResult.data;
2888
- text += `
2889
- ### \u{1F310} \u6D4F\u89C8\u5668\u4FE1\u606F / Browser Information
2890
- `;
2891
- text += `- **\u5DE5\u4F5C\u533A / Workspace**: ${firstWorkspace.workspaceName} (ID: ${firstWorkspace.id})
2892
- `;
2893
- text += `- **\u6D4F\u89C8\u5668\u603B\u6570 / Total Browsers**: ${browsers.total}
2894
- `;
2895
- if (browsers.rows && browsers.rows.length > 0) {
2896
- text += `- **\u6D4F\u89C8\u5668\u793A\u4F8B / Browser Examples**:
2897
- `;
2898
- browsers.rows.slice(0, 3).forEach((browser) => {
2899
- text += ` - ${browser.windowName || "Unnamed"} (ID: ${browser.dirId}) - ${browser.status}
2900
- `;
2901
- });
2902
- }
2903
- }
2904
- }
2905
- } catch (error) {
2906
- text += `
2907
- ### \u{1F310} \u6D4F\u89C8\u5668\u4FE1\u606F / Browser Information
2908
- `;
2909
- text += `- **\u72B6\u6001**: \u26A0\uFE0F \u65E0\u6CD5\u83B7\u53D6\u6D4F\u89C8\u5668\u4FE1\u606F
2910
- `;
2911
- text += `- **\u9519\u8BEF**: ${error.message || "Unknown error"}
2912
- `;
2913
- }
2914
- }
2915
- if (verbose && healthStatus === "healthy") {
2916
- text += `
2917
- ### \u{1F4CA} \u8BE6\u7EC6\u4FE1\u606F / Detailed Information
2918
- `;
2919
- text += `- **\u5065\u5EB7\u68C0\u67E5\u65F6\u95F4 / Check Time**: ${(/* @__PURE__ */ new Date()).toISOString()}
2920
- `;
2921
- text += `- **\u68C0\u67E5\u6A21\u5F0F / Check Mode**: ${includeWorkspaceCheck ? "Workspace + " : ""}${includeBrowserCheck ? "Browser" : ""}
2922
- `;
2826
+ ${error?.message || "Failed to connect to the server"}`;
2923
2827
  }
2924
2828
  return {
2925
2829
  content: [
@@ -3079,8 +2983,7 @@ async function runServer() {
3079
2983
  const server = new RoxyBrowserMCPServer();
3080
2984
  await server.run();
3081
2985
  }
3082
-
3083
- // src/cli.ts
2986
+ dotenv.config();
3084
2987
  var PKG_VERSION = "1.0.9";
3085
2988
  var program = new Command();
3086
2989
  program.name("roxy-browser-mcp").description("RoxyBrowser MCP Server - Model Context Protocol server for RoxyBrowser automation").version(PKG_VERSION, "-V, --version", "Show version").option(