@uzqw/mcp 0.1.1 → 0.1.2

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/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { writeFileSync } from "fs";
8
8
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
9
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
10
  import open from "open";
11
- import { RecolxClient, runOAuthCallback, LoginInput, LogoutInput } from "@uzqw/shared";
11
+ import { RecolxClient, runOAuthCallback, LoginInput, LogoutInput, SetEnvInput, GetEnvInput } from "@uzqw/shared";
12
12
 
13
13
  // src/tools.ts
14
14
  import {
@@ -237,11 +237,12 @@ var CALLBACK_PORT = 8199;
237
237
  var LOGIN_TIMEOUT_MS = 12e4;
238
238
  var sub = process.argv[2];
239
239
  if (sub === "install" || sub === "uninstall") {
240
- const { runInstall, runUninstall } = await import("./install-2GRD6TZR.js");
240
+ const { runInstall, runUninstall, parseEnvFlag } = await import("./install-D7FNIM42.js");
241
241
  const args = process.argv.slice(3);
242
242
  const yes = args.includes("--yes") || args.includes("-y");
243
243
  const noLogin = args.includes("--no-login");
244
- if (sub === "install") await runInstall({ yes, noLogin });
244
+ const env = parseEnvFlag(args);
245
+ if (sub === "install") await runInstall({ yes, noLogin, env: env ?? void 0 });
245
246
  else await runUninstall({ yes });
246
247
  process.exit(0);
247
248
  }
@@ -252,6 +253,7 @@ if (sub === "--help" || sub === "-h") {
252
253
  recolx-mcp \u4EE5 stdio \u542F\u52A8 MCP server\uFF08Claude/Codex/Cursor/Zed \u7B49\u5BA2\u6237\u7AEF\u9ED8\u8BA4\u8DEF\u5F84\uFF09
253
254
  recolx-mcp install \u68C0\u6D4B\u5E76\u5199\u5165\u672C\u5730\u5BA2\u6237\u7AEF\u914D\u7F6E\uFF08Claude Desktop / Codex / Claude Code / Cursor / Windsurf / VS Code / Zed\uFF09
254
255
  recolx-mcp install --yes \u5168\u81EA\u52A8\uFF1A\u4E0D\u8BE2\u95EE\uFF0C\u76F4\u63A5\u914D\u7F6E\u6240\u6709\u68C0\u6D4B\u5230\u7684\u5BA2\u6237\u7AEF
256
+ recolx-mcp install --env local|staging|prod \u5207\u6362\u73AF\u5883\uFF08\u5199 ~/.recolx/config.json\uFF0C\u9ED8\u8BA4 prod\uFF09
255
257
  recolx-mcp install --no-login \u8DF3\u8FC7 OAuth \u767B\u5F55\uFF08CI / \u8DF3\u677F\u673A\uFF09
256
258
  recolx-mcp uninstall \u79FB\u9664\u5404\u5BA2\u6237\u7AEF\u91CC\u7684 recolx MCP \u914D\u7F6E
257
259
  `);
@@ -263,7 +265,7 @@ var READ_ONLY2 = { readOnlyHint: true, destructiveHint: false, openWorldHint: tr
263
265
  server.registerTool(
264
266
  "login",
265
267
  {
266
- description: "\u767B\u5F55 Recolx\uFF08OAuth PKCE\uFF09\uFF1A\u6253\u5F00\u6D4F\u89C8\u5668\u8DF3\u8F6C\u6388\u6743\u9875\uFF0C\u540C\u610F\u540E\u5728\u672C\u5730 8199 \u56DE\u8C03\u6536\u53D6 token \u5E76\u5199\u5165 ~/.recolx/tokens-mcp.json\uFF1B\u5DF2\u767B\u5F55\u65F6\u76F4\u63A5\u8FD4\u56DE",
268
+ description: "\u767B\u5F55 Recolx\uFF08OAuth PKCE\uFF09\uFF1A\u6253\u5F00\u6D4F\u89C8\u5668\u8DF3\u8F6C\u6388\u6743\u9875\uFF0C\u540C\u610F\u540E\u5728\u672C\u5730 8199 \u56DE\u8C03\u6536\u53D6 token \u5E76\u5199\u5165 ~/.recolx/tokens-mcp-{env}.json\uFF08\u6BCF\u73AF\u5883\u72EC\u7ACB\uFF09\uFF1B\u5DF2\u767B\u5F55\u65F6\u76F4\u63A5\u8FD4\u56DE",
267
269
  annotations: { title: "\u767B\u5F55 Recolx", ...READ_ONLY2 },
268
270
  inputSchema: LoginInput
269
271
  },
@@ -362,6 +364,42 @@ server.registerTool(
362
364
  }
363
365
  );
364
366
  registerTools(server, client);
367
+ var ENV_TOOL = { destructiveHint: false, openWorldHint: true };
368
+ server.registerTool(
369
+ "set_env",
370
+ {
371
+ description: "\u5207\u6362 Recolx \u73AF\u5883\uFF08local \u672C\u5730\u6D4B\u8BD5 / staging \u7EBF\u4E0A\u6D4B\u8BD5 / prod \u7EBF\u4E0A\u6B63\u5F0F\uFF09\uFF1A\u5199 ~/.recolx/config.json \u5E76\u5373\u65F6\u751F\u6548\uFF1B\u8FD4\u56DE\u65B0\u73AF\u5883\u3001\u540E\u7AEF\u5730\u5740\u4E0E\u767B\u5F55\u6001",
372
+ annotations: { title: "\u5207\u6362\u73AF\u5883", ...ENV_TOOL },
373
+ inputSchema: SetEnvInput
374
+ },
375
+ async ({ env }) => {
376
+ const state = await client.setEnv(env);
377
+ const login = state.logged_in ? "\u5DF2\u767B\u5F55" : "\u672A\u767B\u5F55\uFF08\u8BF7\u8FD0\u884C login\uFF09";
378
+ return { content: [{ type: "text", text: `\u5DF2\u5207\u6362\u5230 ${state.env}\uFF08${state.api_base}\uFF09\u3002${login}` }] };
379
+ }
380
+ );
381
+ server.registerTool(
382
+ "get_env",
383
+ {
384
+ description: "\u67E5\u770B\u5F53\u524D Recolx \u73AF\u5883\uFF08local/staging/prod\uFF09\u3001\u540E\u7AEF\u5730\u5740\u3001\u9274\u6743\u6A21\u5F0F\u4E0E\u767B\u5F55\u6001",
385
+ annotations: { title: "\u67E5\u770B\u73AF\u5883", ...READ_ONLY2 },
386
+ inputSchema: GetEnvInput
387
+ },
388
+ async () => {
389
+ const state = await client.getEnvState();
390
+ return {
391
+ content: [
392
+ {
393
+ type: "text",
394
+ text: `\u73AF\u5883\uFF1A${state.env}
395
+ \u540E\u7AEF\uFF1A${state.api_base}
396
+ \u9274\u6743\uFF1A${state.auth_mode}
397
+ \u767B\u5F55\uFF1A${state.logged_in ? "\u5DF2\u767B\u5F55" : "\u672A\u767B\u5F55"}`
398
+ }
399
+ ]
400
+ };
401
+ }
402
+ );
365
403
  try {
366
404
  const skills = await loadSkills();
367
405
  for (const skill of skills) {
@@ -12,12 +12,15 @@ import { dirname, join } from "path";
12
12
  import { spawnSync } from "child_process";
13
13
  import { createInterface } from "readline/promises";
14
14
  import open from "open";
15
- import { RecolxClient, DEFAULT_API_BASE, runOAuthCallback } from "@uzqw/shared";
15
+ import { RecolxClient, writeEnvConfig, runOAuthCallback } from "@uzqw/shared";
16
16
  var SERVER_NAME = "recolx";
17
17
  var CALLBACK_PORT = 8199;
18
18
  var LOGIN_TIMEOUT_MS = 12e4;
19
- function resolveApiBase() {
20
- return (process.env.RECOLX_API_BASE?.trim() || DEFAULT_API_BASE).replace(/\/+$/, "");
19
+ function parseEnvFlag(args) {
20
+ const i = args.indexOf("--env");
21
+ if (i === -1) return null;
22
+ const v = args[i + 1];
23
+ return v === "local" || v === "staging" || v === "prod" ? v : null;
21
24
  }
22
25
  function findNodeBinCommand(command) {
23
26
  const commandName = platform() === "win32" ? `${command}.cmd` : command;
@@ -34,7 +37,8 @@ function isLocalPackageSpec(spec) {
34
37
  function getMcpEntry() {
35
38
  const packageSpec = process.env.RECOLX_MCP_PACKAGE_SPEC?.trim() || "@uzqw/mcp@latest";
36
39
  const base = isLocalPackageSpec(packageSpec) ? { command: findNodeBinCommand("npm"), args: ["exec", "--yes", "--package", packageSpec, "--", "recolx-mcp"] } : { command: findNodeBinCommand("npx"), args: ["-y", packageSpec] };
37
- return { ...base, env: { RECOLX_API_BASE: resolveApiBase() } };
40
+ const env = process.env.RECOLX_API_BASE?.trim() ? { RECOLX_API_BASE: process.env.RECOLX_API_BASE.trim().replace(/\/+$/, "") } : {};
41
+ return { ...base, env };
38
42
  }
39
43
  function commandPathIsStale(command) {
40
44
  if (!command) return false;
@@ -558,6 +562,11 @@ function printNextSteps(clients, login) {
558
562
  }
559
563
  async function runInstall(opts = {}) {
560
564
  console.log("Recolx MCP installer\n");
565
+ if (opts.env) {
566
+ writeEnvConfig(opts.env);
567
+ console.log(`\u2192 \u73AF\u5883\u5DF2\u8BBE\u4E3A ${opts.env}\uFF08~/.recolx/config.json\uFF09
568
+ `);
569
+ }
561
570
  const clients = detectClients();
562
571
  console.log("\u68C0\u6D4B\u5230\u7684 AI \u5BA2\u6237\u7AEF\uFF1A");
563
572
  for (const c of clients) {
@@ -629,7 +638,7 @@ async function runUninstall(opts = {}) {
629
638
  }
630
639
  }
631
640
  console.log();
632
- console.log("\u5DF2\u6E05\u7406\u5BA2\u6237\u7AEF\u914D\u7F6E\u3002token \u6587\u4EF6 ~/.recolx/tokens-mcp.json \u4FDD\u7559\uFF08\u5982\u9700\u5F7B\u5E95\u79FB\u9664\u8BF7\u5220\u9664\u8BE5\u6587\u4EF6\uFF09\u3002");
641
+ console.log("\u5DF2\u6E05\u7406\u5BA2\u6237\u7AEF\u914D\u7F6E\u3002token \u6587\u4EF6 ~/.recolx/tokens-mcp-*.json \u4FDD\u7559\uFF08\u5982\u9700\u5F7B\u5E95\u79FB\u9664\u8BF7\u5220\u9664\u8BE5\u76EE\u5F55\uFF09\u3002");
633
642
  }
634
643
  export {
635
644
  CALLBACK_PORT,
@@ -642,7 +651,7 @@ export {
642
651
  extractTomlEnv,
643
652
  getMcpEntry,
644
653
  normalizeWindowsPath,
645
- resolveApiBase,
654
+ parseEnvFlag,
646
655
  runInstall,
647
656
  runUninstall
648
657
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uzqw/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Recolx read-only MCP server (stdio) — 7 read-only tools, readOnlyHint: true",
5
5
  "mcpName": "io.github.uzqw/recolx-mcp",
6
6
  "publishConfig": {