MCPcopy
hub / github.com/Doorman11991/smallcode / _normalize

Function _normalize

src/tools/tool_call_extractor.js:188–200  ·  view source on GitHub ↗
(parsed, knownNames)

Source from the content-addressed store, hash-verified

186// Filters out entries that don't reference a known tool, when we have a
187// known-tool list. Without a list, accepts anything name-shaped.
188function _normalize(parsed, knownNames) {
189 if (!parsed) return [];
190 const items = Array.isArray(parsed) ? parsed : [parsed];
191 const out = [];
192 for (const item of items) {
193 if (!item || typeof item !== 'object') continue;
194 const tc = _coerceOne(item);
195 if (!tc) continue;
196 if (knownNames.size > 0 && !knownNames.has(tc.name)) continue;
197 out.push(tc);
198 }
199 return out;
200}
201
202function _coerceOne(item) {
203 // Form A: { name, arguments }

Callers 1

extractFromMessageFunction · 0.85

Calls 2

_coerceOneFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected