Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Refuse a misspelled scope or filter only when the read declares that scope or filter
garrytan383a1b9d0945
diff --git a/src/mcp/validate-params.ts b/src/mcp/validate-params.tsindex 5922eba6ab..080b604dd6 100644--- a/src/mcp/validate-params.ts+++ b/src/mcp/validate-params.ts@@ -245,11 +245,12 @@ function isNarrowingName(name: string): boolean {/*** GBRA-431: the unknown keys a read must refuse whatever `mcp.strict_params` says, because ignoring them answers- * unnarrowed: a key whose own name, or whose nearest declared param, is a scope or filter (`source` for- * `source_id`, `sources` for `source_ids`, `type` for `types`). Other unknown keys keep the warn grace period.+ * unnarrowed: a key whose nearest declared param is a scope or filter of this op (`source` for `source_id`, `sources`+ * for `source_ids`, `type` for `types`). An op that declares no such param cannot narrow, so a scope key sent to it+ * (a client adding `source_id` to every call) keeps the warn grace period like any other unknown key.*/export function narrowingUnknownParams(warnings: readonly UnknownParamWarning[]): UnknownParamWarning[] {- return warnings.filter(w => isNarrowingName(w.param) || (w.suggestion !== undefined && isNarrowingName(w.suggestion)));+ return warnings.filter(w => w.suggestion !== undefined && isNarrowingName(w.suggestion));}/**diff --git a/test/validate-params.test.ts b/test/validate-params.test.tsindex 2f7c1d79dd..9c47c6eb7c 100644--- a/test/validate-params.test.ts+++ b/test/validate-params.test.ts@@ -528,11 +528,17 @@ describe('a read rejects an unknown scope or filter parameter even in warn mode});});- test('narrowingUnknownParams picks scope and filter names, by the key or by its nearest declared param', () => {+ test('narrowingUnknownParams picks keys whose nearest declared param is a scope or filter of the op', () => {expect(narrowingUnknownParams([- { code: 'unknown_param', param: 'source' }, { code: 'unknown_param', param: 'Source-IDs' },- { code: 'unknown_param', param: 'srcid', suggestion: 'source_id' }, { code: 'unknown_param', param: 'tag' },+ { code: 'unknown_param', param: 'source', suggestion: 'source_id' }, { code: 'unknown_param', param: 'Source-IDs', suggestion: 'source_ids' },+ { code: 'unknown_param', param: 'srcid', suggestion: 'source_id' }, { code: 'unknown_param', param: 'tag', suggestion: 'types' },{ code: 'unknown_param', param: 'limt', suggestion: 'limit' }, { code: 'unknown_param', param: 'partal', suggestion: 'partial' },]).map(w => w.param)).toEqual(['source', 'Source-IDs', 'srcid', 'tag']);});++ test('a scope key sent to an op that declares no scope param keeps the warn grace period', () => {+ expect(narrowingUnknownParams([+ { code: 'unknown_param', param: 'source_id' }, { code: 'unknown_param', param: 'source_id', suggestion: 'request_id' },+ ])).toEqual([]);+ });});