@crush-protocol/mcp-client 0.3.2 → 0.3.3

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.
@@ -7,6 +7,7 @@ import path from "node:path";
7
7
  const DEFAULT_SCOPE = "mcp:tools";
8
8
  const DEFAULT_REDIRECT_PORT = 8787;
9
9
  const DEFAULT_REDIRECT_PATH = "/oauth/callback";
10
+ const escapeHtml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
10
11
  const renderCallbackHtml = (title, message) => `<!DOCTYPE html>
11
12
  <html lang="en">
12
13
  <head>
@@ -44,8 +45,8 @@ const renderCallbackHtml = (title, message) => `<!DOCTYPE html>
44
45
  </head>
45
46
  <body>
46
47
  <main>
47
- <h1>${title}</h1>
48
- <p>${message}</p>
48
+ <h1>${escapeHtml(title)}</h1>
49
+ <p>${escapeHtml(message)}</p>
49
50
  </main>
50
51
  </body>
51
52
  </html>`;
@@ -188,7 +189,7 @@ export class InteractiveOAuthProvider {
188
189
  }
189
190
  async saveState(data) {
190
191
  await mkdir(path.dirname(this.storageFile), { recursive: true });
191
- await writeFile(this.storageFile, JSON.stringify(data, null, 2), "utf8");
192
+ await writeFile(this.storageFile, JSON.stringify(data, null, 2), { encoding: "utf8", mode: 0o600 });
192
193
  }
193
194
  createPendingAuthorization() {
194
195
  let resolve;
@@ -2,6 +2,7 @@ import { auth, UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.j
2
2
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
3
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
4
4
  import { InteractiveOAuthProvider } from "./oauthProvider.js";
5
+ import { CLIENT_NAME, CLIENT_VERSION } from "./version.js";
5
6
  export class OAuthRemoteMcpClient {
6
7
  options;
7
8
  client;
@@ -10,8 +11,8 @@ export class OAuthRemoteMcpClient {
10
11
  constructor(options) {
11
12
  this.options = options;
12
13
  this.client = new Client({
13
- name: options.clientName ?? "crush-mcp-client",
14
- version: options.clientVersion ?? "0.2.0",
14
+ name: options.clientName ?? CLIENT_NAME,
15
+ version: options.clientVersion ?? CLIENT_VERSION,
15
16
  }, {
16
17
  capabilities: {},
17
18
  });
@@ -1,5 +1,6 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
3
+ import { CLIENT_NAME, CLIENT_VERSION } from "./version.js";
3
4
  export class RemoteMcpClient {
4
5
  client;
5
6
  transport;
@@ -8,8 +9,8 @@ export class RemoteMcpClient {
8
9
  throw new Error("Invalid token. Expected a non-empty OAuth access token");
9
10
  }
10
11
  this.client = new Client({
11
- name: options.clientName || "crush-mcp-client",
12
- version: options.clientVersion || "0.1.0",
12
+ name: options.clientName || CLIENT_NAME,
13
+ version: options.clientVersion || CLIENT_VERSION,
13
14
  }, {
14
15
  capabilities: {},
15
16
  });
@@ -0,0 +1,3 @@
1
+ /** 从 package.json 动态读取的客户端版本号 */
2
+ export declare const CLIENT_VERSION: string;
3
+ export declare const CLIENT_NAME = "crush-mcp-client";
@@ -0,0 +1,6 @@
1
+ import { createRequire } from "node:module";
2
+ const require = createRequire(import.meta.url);
3
+ const pkg = require("../../package.json");
4
+ /** 从 package.json 动态读取的客户端版本号 */
5
+ export const CLIENT_VERSION = pkg.version;
6
+ export const CLIENT_NAME = "crush-mcp-client";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crush-protocol/mcp-client",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Crush MCP npm client package (remote Streamable HTTP + optional ClickHouse direct)",
5
5
  "type": "module",
6
6
  "license": "MIT",