@cloudhal/mcp-server 0.7.0 → 0.7.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.
@@ -16,6 +16,7 @@ import {
16
16
  resolveChrome,
17
17
 
18
18
  } from "@cloudhal/core-ts/chrome";
19
+ import { isReservedKey } from "@cloudhal/core-ts/names";
19
20
  import { id, mapError, obj, ToolError } from "./common.js";
20
21
 
21
22
  async function requireSite(ctx , siteId ) {
@@ -24,12 +25,18 @@ async function requireSite(ctx , siteId ) {
24
25
  return site;
25
26
  }
26
27
 
27
- /** `patch` onto `current`: a value replaces the part, null removes it. */
28
+ /**
29
+ * `patch` onto `current`: a value replaces the part, null removes it. A reserved key
30
+ * (`__proto__`, `constructor`, `prototype`) is refused: JSON input can carry `__proto__` as an own
31
+ * key, and assigning it would swap the part's prototype instead of setting a field.
32
+ */
28
33
  function merge (current , patch ) {
29
34
  const out = { ...(current ?? {}) };
30
- for (const [k, v] of Object.entries(patch))
35
+ for (const [k, v] of Object.entries(patch)) {
36
+ if (isReservedKey(k)) throw new ToolError("invalid", `"${k}" is a reserved key`);
31
37
  if (v === null) delete out[k];
32
38
  else out[k] = v;
39
+ }
33
40
  return out ;
34
41
  }
35
42
 
@@ -13,7 +13,11 @@ type Values = Record<string, unknown>;
13
13
  export declare const FIELDS_INPUT: JsonSchema;
14
14
  /** `update_entry`'s `fields`: a merge patch. */
15
15
  export declare const FIELDS_PATCH: JsonSchema;
16
- /** The stored `fields` with `patch` applied: `null` removes a key. */
16
+ /**
17
+ * The stored `fields` with `patch` applied: `null` removes a key. A reserved key (`__proto__`,
18
+ * `constructor`, `prototype`) is refused, also for collections without field definitions: JSON
19
+ * input can carry `__proto__` as an own key, and assigning it would swap the object's prototype.
20
+ */
17
21
  export declare function mergeFields(current: Values | undefined, patch: Values): Values;
18
22
  /** What an entry write would store, for the check. */
19
23
  export interface FieldsCheck {
@@ -18,7 +18,8 @@ import {
18
18
  refuseFieldIssues,
19
19
  } from "@cloudhal/core-ts/fields";
20
20
  import { fieldAssetIssues, fieldAssetRefs } from "@cloudhal/core-ts/media";
21
- import { quote, } from "./common.js";
21
+ import { isReservedKey } from "@cloudhal/core-ts/names";
22
+ import { quote, ToolError } from "./common.js";
22
23
 
23
24
 
24
25
 
@@ -36,10 +37,15 @@ export const FIELDS_PATCH = {
36
37
  "Typed custom fields to change, as a merge patch: given keys are set, null removes a key, others stay. The collection's fieldsSchema (list_collections) lists the keys and allowed values.",
37
38
  };
38
39
 
39
- /** The stored `fields` with `patch` applied: `null` removes a key. */
40
+ /**
41
+ * The stored `fields` with `patch` applied: `null` removes a key. A reserved key (`__proto__`,
42
+ * `constructor`, `prototype`) is refused, also for collections without field definitions: JSON
43
+ * input can carry `__proto__` as an own key, and assigning it would swap the object's prototype.
44
+ */
40
45
  export function mergeFields(current , patch ) {
41
46
  const next = { ...(current ?? {}) };
42
47
  for (const [key, value] of Object.entries(patch)) {
48
+ if (isReservedKey(key)) throw new ToolError("invalid", `fields: "${key}" is a reserved key`);
43
49
  if (value === null) delete next[key];
44
50
  else next[key] = value;
45
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudhal/mcp-server",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Cloudhal MCP server: semantic site tools (pages, articles, snapshots, preview, publish) governed by the policy engine",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://cloudhal.dev",
@@ -56,15 +56,15 @@
56
56
  "README.md"
57
57
  ],
58
58
  "dependencies": {
59
- "@cloudhal/analytics": "0.7.0",
60
- "@cloudhal/agent-runtime": "0.7.0",
61
- "@cloudhal/astro-renderer": "0.7.0",
62
- "@cloudhal/comments": "0.7.0",
63
- "@cloudhal/core-contracts": "0.7.0",
64
- "@cloudhal/core-ts": "0.7.0",
65
- "@cloudhal/storage": "0.7.0",
59
+ "@cloudhal/analytics": "0.7.1",
60
+ "@cloudhal/agent-runtime": "0.7.1",
61
+ "@cloudhal/astro-renderer": "0.7.1",
62
+ "@cloudhal/comments": "0.7.1",
63
+ "@cloudhal/core-contracts": "0.7.1",
64
+ "@cloudhal/core-ts": "0.7.1",
65
+ "@cloudhal/storage": "0.7.1",
66
66
  "@modelcontextprotocol/server": "2.3.1",
67
- "@cloudhal/schedules": "0.7.0"
67
+ "@cloudhal/schedules": "0.7.1"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@cloudflare/workers-types": "^5.20261007.1",