# Declared fields and rules check for an MCP connector Version 1.0, November 26, 2026. Companion guide: https://jwatte.com/blog/change-live-mcp-connector-without-breaking-it/ (section "What ChatGPT passes to the model, and what a rule in the answer can and cannot do") Written by J.A. Watte, jwatte.com. Free to copy, adapt and ship. No attribution required. One page for a release: check that every notice reaches the model in a client that passes only declared fields, imitate that client before you ship, and know what a rule sentence in the answer can and cannot do. Use it with your developer, or paste it to an AI coding agent as its brief. Replace every ALL-CAPS placeholder. Test only servers you operate. ## 1. What we saw - **In our chats, ChatGPT passed the model only the top-level fields the tool's `outputSchema` declares.** A link returned under an undeclared top-level key never reached the customer, in either language, although the tool was called. Moved into a declared string field, it did. - **Claude Code fails differently:** when a tool declared an `outputSchema`, it passed the model the `structuredContent` JSON, not the text block. So put every notice in a declared structured field **and** in the text block. - **Server instructions did not hold a pricing rule in ChatGPT.** The facts were right, but in 5 of 7 chats it split weekly or monthly rates into figures per night, per day or per person, or multiplied them into longer totals, once with an assumed tax exemption. Claude, on the same server, did not. - **A rule sentence inside the declared fields of every rate answer fixed the volunteered arithmetic.** It did not stop arithmetic the customer asked for (section 5). ## 2. Before every release: the projection test For every tool, every language and every refusal or fallback that carries a notice, keep only the declared top-level keys of each result and check that each notice survives. Read the schemas from your own `tools/list`, sent with the `MCP-Protocol-Version` header that real clients send (some servers declare output schemas only to clients that send it). - [ ] `calls.json` lists every tool, in every language you serve, including the arguments that produce a refusal or a fallback. - [ ] `notices.json` lists each notice with a pattern that marks the answers that need it (for a rate rule: any answer with a price, an estimate or a total). - [ ] The run prints `N of N`, and the list of undeclared keys holds nothing the customer needs. - [ ] Run it on the draft and on production. Production failing and the draft passing is the release you want. ```javascript // projection-check.mjs: keep only the top-level fields each tool's outputSchema declares (what ChatGPT passes to the // model) and check that every notice survives, in the declared fields and in the text block. // usage: node projection-check.mjs ENDPOINT calls.json notices.json [PROTOCOL_VERSION] // calls.json: [{"name":"TOOL_NAME","arguments":{"ARG":"VALUE"}}, ...] every tool, every language, refusals too // notices.json: [{"when":"REGEX_THAT_MARKS_AN_ANSWER_NEEDING_IT","notice":"EXACT SENTENCE"}, ...] // Node 18 or later, no dependencies. Read-only tools only. Paced at one request per 400 ms. import { readFileSync } from 'node:fs'; const [EP, CALLS, NOTICES, PV = '2025-06-18'] = process.argv.slice(2); if (!NOTICES) { console.error('usage: node projection-check.mjs ENDPOINT calls.json notices.json [PROTOCOL_VERSION]'); process.exit(2); } const calls = JSON.parse(readFileSync(CALLS, 'utf8')); const notices = JSON.parse(readFileSync(NOTICES, 'utf8')).map((n) => ({ re: new RegExp(n.when), notice: n.notice, matched: 0 })); let session = '', id = 0, last = 0; async function rpc(method, params, notify = false) { const wait = last + 400 - Date.now(); if (wait > 0) await new Promise((r) => setTimeout(r, wait)); last = Date.now(); const headers = { 'content-type': 'application/json', accept: 'application/json, text/event-stream', 'mcp-protocol-version': PV }; if (session) headers['mcp-session-id'] = session; const body = notify ? { jsonrpc: '2.0', method } : { jsonrpc: '2.0', id: ++id, method, params }; const r = await fetch(EP, { method: 'POST', headers, body: JSON.stringify(body), signal: AbortSignal.timeout(30000) }); session = r.headers.get('mcp-session-id') || session; const t = await r.text(); if (notify) return null; const data = t.split('\n').filter((l) => l.startsWith('data:')).map((l) => l.slice(5)).join('') || t; const j = JSON.parse(data); if (j.error) throw new Error(`${method}: ${JSON.stringify(j.error)}`); return j.result; } const declared = (s) => { const k = new Set(Object.keys(s?.properties || {})); for (const b of [...(s?.anyOf || []), ...(s?.oneOf || [])]) for (const x of Object.keys(b.properties || {})) k.add(x); return k; }; await rpc('initialize', { protocolVersion: PV, capabilities: {}, clientInfo: { name: 'projection-check', version: '1.0' } }); await rpc('notifications/initialized', {}, true); const schemas = Object.fromEntries((await rpc('tools/list', {})).tools.map((t) => [t.name, t.outputSchema])); let needed = 0, kept = 0; const fails = [], dropped = new Set(); for (const c of calls) { if (!(c.name in schemas)) { fails.push(`${c.name}: not in tools/list`); continue; } const r = await rpc('tools/call', { name: c.name, arguments: c.arguments || {} }); const full = JSON.stringify(r); const keys = schemas[c.name] ? declared(schemas[c.name]) : null; const sc = r.structuredContent || {}; const projected = keys ? Object.fromEntries(Object.entries(sc).filter(([k]) => keys.has(k))) : sc; if (keys) for (const k of Object.keys(sc)) if (!keys.has(k)) dropped.add(`${c.name}.${k}`); const text = (r.content || []).filter((b) => b.type === 'text').map((b) => b.text).join('\n'); for (const n of notices) { if (!n.re.test(full)) continue; needed++; n.matched++; const inDeclared = JSON.stringify(projected).includes(JSON.stringify(n.notice).slice(1, -1)); const inText = text.includes(n.notice); if (inDeclared && inText) kept++; else fails.push(`${c.name} ${JSON.stringify(c.arguments || {})}: notice "${n.notice.slice(0, 40)}..." declared=${inDeclared} text=${inText}`); } } for (const n of notices) if (!n.matched) fails.push(`notice "${n.notice.slice(0, 40)}...": its "when" pattern matched no result, so nothing was checked (fix the pattern or calls.json)`); for (const f of fails) console.log('FAIL ' + f); console.log(`undeclared top-level keys a client like ChatGPT drops: ${[...dropped].join(', ') || 'none'}`); console.log(`${kept} of ${needed} answers that need a notice keep it after projection (${calls.length} calls)`); process.exit(fails.length ? 1 : 0); ``` ```bash node projection-check.mjs https://DRAFT_HOST/mcp calls.json notices.json 2025-06-18 ``` ## 3. The rule-sentence pattern When a client may skip your server instructions, a rule the model must follow belongs in the answer it applies to. - [ ] One short sentence, in the answer's language. - [ ] In **every** answer that carries what the rule is about (every tool, refusals and fallbacks too, and the fact sheets), not only in the main tool. - [ ] The last line of a declared text field **and** the last item of a declared notes list, so it survives in both clients. - [ ] For prices, the sentence covers four points: the figures are repeated the way the tool states them; they are not broken down into per-night, per-day or per-person amounts; they are not scaled up to a total for a longer stay; and no tax exemption is taken for granted. It ends by saying who settles the rest. A TEMPLATE to adapt in your own words: "PRICE_NOUN in this answer stand exactly as stated here. Keep them whole: no figure per UNIT_LIST, and no total for a stay past STAY_LIMIT built from them. Tax relief is never automatic; CONTACT_ROLE confirms longer stays and any exemption." Asking for the figures exactly as stated still lets the model pass on an estimate the tool did give as the total. - [ ] If a listing is in review: change only tool results, inside the definitions already published. Keep `initialize`, `tools/list`, `resources/list` and `prompts/list` byte-identical (compare them in each protocol header mode), because a changed definition or instructions text can be held at the older version. Submit the instructions or schema change after the review ends, as a normal update for review; this step is not a way around a review. - [ ] Compare production and draft answers call by call: every difference must be the rule, and no figure may change. ## 4. Before release: a stand-in that imitates ChatGPT A test through Claude alone can pass while ChatGPT fails, because Claude reads the server instructions. This small local proxy sits between a model client and your server, cuts every tool result to its declared top-level keys, and with `noinstr` also deletes the server instructions. Run the model client exactly as in the companion kit https://jwatte.com/downloads/mcp-model-in-the-loop-test.md (section 3: read-only tools only, other tools disallowed), with `mcp-test.json` pointing at the stand-in. The stand-in forwards only read-only MCP methods. It lists and calls only tools whose `tools/list` annotations say `readOnlyHint: true`, and refuses any other tool call without forwarding it. Keep the client restriction anyway: an annotation is only as good as your server's own marking. ```javascript // declared-proxy.mjs: a local stand-in for what ChatGPT passes to the model. It sits between a model client and your // server, cuts every tools/call result to the top-level keys the tool's outputSchema declares, and with "noinstr" // also deletes the server instructions from initialize. Read-only MCP methods only. Only tools whose tools/list // annotations say readOnlyHint: true are listed to the client or called; any other tool call is refused here and // never reaches your server. One upstream call per 400 ms. // usage: node declared-proxy.mjs UPSTREAM_ENDPOINT PORT LOG.jsonl [noinstr] // then point the model client at http://127.0.0.1:PORT/ Node 18 or later, no dependencies. Listens on 127.0.0.1 only. import http from 'node:http'; import { appendFileSync } from 'node:fs'; const [UP, PORT, LOG, MODE] = process.argv.slice(2); if (!LOG) { console.error('usage: node declared-proxy.mjs UPSTREAM_ENDPOINT PORT LOG.jsonl [noinstr]'); process.exit(2); } const READ = new Set(['initialize', 'notifications/initialized', 'tools/list', 'tools/call', 'resources/list', 'resources/read', 'resources/templates/list', 'prompts/list', 'prompts/get', 'ping']); let last = 0, tools = null; const gap = async () => { const w = last + 400 - Date.now(); if (w > 0) await new Promise((r) => setTimeout(r, w)); last = Date.now(); }; const declared = (s) => { const k = new Set(Object.keys(s?.properties || {})); for (const b of [...(s?.anyOf || []), ...(s?.oneOf || [])]) for (const x of Object.keys(b.properties || {})) k.add(x); return k; }; const remember = (list) => { tools = Object.fromEntries(list.map((t) => [t.name, { schema: t.outputSchema, readOnly: t.annotations?.readOnlyHint === true }])); }; async function up(msg, h) { await gap(); const headers = { 'content-type': 'application/json', accept: 'application/json, text/event-stream', 'mcp-protocol-version': h['mcp-protocol-version'] || '2025-06-18' }; if (h['mcp-session-id']) headers['mcp-session-id'] = h['mcp-session-id']; const r = await fetch(UP, { method: 'POST', headers, body: JSON.stringify(msg), signal: AbortSignal.timeout(30000) }); const t = await r.text(); const data = t.split('\n').filter((l) => l.startsWith('data:')).map((l) => l.slice(5)).join('') || t; return { status: r.status, session: r.headers.get('mcp-session-id'), text: data.trim() }; } http.createServer(async (req, res) => { try { const chunks = []; for await (const c of req) chunks.push(c); if (req.method !== 'POST') { res.writeHead(405, { allow: 'POST' }); return res.end(); } const msg = JSON.parse(Buffer.concat(chunks).toString() || 'null'); if (!msg || Array.isArray(msg) || !READ.has(msg.method)) { res.writeHead(403); return res.end('{"error":"refused by the read-only stand-in"}'); } const entry = { at: new Date().toISOString(), method: msg.method, name: msg.params?.name, args: msg.params?.arguments }; if (msg.method === 'tools/call') { if (!tools) remember(JSON.parse((await up({ jsonrpc: '2.0', id: 'stand-in', method: 'tools/list', params: {} }, req.headers)).text).result.tools); if (!tools[msg.params?.name]?.readOnly) { entry.refused = 'not a tool with readOnlyHint: true'; appendFileSync(LOG, JSON.stringify(entry) + '\n'); res.writeHead(200, { 'content-type': 'application/json' }); return res.end(JSON.stringify({ jsonrpc: '2.0', id: msg.id, error: { code: -32601, message: 'refused by the read-only stand-in: this tool is not marked readOnlyHint: true' } })); } } const u = await up(msg, req.headers); const sid = u.session ? { 'mcp-session-id': u.session } : {}; if (!u.text) { res.writeHead(u.status, sid); return res.end(); } const j = JSON.parse(u.text); if (msg.method === 'initialize' && MODE === 'noinstr' && j.result) { delete j.result.instructions; entry.instructionsWithheld = true; } if (msg.method === 'tools/list' && j.result) { remember(j.result.tools); entry.hidden = j.result.tools.filter((t) => !tools[t.name].readOnly).map((t) => t.name); j.result = { ...j.result, tools: j.result.tools.filter((t) => tools[t.name].readOnly) }; } if (msg.method === 'tools/call' && j.result?.structuredContent) { const s = tools[msg.params.name].schema; if (s) { const keys = declared(s), sc = j.result.structuredContent; const kept = Object.fromEntries(Object.entries(sc).filter(([k]) => keys.has(k))); entry.dropped = Object.keys(sc).filter((k) => !keys.has(k)); j.result = { ...j.result, structuredContent: kept, content: [{ type: 'text', text: JSON.stringify(kept) }] }; } entry.result = j.result; } appendFileSync(LOG, JSON.stringify(entry) + '\n'); res.writeHead(200, { 'content-type': 'application/json', ...sid }); res.end(JSON.stringify(j)); } catch (e) { res.writeHead(502); res.end(JSON.stringify({ error: String(e.message || e) })); } }).listen(Number(PORT), '127.0.0.1', () => console.log(`stand-in on http://127.0.0.1:${PORT}/ -> ${UP}${MODE === 'noinstr' ? ' (instructions withheld)' : ''}`)); ``` ```bash node declared-proxy.mjs https://DRAFT_HOST/mcp 8790 standin-log.jsonl noinstr & # mcp-test.json: { "mcpServers": { "SERVER_NAME": { "type": "http", "url": "http://127.0.0.1:8790/" } } } ``` - [ ] Run the price questions customers ask, with instructions withheld and with them present, on the old build and on the new one. In our run the old build with instructions withheld failed 4 of 5 and 5 of 5 on two models, matching the ChatGPT figures almost exactly. The new build failed none. With instructions present, both builds passed. - [ ] Caveat: this is a Claude model imitating ChatGPT's projection, not ChatGPT. The real walk in ChatGPT after release is the proof. ## 5. The limit, and how to score it A rule sentence stops the assistant from **volunteering** arithmetic. When the customer **asks** for it ("what is that per night and per person?", "what would three months cost?"), ChatGPT still calculated it on a fast model and on a medium thinking setting, labeled it as its own estimate, said the business must confirm, and hedged the tax exemption. Once it assumed the monthly rate could be prorated. Asked, it said it had not followed the note because the customer requested the calculations. Score the two kinds of question apart. `figures.mjs` lists the money figures in an answer that no tool result contains: ```javascript // figures.mjs: list every money figure in a model's answer that no tool result contains (arithmetic the model did itself). // usage: node figures.mjs RUN.jsonl [plain|asked] (RUN.jsonl: Claude Code --output-format stream-json --verbose) // plain: the customer did not ask for a split or a longer total, so any figure of the model's own is VOLUNTEERED (FAIL). // asked: the customer asked for it; the figures are listed for a person to read against the rubric (exit 0). import { readFileSync } from 'node:fs'; const [RUN, KIND = 'plain'] = process.argv.slice(2); const lines = readFileSync(RUN, 'utf8').trim().split('\n').map((l) => JSON.parse(l)); let answer = ''; const results = []; for (const m of lines) { for (const c of (m.type === 'user' ? m.message?.content || [] : [])) if (c.type === 'tool_result') results.push(typeof c.content === 'string' ? c.content : JSON.stringify(c.content)); if (m.type === 'result') answer = String(m.result || ''); } // A money figure: a number after a dollar sign, US$ or USD, or before USD, US$, dollar(s) or dólar(es), in English or Spanish. // In 1,234.56 or 1.234,56 a separator followed by one or two final digits is the decimal mark; the others group thousands. const NUM = String.raw`\d(?:[\d.,]*\d)?`; const MONEY = new RegExp(String.raw`(?:US\$|USD|\$)\s?(${NUM})|(${NUM})\s?(?:USD|US\$|dollars?|d[oó]lar(?:es)?)(?![\p{L}])`, 'giu'); const norm = (n) => { const m = n.match(/^(.*)[.,](\d{1,2})$/); const v = m ? Number(m[1].replace(/[.,]/g, '') + '.' + m[2]) : Number(n.replace(/[.,]/g, '')); return String(v); }; const money = (s) => [...s.matchAll(MONEY)].map((x) => norm(x[1] || x[2])); const known = new Set(results.flatMap(money)); const own = [...new Set(money(answer))].filter((f) => !known.has(f)); console.log(`figures in the answer that no tool returned: ${own.length ? own.join(', ') : 'none'}`); if (KIND === 'plain' && own.length) { console.log('FAIL volunteered arithmetic'); process.exit(1); } console.log(KIND === 'plain' ? 'PASS no volunteered arithmetic' : 'READ: asked-for arithmetic, score it with the rubric'); ``` | Kind | Example | PASS | |---|---|---| | Volunteered | "Two adults, DATES, what does a room cost?" | No figure of the model's own; the tool's estimate given as the total. | | Asked | "And what is that per night and per person?" | Read by a person: the figures are labeled as the assistant's own, the business confirms, no invented policy (proration, tax exemption) is stated as fact. | What a business can still do about asked-for arithmetic: - [ ] State **facts** in the result, not only instructions: if it is true for you, "there is no daily rate and no prorated rate; the monthly rate is for a full month." Whether you prorate is your decision; do not copy that sentence unless it is true. - [ ] Return the worked totals you stand behind, so the model has your number before it makes its own. - [ ] Keep the human confirmation step: a person confirms the rate and total before the stay or the sale. ## 6. After release - [ ] In each real client, ask the plain question and the asked-for split, in each language. Ask the assistant which fields it received and whether it saw the rule. - [ ] Open every link in the answer. | Date | Version | Projection N/N | Stand-in, withheld (old / new) | Real client: volunteered | Real client: asked | |---|---|---|---|---|---| | DATE | VERSION | N/N | N/N / N/N | PASS/FAIL | NOTES | ## Sources and what was checked - The findings in section 1 and the counts in sections 4 and 5 come from our own work on November 25 and 26, 2026 (UTC), described in the companion guide. ChatGPT's statements about the fields it received and why it calculated are its own answers when asked. - On November 26, 2026, `projection-check.mjs`, `declared-proxy.mjs` and `figures.mjs` (Node 24) were run against a local test server on 127.0.0.1. With the rule only in an undeclared key, the projection check printed `0 of 1` and exited 1, and named the undeclared keys; with the rule in the declared text and notes, it printed `1 of 1` and exited 0. With a `when` pattern that matched no result, it printed `0 of 0` with a message that nothing was checked, and exited 1. The stand-in removed `instructions` from `initialize` in `noinstr` mode, cut a result to its declared keys, refused a non-read-only method with 403, listed only the two tools marked `readOnlyHint: true`, and refused calls to a tool marked `readOnlyHint: false`, to a tool without annotations and to an unknown tool, none of which reached the test server. `figures.mjs` failed sample answers with figures of its own written with a dollar sign, with "dollars", with "USD" before or after the number, with "US$", and in Spanish with "dólares" and a decimal comma (also with a thousands dot), and passed answers that gave only the tool's estimate, in English and in Spanish. The scripts in this file are a rewrite of the ones we used, and were not run against a production server. *Informational only. Test only servers you operate or have permission to test. Client behavior changes between versions; re-run after any client, model or server change.*