Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(mcp): preserve questions and choice descriptions in input requests (#1050)

mldangelo-oaid7b73163d37a
diff --git a/plugins/codex-security/mcp-app/server.ts b/plugins/codex-security/mcp-app/server.ts
index 540de0fce..bba032573 100644
--- a/plugins/codex-security/mcp-app/server.ts
+++ b/plugins/codex-security/mcp-app/server.ts
@@ -2230,9 +2230,17 @@ function buildUserInputElicitation(
const isSingleQuestion = questions.length === 1;
return {
mode: "form" as const,
- message: isSingleQuestion
- ? questions[0]!.question
- : "Codex Security needs your input before it can continue.",
+ message: questions
+ .map((question) =>
+ [
+ ...(isSingleQuestion ? [] : [question.header]),
+ question.question,
+ ...question.options.map(
+ (option) => `- ${option.label}: ${option.description}`,
+ ),
+ ].join("\n"),
+ )
+ .join("\n\n"),
requestedSchema: {
type: "object" as const,
properties: Object.fromEntries(
@@ -2241,6 +2249,7 @@ function buildUserInputElicitation(
{
type: "string" as const,
title: question.header,
+ description: question.question,
oneOf: question.options.map((option) => ({
const: option.label,
title: option.label,
diff --git a/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts b/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts
index 1619bc954..40587d588 100644
--- a/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts
+++ b/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts
@@ -1505,7 +1505,18 @@ try {
assert.equal(elicitationRequest.params.mode, "form");
assert.equal(
elicitationRequest.params.message,
- "Codex Security needs your input before it can continue.",
+ [
+ "Deep scan?",
+ "Another Deep Security Scan is running. Continue this one?",
+ "- Cancel (Recommended): Stop this new scan before preflight or substantive work.",
+ "- Continue: Proceed even though both scans may use more resources.",
+ "",
+ "Preflight?",
+ "How should Codex Security handle the blocked preflight?",
+ "- Apply and retry: Apply the proposed Codex configuration change and rerun preflight.",
+ "- Leave paused: Keep the scan available for a later retry.",
+ "- Cancel scan: Cancel this scan without changing configuration.",
+ ].join("\n"),
);
assert.deepEqual(
elicitationRequest.params.requestedSchema.properties.concurrent_deep_scan
@@ -1519,11 +1530,9 @@ try {
],
);
assert.equal(
- Object.hasOwn(
- elicitationRequest.params.requestedSchema.properties.concurrent_deep_scan,
- "description",
- ),
- false,
+ elicitationRequest.params.requestedSchema.properties.concurrent_deep_scan
+ .description,
+ "Another Deep Security Scan is running. Continue this one?",
);
assert.deepEqual(
elicitationRequest.params.requestedSchema.properties.preflight_action.oneOf,
@@ -1540,11 +1549,9 @@ try {
],
);
assert.equal(
- Object.hasOwn(
- elicitationRequest.params.requestedSchema.properties.preflight_action,
- "description",
- ),
- false,
+ elicitationRequest.params.requestedSchema.properties.preflight_action
+ .description,
+ "How should Codex Security handle the blocked preflight?",
);
testServer.sendResponse(elicitationRequest.id, {
action: "accept",
@@ -1605,9 +1612,19 @@ try {
const declinedElicitation = await testServer.waitForMessage(
(message) =>
message.method === "elicitation/create" &&
- message.params?.message === "Decline this Codex Security input request?",
+ message.params?.message.startsWith(
+ "Decline this Codex Security input request?",
+ ),
"declined Codex Security elicitation request",
);
+ assert.equal(
+ declinedElicitation.params.message,
+ [
+ "Decline this Codex Security input request?",
+ "- Continue: Continue the current workflow.",
+ "- Cancel: Leave the current workflow paused.",
+ ].join("\n"),
+ );
testServer.sendResponse(declinedElicitation.id, { action: "decline" });
const declinedUserInput = await testServer.waitForMessage(
(message) => message.id === 9002,
@@ -1634,7 +1651,9 @@ try {
const cancelledElicitation = await testServer.waitForMessage(
(message) =>
message.method === "elicitation/create" &&
- message.params?.message === "Cancel this Codex Security input request?",
+ message.params?.message.startsWith(
+ "Cancel this Codex Security input request?",
+ ),
"cancelled Codex Security elicitation request",
);
testServer.sendResponse(cancelledElicitation.id, { action: "cancel" });