Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(mcp): core reads in ops/pages.ts and ops/search.ts carry explicit mutating:false, so tools/list marks them read-only (#5037)

garrytan4d53c7cf551e
diff --git a/src/core/ops/pages.ts b/src/core/ops/pages.ts
index 151bc26075..55a197b85e 100644
--- a/src/core/ops/pages.ts
+++ b/src/core/ops/pages.ts
@@ -204,7 +204,7 @@ const get_page: Operation = {
...(content_flag ? { content_flag } : {}),
};
},
- scope: 'read',
+ scope: 'read', mutating: false,
cliHints: { name: 'get', positional: ['slug'] },
};
@@ -275,7 +275,7 @@ const fetch_page: Operation = {
},
};
},
- scope: 'read',
+ scope: 'read', mutating: false,
cliHints: { name: 'fetch', positional: ['id'] },
};
@@ -584,7 +584,7 @@ const list_pages: Operation = {
...(pg.deleted_at ? { deleted_at: pg.deleted_at } : {}),
}));
},
- scope: 'read',
+ scope: 'read', mutating: false,
cliHints: { name: 'list' },
};
diff --git a/src/core/ops/search.ts b/src/core/ops/search.ts
index 762d450d6b..cc4cd77bf9 100644
--- a/src/core/ops/search.ts
+++ b/src/core/ops/search.ts
@@ -449,7 +449,7 @@ const search: Operation = {
return evidenceOutput(ctx, p, results, plan, { ...scope, excludePrivate }, capturedMeta, snippetCap,
rows => buildRetrievalResponseMeta(ctx, scope, queryText, rows, capturedMeta, { conceptHint: true, types }));
},
- scope: 'read',
+ scope: 'read', mutating: false,
cliHints: { name: 'search', positional: ['query'] },
};
@@ -898,7 +898,7 @@ const query: Operation = {
return evidenceOutput(ctx, p, results, plan, { ...querySourceScope, excludePrivate, detail }, capturedMeta, snippetCap,
async rows => ({ ...(await buildRetrievalResponseMeta(ctx, querySourceScope, queryText, rows, capturedMeta, { types })), crag }));
},
- scope: 'read',
+ scope: 'read', mutating: false,
cliHints: { name: 'query', positional: ['query'] },
};
@@ -925,7 +925,7 @@ const assemble_evidence: Operation = {
token_budget: { type: 'number', description: 'Token budget for the delivered evidence (default search.return_budget_default = 6000, auto search.return_budget_conversation = 24000; remote max 32000).' },
detail: { type: 'string', enum: ['low', 'medium', 'high'], description: "As query: 'low' delivers compiled truth only (no timeline text)." },
},
- scope: 'read',
+ scope: 'read', mutating: false,
annotations: { title: 'assemble evidence', readOnlyHint: true },
handler: async (ctx, p) => {
const hits = p.hits;
@@ -1013,7 +1013,7 @@ const search_modes: Operation = {
'the payload spells this out). Never mutates; to change modes, tell the user to set the ' +
'search.mode config key on the brain host.',
params: {},
- scope: 'read',
+ scope: 'read', mutating: false,
area: 'search',
handler: async (ctx) => {
const { buildModesReport, redactReadinessForRemote } = await import('../search/modes-report.ts');
diff --git a/test/mcp-tool-defs.test.ts b/test/mcp-tool-defs.test.ts
index 4bbe9bf2d2..2ad38967bf 100644
--- a/test/mcp-tool-defs.test.ts
+++ b/test/mcp-tool-defs.test.ts
@@ -112,6 +112,10 @@ describe('buildToolDefs', () => {
expect(defs.get('put_page')?.annotations).toEqual({ readOnlyHint: false });
expect(defs.get('edit_page')?.annotations).toEqual({ readOnlyHint: false });
expect(defs.get('recall')?.annotations?.readOnlyHint).toBe(true);
+ // The core reads in ops/pages.ts and ops/search.ts carry explicit tags, so agents see them as read-only.
+ for (const name of ['get_page', 'fetch', 'list_pages', 'search', 'query', 'assemble_evidence', 'search_modes']) {
+ expect({ name, readOnlyHint: defs.get(name)?.annotations?.readOnlyHint }).toEqual({ name, readOnlyHint: true });
+ }
for (const op of operations) {
if (op.mutating === true && !op.annotations) expect(defs.get(op.name)?.annotations?.readOnlyHint).toBe(false);
}