Responses API: approved native MCP write executes twice after a programmatic read

Environment

  • Surface: API.
  • Endpoint: POST https://api.openai.com/v1/responses, non-streaming, standard openai Node SDK 7.43.0, maxRetries: 0.
  • Model gpt-6.1-sol, reasoning effort medium; Node v24.22.3, macOS.
  • store: false, explicit complete input history, include: ["reasoning.encrypted_content"]; no previous_response_id.
  • Synthetic remote HTTP MCP server; protocol 2025-11-25. Two captured WordPress tool definitions, but no WordPress runtime, application response adapter, real provider accounts, business data or business writes.
  • Successful-write reproduction: 2026-11-15 22:40:57.565–22:41:04.870 UTC.

Bug

One native MCP write approval causes two actual tools/call executions when the same approval-resumption response continues with a hosted programmatic read. This happens with both a successful write and an MCP tool error. Server-side execution logs confirm this is not duplicated UI or duplicated receipts alone.

Expected: execute the approved write once, execute the requested read once, and finish.

Actual: the synthetic MCP server receives write → read → write. The two write output items have different IDs but the same approval_request_id and arguments. The generated program contains only a read. The final model answer nevertheless says the write was called once.

Reproduction

  1. Offer rest-api-write (readOnlyHint: false, idempotentHint: false) and rest-api-read (readOnlyHint: true), plus programmatic_tool_calling.
  2. Configure MCP with require_approval: { never: { read_only: true } }, allowed_callers: ["direct", "programmatic"], and defer_loading: false.
  3. Force a direct rest-api-write with tool_choice: { type: "mcp", server_label: "wordpress_fixture", name: "rest-api-write" } and arguments:
{"method":"POST","route":"/wp/v2/pages/14720","params":{"title":"Synthetic verified title"}}
  1. The first response contains exactly one mcp_approval_request; the server execution counter is still zero.
  2. Send a second Responses request containing the original user message, all first-response output items, and exactly one mcp_approval_response with approve: true. There is no application retry loop.
  3. In this second request, restrict further tool selection to the programmatic tool and the read tool:
{
  "type": "allowed_tools",
  "mode": "auto",
  "tools": [
    {"type": "programmatic_tool_calling"},
    {"type": "mcp", "server_label": "wordpress_fixture", "name": "rest-api-read"}
  ]
}
  1. The emitted program is exactly:
text(await tools.mcp_wordpress_fixture.rest_api_read({method:"GET",route:"/wp/v2/pages/14720"}));
  1. Despite no write in that program, the MCP server logs two writes surrounding the read. Both write calls complete successfully. The fixture persists the title on write, and the intervening read returns it.

Standalone files

Save the three files below in one disposable directory. Install openai@7.43.0. Set OPENAI_API_KEY and a fresh random MCP_TEST_TOKEN in the environment, run node server.cjs, and expose only its token-protected /mcp endpoint over HTTPS. Set MCP_SERVER_URL to that externally reachable endpoint, preserving the bearer Authorization header.

Run:

node probe.cjs approved-success-program-programonly
node probe.cjs approved-failure-program-programonly
node probe.cjs approved-success-directread-readonly

Inspect server-events.jsonl, server-state.json, and each probe’s request/response/evidence JSON files. Authorization is omitted from the saved request JSON. Do not publish your environment credentials. Stop the fixture and its HTTPS exposure afterwards.

The files preserve the tested v2 server execution behavior, captured tool definitions, prompts and Responses parameters. Machine-specific paths/credential loading are replaced with environment variables and sibling files; the standalone fixture initializes its counter file on startup. This packaged fixture passed a local write/readback/error check and both JS files passed syntax checks. The hosted API evidence above comes from the original run, not a new run of the repackaged files.

tools.json
[
  {
    "name": "rest-api-read",
    "title": "Read REST API",
    "description": "Read any WordPress REST API endpoint internally, or inspect a route's parameters with OPTIONS. Call GET / for a list of every route and the methods it accepts, or GET /wp/v2 for one namespace, then OPTIONS on one route for its parameters. A route listed with a regex group, such as /wp/v2/posts/(?P<id>[\\d]+), is called with a value in its place: /wp/v2/posts/123. A route that does not exist returns an error naming the closest registered routes. To find the post, page or file at a URL, GET /hm-rest-ability/v1/url-lookup with the URL as the url param. Responses are capped at 50000 bytes and trimmed when they exceed it, so narrow them with _fields, per_page, or a more specific route.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "GET",
            "OPTIONS"
          ],
          "description": "HTTP method"
        },
        "route": {
          "type": "string",
          "description": "REST API route path, e.g. /wp/v2/posts or /wp/v2/posts/123"
        },
        "params": {
          "type": "object",
          "description": "Query params (GET/DELETE) or body params (POST/PUT/PATCH). Pass _fields to limit which fields come back.",
          "additionalProperties": true
        },
        "response_cursor": {
          "type": "string",
          "description": "Continue a truncated GET with its response_cursor and the same route and params. Each chunk is base64-encoded JSON bytes; concatenate decoded chunks before parsing. A changed response returns 409; restart the read."
        }
      },
      "required": [
        "method",
        "route"
      ]
    },
    "outputSchema": {
      "type": "object",
      "properties": {
        "status": {
          "type": "integer",
          "description": "HTTP status code of the REST API response."
        },
        "headers": {
          "type": [
            "object",
            "array"
          ],
          "description": "Response headers, keyed by header name. An empty list when there are none."
        },
        "data": {
          "type": [
            "object",
            "array",
            "string",
            "number",
            "integer",
            "boolean",
            "null"
          ],
          "description": "Response body, as JSON. Its shape depends on the route."
        },
        "response": {
          "type": "object",
          "description": "GET continuation metadata: base64-json encoding, byte offset, total_bytes, sha256 of the complete JSON, and next_cursor (null at the end)."
        },
        "truncated": {
          "type": "object",
          "description": "Present when the response was trimmed to fit the size cap. batch_receipt is true when data contains all native batch item statuses and omits their bodies and headers."
        },
        "error": {
          "type": "string",
          "description": "What went wrong, when the call could not be made."
        },
        "suggestions": {
          "type": "array",
          "description": "Closest registered routes, when the route does not exist."
        },
        "guidance": {
          "type": "string",
          "description": "Advice on calling a route that changes site settings or access, or that deletes data. Returned by OPTIONS."
        }
      },
      "additionalProperties": true
    },
    "annotations": {
      "title": "Read REST API",
      "readOnlyHint": true,
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": true
    }
  },
  {
    "name": "rest-api-write",
    "title": "Write REST API",
    "description": "Create or update data through any WordPress REST API endpoint internally. Use rest-api/read first to find the route and its parameters \u2014 changes take effect on the live site immediately. Responses are capped at 50000 bytes and trimmed when they exceed it, so narrow them with _fields. Confirm with the user before calling, and say what will change.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "POST",
            "PUT",
            "PATCH"
          ],
          "description": "HTTP method"
        },
        "route": {
          "type": "string",
          "description": "REST API route path, e.g. /wp/v2/posts or /wp/v2/posts/123"
        },
        "params": {
          "type": "object",
          "description": "Query params (GET/DELETE) or body params (POST/PUT/PATCH). Pass _fields to limit which fields come back.",
          "additionalProperties": true
        }
      },
      "required": [
        "method",
        "route"
      ]
    },
    "outputSchema": {
      "type": "object",
      "properties": {
        "status": {
          "type": "integer",
          "description": "HTTP status code of the REST API response."
        },
        "headers": {
          "type": [
            "object",
            "array"
          ],
          "description": "Response headers, keyed by header name. An empty list when there are none."
        },
        "data": {
          "type": [
            "object",
            "array",
            "string",
            "number",
            "integer",
            "boolean",
            "null"
          ],
          "description": "Response body, as JSON. Its shape depends on the route."
        },
        "response": {
          "type": "object",
          "description": "GET continuation metadata: base64-json encoding, byte offset, total_bytes, sha256 of the complete JSON, and next_cursor (null at the end)."
        },
        "truncated": {
          "type": "object",
          "description": "Present when the response was trimmed to fit the size cap. batch_receipt is true when data contains all native batch item statuses and omits their bodies and headers."
        },
        "error": {
          "type": "string",
          "description": "What went wrong, when the call could not be made."
        },
        "suggestions": {
          "type": "array",
          "description": "Closest registered routes, when the route does not exist."
        },
        "guidance": {
          "type": "string",
          "description": "Advice on calling a route that changes site settings or access, or that deletes data. Returned by OPTIONS."
        }
      },
      "additionalProperties": true
    },
    "annotations": {
      "title": "Write REST API",
      "readOnlyHint": false,
      "destructiveHint": false,
      "idempotentHint": false,
      "openWorldHint": true
    }
  }
]
server.cjs
'use strict';
const fs=require('node:fs'),http=require('node:http'),crypto=require('node:crypto');
const dir=process.env.MCP_REPRO_DIR||__dirname;const token=process.env.MCP_TEST_TOKEN;if(!token)throw new Error('Set MCP_TEST_TOKEN');
const inventory=JSON.parse(fs.readFileSync(__dirname+'/tools.json'));
const state={requests:0,executions:[],mutations:[],records:{}};
fs.writeFileSync(dir+'/server-state.json',JSON.stringify(state,null,2),{mode:0o600});
function log(e){fs.appendFileSync(dir+'/server-events.jsonl',JSON.stringify({at:new Date().toISOString(),...e})+'\n',{mode:0o600});}
const server=http.createServer(async(req,res)=>{const expected='Bearer '+token,received=req.headers.authorization||'';if(req.url!=='/mcp'||received.length!==expected.length||!crypto.timingSafeEqual(Buffer.from(received),Buffer.from(expected))){res.writeHead(404);return res.end();}if(req.method!=='POST'){res.writeHead(405);return res.end();}let raw='';for await(const c of req)raw+=c;let msg;try{msg=JSON.parse(raw);}catch{res.writeHead(400);return res.end();}const request=++state.requests;log({event:'request',request,rpcId:msg.id,method:msg.method,params:msg.params});let result,error;if(msg.method==='initialize')result={protocolVersion:'2025-11-25',capabilities:{tools:{}},serverInfo:{name:'synthetic-wordpress-receipt-isolation',version:'1.0.0'}};else if(msg.method.startsWith('notifications/')){res.writeHead(202);return res.end();}else if(msg.method==='tools/list')result={tools:inventory};else if(msg.method==='tools/call'){const call={execution:state.executions.length+1,request,rpcId:msg.id,name:msg.params.name,arguments:msg.params.arguments};state.executions.push(call);log({event:'execution',...call});const args=msg.params.arguments;if(msg.params.name==='rest-api-write'&&args.params?.status==='mcp-qa-invalid-status'){result={content:[{type:'text',text:'Invalid parameter(s): status. status is not one of publish, future, draft, pending, private and expired.'}],isError:true};}else{if(msg.params.name==='rest-api-write'){state.mutations.push(call);state.records[args.route]={title:args.params?.title||state.records[args.route]?.title||'Synthetic QA draft'};}const data={id:14720,status:'draft',title:{raw:state.records[args.route]?.title||'Synthetic QA draft'},content:{raw:'Synthetic text only.'}};const body={status:200,headers:{},data};result={content:[{type:'text',text:JSON.stringify(body)}],structuredContent:body,isError:false};}fs.writeFileSync(dir+'/server-state.json',JSON.stringify(state,null,2),{mode:0o600});}else if(msg.method==='ping')result={};else error={code:-32601,message:'Method not found'};const output={jsonrpc:'2.0',id:msg.id,...(error?{error}:{result})};log({event:'result_sent',request,rpcId:msg.id,isError:result?.isError||false});res.writeHead(200,{'content-type':'application/json'});res.end(JSON.stringify(output));});
server.listen(Number(process.env.PORT||54739),'127.0.0.1',()=>{const port=server.address().port;fs.writeFileSync(dir+'/server-runtime.json',JSON.stringify({port,pid:process.pid,fixtureVersion:2,scope:'Synthetic MCP tools only. Synthetic MCP only; no external business services reachable.'}),{mode:0o600});console.log(JSON.stringify({port,pid:process.pid}));});
process.on('SIGTERM',()=>server.close(()=>process.exit(0)));
probe.cjs
'use strict';
const fs=require('node:fs'),assert=require('node:assert/strict');const dir=process.env.MCP_REPRO_DIR||__dirname;const OpenAI=require('openai');const client=new OpenAI({maxRetries:0});
const mode=process.argv[2]||'approved-failure-none',auth={token:process.env.MCP_TEST_TOKEN},endpoint=process.env.MCP_SERVER_URL;
const directRead=mode.includes('directread'),success=mode.includes('success'),program=mode.includes('program'),automatic=mode.endsWith('-auto'),programOnly=mode.endsWith('-programonly')||mode.endsWith('-readonly');const server={type:'mcp',server_label:'wordpress_fixture',server_url:endpoint,authorization:auth.token,require_approval:{never:{read_only:true}},allowed_callers:program?['direct','programmatic']:['direct'],defer_loading:false};
const tools=[server,...(program?[{type:'programmatic_tool_calling'}]:[])];
const params={model:'gpt-6.1-sol',reasoning:{effort:'medium'},store:false,include:['reasoning.encrypted_content'],max_output_tokens:4000,tools};
const args={method:'POST',route:'/wp/v2/pages/14720',params:success?{title:'Synthetic verified title'}:{status:'mcp-qa-invalid-status'}};
const state=()=>JSON.parse(fs.readFileSync(dir+'/server-state.json'));
const evidence={mode,scope:'Synthetic native MCP server only. No application adapter, WordPress, real account tokens or business writes.',startedAt:new Date().toISOString(),args,before:state().executions.length,responses:[]};
async function request(p,step){const {authorization,...publicServer}=server;fs.writeFileSync(dir+'/'+mode+'-'+step+'-request.json',JSON.stringify({...p,tools:[publicServer,...tools.slice(1)]},null,2),{mode:0o600});const result=await client.responses.create(p);fs.writeFileSync(dir+'/'+mode+'-'+step+'-response.json',JSON.stringify(result,null,2),{mode:0o600});evidence.responses.push({step,id:result.id,status:result.status,requestId:result._request_id,items:result.output.map(i=>({type:i.type,id:i.id,name:i.name,call_id:i.call_id,status:i.status,approval_request_id:i.approval_request_id,arguments:i.arguments,error:i.error,code:i.code})),text:result.output_text});return result;}
(async()=>{const prompt=`This is a synthetic MCP execution-count test. Call rest-api-write exactly once with these exact arguments: ${JSON.stringify(args)}. This action is authorized for the disposable fixture; let the native approval pause occur. After the tool returns, report its exact result or failure, and do not retry the write. ${program ? "After the write returns, use programmatic_tool_calling to read the same page exactly once using rest-api-read with method GET and route /wp/v2/pages/14720, then report the result. The program must contain only that read; do not retry the write." : directRead ? "After the write returns, call rest-api-read directly once using method GET and route /wp/v2/pages/14720, then report the result. Do not retry the write." : "Do not call any other tool."}`;const first=await request({...params,input:prompt,tool_choice:{type:'mcp',server_label:server.server_label,name:'rest-api-write'}},'prepare');const approvals=first.output.filter(i=>i.type==='mcp_approval_request');assert.equal(approvals.length,1,'Expected exactly one approval');assert.deepEqual(JSON.parse(approvals[0].arguments),args);assert.equal(state().executions.length,evidence.before,'Preparation must not execute the write');const input=[{role:'user',content:prompt},...first.output,{type:'mcp_approval_response',approval_request_id:approvals[0].id,approve:true}];await request({...params,input,tool_choice:programOnly?{type:'allowed_tools',mode:'auto',tools:[...(program?[{type:'programmatic_tool_calling'}]:[]),{type:'mcp',server_label:server.server_label,name:'rest-api-read'}]}:automatic?'auto':'none'},'approved');const after=state();evidence.after=after.executions.length;evidence.executions=after.executions.slice(evidence.before);evidence.mutations=after.mutations.filter(m=>m.execution>evidence.before);evidence.finishedAt=new Date().toISOString();fs.writeFileSync(dir+'/'+mode+'-evidence.json',JSON.stringify(evidence,null,2),{mode:0o600});console.log(JSON.stringify({mode,executions:evidence.executions.length,mutations:evidence.mutations.length,items:evidence.responses.at(-1).items,text:evidence.responses.at(-1).text},null,2));})().catch(e=>{evidence.error={name:e.name,code:e.code,message:e.message,status:e.status};fs.writeFileSync(dir+'/'+mode+'-evidence.json',JSON.stringify(evidence,null,2),{mode:0o600});console.log(JSON.stringify({mode,error:evidence.error}));process.exitCode=1;});

Diagnostics

Exact error and HTTP status: the successful case has HTTP 200 and two completed MCP writes; the failing case has two native mcp_tool_execution_error results. The synthetic server returns HTTP 200 JSON-RPC responses in both cases. This is repeated dispatch, not an HTTP API error.

When/how often: November 15, 2026 UTC. All three tested hosted-programmatic continuation samples replayed the write; the three non-programmatic controls did not. This is a sample description, not a claim about the rate across models or all requests.

Server and response evidence

Server-side JSON-RPC tools/call execution sequence for the successful case (counters are cumulative across fixture tests):

execution 6, HTTP request 16, JSON-RPC id 0: rest-api-write
  {"method":"POST","route":"/wp/v2/pages/14720","params":{"title":"Synthetic verified title"}}
execution 7, HTTP request 17, JSON-RPC id 0: rest-api-read
  {"method":"GET","route":"/wp/v2/pages/14720"}
execution 8, HTTP request 18, JSON-RPC id 0: rest-api-write
  {"method":"POST","route":"/wp/v2/pages/14720","params":{"title":"Synthetic verified title"}}

These are three distinct incoming HTTP requests. All received HTTP 200 JSON-RPC responses; there is no transport failure in this sequence.

The two native write output items:

[
  {
    "id": "mcp_021298642ea69385016afa34fc8c5887d2984e75fe692780e0",
    "name": "rest-api-write",
    "status": "completed",
    "approval_request_id": "mcpr_021298642ea69385016afa34fc025087d296f451cc230efe3a",
    "arguments": "{\"method\":\"POST\",\"route\":\"/wp/v2/pages/14720\",\"params\":{\"title\":\"Synthetic verified title\"}}"
  },
  {
    "id": "mcp_021298642ea69385016afa34fe734487d28aae54177dc89eb6",
    "name": "rest-api-write",
    "status": "completed",
    "approval_request_id": "mcpr_021298642ea69385016afa34fc025087d296f451cc230efe3a",
    "arguments": "{\"method\":\"POST\",\"route\":\"/wp/v2/pages/14720\",\"params\":{\"title\":\"Synthetic verified title\"}}"
  }
]

Native output order: mcp_call(write), program(read only), mcp_call(read), program_output, mcp_call(write), final message.

The final message ends: “Called the write once and the programmatic read once. No retries.” The server counter contradicts that execution claim.

Case Actual write executions Actual read executions
Approved MCP tool error, further tools disabled (tool_choice: "none") 1 0
Approved MCP tool error, ordinary final answer (auto) 1 0
Approved MCP tool error → hosted programmatic read (auto) 2 1
Approved MCP tool error → hosted programmatic read, only program/read permitted in allowed_tools 2 1
Approved success → hosted programmatic read, only program/read permitted in allowed_tools 2 1
Approved success → direct MCP read, only read permitted in allowed_tools 1 1

For the failing case, replace the write’s params with {"status":"mcp-qa-invalid-status"}. The fixture returns native isError: true with Invalid parameter(s): status. status is not one of publish, future, draft, pending, private and expired. Both failing write executions reach the server.

The observed trigger is the interaction between native MCP approval resumption and hosted programmatic continuation within one response. These observations do not establish the internal root cause or behavior of other models.

Request IDs

  • Successful replay: req_be6e8ae06a6249baa2ac9c624f18d383; response resp_021298642ea69385016afa34fc46a887d289c5656c55c5588b.
  • MCP-error replay: req_be0a8582dcdc431b9b3d149758c78bca; response resp_0280b93b2e72c424016afa34d8bfbc87d291043e2d1e39487c.
  • Direct-read control (one write): req_51dd1f1cf15e4439a2b5c93bd82fa2eb; response resp_0c339a94302c6d0b016afa35227f9487d28294c04841243a0c.

Related report

Microsoft agent-framework #6851 also reports an already-approved action actually executing again, rather than only displaying twice. That issue is closed, and its reproduction uses Microsoft’s hosted-agent/framework path with previous_response_id on a later turn.

This report is separate because it uses OpenAI’s native remote MCP directly, without that framework or previous_response_id, and replays within the same approval-resumption response after a hosted programmatic read. The symptoms are related; a shared root cause has not been established.

AI disclosure: Codex investigated the reproduction and prepared this report under Tom’s direction.

Thanks for packaging this so clearly. Until it’s fixed on the API side, a few ways to keep writes safe:

  1. Split the turns. Your controls show the replay only happens when the approval resumption and the hosted programmatic read happen in the same response. Resume the approval with tool_choice: “none” (your table shows 1 write in that case), then send the read as a separate request. One extra round trip, but no second write.
  2. Make the write idempotent on the MCP server. Add a required idempotency_key string to rest-api-write’s input schema and keep seen keys (with the result) for a few minutes. The replayed call has the same arguments, so it carries the same key and the server can return the first result instead of writing again. This matters most for non-idempotent routes like creating posts or orders.
  3. Detect it in the client too: two mcp_call items with the same approval_request_id in one response means a replay. Log it and don’t rely on the model’s final summary for execution counts, as you saw.

Thank you for flagging and providing such detailed set of information, we are looking into this issue.