@evercam/mcp 0.0.3 → 0.0.4

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.
@@ -3,7 +3,7 @@ import { getProfileConfig } from "./profiles.js";
3
3
  import { getToken } from "../auth/tokenStore.js";
4
4
  export function resolveConfig(profileName) {
5
5
  const profile = getProfileConfig(profileName);
6
- const token = process.env.EVERCAM_TOKEN ?? getToken(profileName);
6
+ const token = process.env.EVERCAM_TOKEN || getToken(profileName);
7
7
  return {
8
8
  credentials: token ? { token } : undefined,
9
9
  baseUrls: {
@@ -1,12 +1,11 @@
1
1
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  /**
3
3
  * Call an MCP tool handler directly without going through a transport.
4
- * Used by the HTTP REST endpoint (POST /tools/:toolName).
4
+ * Used by the HTTP REST endpoint (POST /tools/:toolName) and the CLI `run` command.
5
5
  *
6
- * This function accesses private fields on McpServer (_registeredTools,
7
- * validateToolInput, executeToolHandler). These are undocumented internals.
8
- * Call validateCallToolInternals() at server startup to catch SDK version
9
- * breakage early rather than at runtime.
6
+ * Accesses _registeredTools on McpServer (undocumented but stable across v1.x).
7
+ * Each registered tool exposes `inputSchema` (Zod) and `callback`.
8
+ * Call validateCallToolInternals() at server startup to catch SDK version breakage early.
10
9
  */
11
10
  export declare function callToolDirect(server: McpServer, toolName: string, args: unknown): Promise<unknown>;
12
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"callTool.d.ts","sourceRoot":"","sources":["../../../src/utils/callTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAIxE;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CAsBlB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAajE"}
1
+ {"version":3,"file":"callTool.d.ts","sourceRoot":"","sources":["../../../src/utils/callTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAIxE;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CA6BlB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CASjE"}
@@ -2,12 +2,11 @@ import { withRetry } from "./retry.js";
2
2
  import { normalizeError } from "./errors.js";
3
3
  /**
4
4
  * Call an MCP tool handler directly without going through a transport.
5
- * Used by the HTTP REST endpoint (POST /tools/:toolName).
5
+ * Used by the HTTP REST endpoint (POST /tools/:toolName) and the CLI `run` command.
6
6
  *
7
- * This function accesses private fields on McpServer (_registeredTools,
8
- * validateToolInput, executeToolHandler). These are undocumented internals.
9
- * Call validateCallToolInternals() at server startup to catch SDK version
10
- * breakage early rather than at runtime.
7
+ * Accesses _registeredTools on McpServer (undocumented but stable across v1.x).
8
+ * Each registered tool exposes `inputSchema` (Zod) and `callback`.
9
+ * Call validateCallToolInternals() at server startup to catch SDK version breakage early.
11
10
  */
12
11
  export async function callToolDirect(server, toolName, args) {
13
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -17,10 +16,17 @@ export async function callToolDirect(server, toolName, args) {
17
16
  throw new Error(`Tool ${toolName} not found`);
18
17
  if (!tool.enabled)
19
18
  throw new Error(`Tool ${toolName} disabled`);
20
- const parsed = await internal.validateToolInput(tool, args, toolName);
19
+ let parsed = args;
20
+ if (tool.inputSchema) {
21
+ const parseResult = await tool.inputSchema.safeParseAsync(args);
22
+ if (!parseResult.success) {
23
+ throw new Error(`Invalid arguments for tool ${toolName}: ${parseResult.error.message}`);
24
+ }
25
+ parsed = parseResult.data;
26
+ }
21
27
  let result;
22
28
  try {
23
- result = await withRetry(() => internal.executeToolHandler(tool, parsed, {}));
29
+ result = await withRetry(() => tool.callback(parsed, {}));
24
30
  }
25
31
  catch (err) {
26
32
  const message = normalizeError(err).message;
@@ -39,16 +45,9 @@ export async function callToolDirect(server, toolName, args) {
39
45
  export function validateCallToolInternals(server) {
40
46
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
47
  const internal = server;
42
- const missing = [];
43
- if (typeof internal._registeredTools !== "object")
44
- missing.push("_registeredTools");
45
- if (typeof internal.validateToolInput !== "function")
46
- missing.push("validateToolInput");
47
- if (typeof internal.executeToolHandler !== "function")
48
- missing.push("executeToolHandler");
49
- if (missing.length > 0) {
50
- throw new Error(`MCP SDK private API changed — callTool.ts needs updating. Missing: ${missing.join(", ")}. ` +
51
- `Check @modelcontextprotocol/sdk release notes.`);
48
+ if (typeof internal._registeredTools !== "object") {
49
+ throw new Error(`MCP SDK private API changed — callTool.ts needs updating. ` +
50
+ `_registeredTools is missing. Check @modelcontextprotocol/sdk release notes.`);
52
51
  }
53
52
  }
54
53
  //# sourceMappingURL=callTool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"callTool.js","sourceRoot":"","sources":["../../../src/utils/callTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,QAAgB,EAChB,IAAa;IAEb,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,MAAa,CAAA;IAC9B,MAAM,IAAI,GAAG,QAAQ,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,CAAA;IAElD,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,YAAY,CAAC,CAAA;IACxD,IAAI,CAAC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AAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA;QAC3C,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;YAC9E,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAiB;IACzD,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,MAAa,CAAA;IAC9B,IAAI,OAAO,QAAQ,CAAC,gBAAgB,KAAK,QAAQ,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,4DAA4D;YAC1D,6EAA6E,CAChF,CAAA;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evercam/mcp",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "MCP server + CLI for Evercam — cameras, AI, copilot, analytics",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",