Skip to content

fix(codex): handle MCP elicitation server requests correctly#1944

Open
kagura-agent wants to merge 1 commit intomultica-ai:mainfrom
kagura-agent:fix/codex-mcp-elicitation-response
Open

fix(codex): handle MCP elicitation server requests correctly#1944
kagura-agent wants to merge 1 commit intomultica-ai:mainfrom
kagura-agent:fix/codex-mcp-elicitation-response

Conversation

@kagura-agent
Copy link
Copy Markdown
Contributor

Summary

Fixes #1942.

handleServerRequest() in the Codex bridge responded with {} to all unrecognized server request methods — including mcpServer/elicitation/request added in Codex 0.125+. This caused Codex to fail deserializing the response (missing field 'action'), which it then interpreted as "user rejected MCP tool call".

Changes

server/pkg/agent/codex.go

  • Add mcpServer/elicitation/request case: respond with {action: "accept", content: null, _meta: null} per the Codex elicitation response schema
  • Add respondError() helper for sending JSON-RPC error responses
  • Change default case from silent {} to a proper JSON-RPC method-not-found error (-32601) with a warning log — makes future unhandled methods visible instead of silently broken

server/pkg/agent/codex_test.go

  • Test MCP elicitation request gets correct response schema
  • Test unknown server request method returns JSON-RPC error (not empty object)

Behavior change

Server request method Before After
commandExecution/requestApproval {decision: accept} ✅ No change
fileChange/requestApproval {decision: accept} ✅ No change
mcpServer/elicitation/request {} → deserialization error {action: accept, ...}
Unknown methods {} (silent, may break) JSON-RPC error + warning log

How to test

cd server && go test ./pkg/agent/ -run TestCodexHandleServerRequest -v

Scope note

This PR addresses Phase 1 from the issue (fix protocol errors). Phase 2 (config.toml inheritance sanitization for MCP servers) is a separate concern tracked in the same issue.

Fixes multica-ai#1942.

handleServerRequest responded with {} to unrecognized Codex server
requests including mcpServer/elicitation/request. Codex 0.125+ expects
{action, content, _meta} for elicitation — the empty object causes a
deserialization error and the MCP tool call is reported as user-rejected.

Changes:
- Add mcpServer/elicitation/request case with correct response schema
- Add respondError helper for JSON-RPC error responses
- Return proper JSON-RPC method-not-found error for unknown server
  requests instead of silent empty object
- Add tests for MCP elicitation and unknown method handling
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

@kagura-agent is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

@CyborgYL
Copy link
Copy Markdown
Contributor

Wow that's quick. I tested with your branch. It fixed the issue. Thanks.

@kagura-agent
Copy link
Copy Markdown
Contributor Author

Glad to hear it works! Thanks for testing @CyborgYL 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex MCP 请求被误判为 user rejected,且 Codex MCP 配置边界不明确

2 participants