This commit is contained in:
Matthew Zeng
2026-03-05 21:52:07 -08:00
parent db979dc5de
commit 84f66b3309
57 changed files with 4732 additions and 225 deletions
@@ -548,6 +548,7 @@
"oneOf": [
{
"properties": {
"_meta": true,
"message": {
"type": "string"
},
@@ -568,6 +569,7 @@
},
{
"properties": {
"_meta": true,
"elicitation_id": {
"type": "string"
},
@@ -2019,6 +2021,13 @@
"server_name": {
"type": "string"
},
"turn_id": {
"description": "Turn ID that this elicitation belongs to, when known.",
"type": [
"string",
"null"
]
},
"type": {
"enum": [
"elicitation_request"
@@ -7812,6 +7821,13 @@
"server_name": {
"type": "string"
},
"turn_id": {
"description": "Turn ID that this elicitation belongs to, when known.",
"type": [
"string",
"null"
]
},
"type": {
"enum": [
"elicitation_request"
@@ -1,8 +1,535 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"McpElicitationArrayType": {
"enum": [
"array"
],
"type": "string"
},
"McpElicitationBooleanSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"boolean",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationBooleanType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationBooleanType": {
"enum": [
"boolean"
],
"type": "string"
},
"McpElicitationConstOption": {
"properties": {
"const": {
"type": "string"
},
"title": {
"type": "string"
}
},
"required": [
"const",
"title"
],
"type": "object"
},
"McpElicitationEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationSingleSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationMultiSelectEnumSchema"
}
]
},
"McpElicitationIntegerSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"maximum": {
"format": "int64",
"type": [
"integer",
"null"
]
},
"minimum": {
"format": "int64",
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationIntegerType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationIntegerType": {
"enum": [
"integer"
],
"type": "string"
},
"McpElicitationMultiSelectEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationUntitledMultiSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationTitledMultiSelectEnumSchema"
}
]
},
"McpElicitationNumberSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"maximum": {
"format": "double",
"type": [
"number",
"null"
]
},
"minimum": {
"format": "double",
"type": [
"number",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationNumberType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationNumberType": {
"enum": [
"number"
],
"type": "string"
},
"McpElicitationObjectType": {
"enum": [
"object"
],
"type": "string"
},
"McpElicitationPrimitiveSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationStringSchema"
},
{
"$ref": "#/definitions/McpElicitationNumberSchema"
},
{
"$ref": "#/definitions/McpElicitationIntegerSchema"
},
{
"$ref": "#/definitions/McpElicitationBooleanSchema"
}
]
},
"McpElicitationSchema": {
"additionalProperties": true,
"description": "Typed form schema for MCP `elicitation/create` requests.\n\nThis mirrors the `requestedSchema` shape from the MCP `ElicitRequestFormParams` schema while preserving extension keywords such as Codex-specific `x-codex-*` metadata.",
"properties": {
"$schema": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"properties": {
"additionalProperties": {
"$ref": "#/definitions/McpElicitationPrimitiveSchema"
},
"type": "object"
},
"required": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationObjectType"
}
},
"required": [
"properties",
"type"
],
"type": "object"
},
"McpElicitationSingleSelectEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationUntitledSingleSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationTitledSingleSelectEnumSchema"
}
]
},
"McpElicitationStringFormat": {
"enum": [
"email",
"uri",
"date",
"date-time"
],
"type": "string"
},
"McpElicitationStringSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"format": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationStringFormat"
},
{
"type": "null"
}
]
},
"maxLength": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minLength": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationStringType": {
"enum": [
"string"
],
"type": "string"
},
"McpElicitationTitledEnumItems": {
"properties": {
"anyOf": {
"items": {
"$ref": "#/definitions/McpElicitationConstOption"
},
"type": "array"
}
},
"required": [
"anyOf"
],
"type": "object"
},
"McpElicitationTitledMultiSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"items": {
"$ref": "#/definitions/McpElicitationTitledEnumItems"
},
"maxItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationArrayType"
}
},
"required": [
"items",
"type"
],
"type": "object"
},
"McpElicitationTitledSingleSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"oneOf": {
"items": {
"$ref": "#/definitions/McpElicitationConstOption"
},
"type": "array"
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"oneOf",
"type"
],
"type": "object"
},
"McpElicitationUntitledEnumItems": {
"properties": {
"enum": {
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"enum",
"type"
],
"type": "object"
},
"McpElicitationUntitledMultiSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"items": {
"$ref": "#/definitions/McpElicitationUntitledEnumItems"
},
"maxItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationArrayType"
}
},
"required": [
"items",
"type"
],
"type": "object"
},
"McpElicitationUntitledSingleSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"enum": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"enum",
"type"
],
"type": "object"
}
},
"oneOf": [
{
"properties": {
"_meta": true,
"message": {
"type": "string"
},
@@ -12,17 +539,26 @@
],
"type": "string"
},
"requestedSchema": true
"requestedSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationSchema"
},
{
"type": "null"
}
]
}
},
"required": [
"message",
"mode",
"requestedSchema"
"mode"
],
"type": "object"
},
{
"properties": {
"_meta": true,
"elicitationId": {
"type": "string"
},
@@ -11,6 +11,9 @@
}
},
"properties": {
"_meta": {
"description": "Optional client metadata for form-mode action handling."
},
"action": {
"$ref": "#/definitions/McpServerElicitationAction"
},
@@ -652,10 +652,535 @@
}
]
},
"McpElicitationArrayType": {
"enum": [
"array"
],
"type": "string"
},
"McpElicitationBooleanSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"boolean",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationBooleanType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationBooleanType": {
"enum": [
"boolean"
],
"type": "string"
},
"McpElicitationConstOption": {
"properties": {
"const": {
"type": "string"
},
"title": {
"type": "string"
}
},
"required": [
"const",
"title"
],
"type": "object"
},
"McpElicitationEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationSingleSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationMultiSelectEnumSchema"
}
]
},
"McpElicitationIntegerSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"maximum": {
"format": "int64",
"type": [
"integer",
"null"
]
},
"minimum": {
"format": "int64",
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationIntegerType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationIntegerType": {
"enum": [
"integer"
],
"type": "string"
},
"McpElicitationMultiSelectEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationUntitledMultiSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationTitledMultiSelectEnumSchema"
}
]
},
"McpElicitationNumberSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"maximum": {
"format": "double",
"type": [
"number",
"null"
]
},
"minimum": {
"format": "double",
"type": [
"number",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationNumberType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationNumberType": {
"enum": [
"number"
],
"type": "string"
},
"McpElicitationObjectType": {
"enum": [
"object"
],
"type": "string"
},
"McpElicitationPrimitiveSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationStringSchema"
},
{
"$ref": "#/definitions/McpElicitationNumberSchema"
},
{
"$ref": "#/definitions/McpElicitationIntegerSchema"
},
{
"$ref": "#/definitions/McpElicitationBooleanSchema"
}
]
},
"McpElicitationSchema": {
"additionalProperties": true,
"description": "Typed form schema for MCP `elicitation/create` requests.\n\nThis mirrors the `requestedSchema` shape from the MCP `ElicitRequestFormParams` schema while preserving extension keywords such as Codex-specific `x-codex-*` metadata.",
"properties": {
"$schema": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"properties": {
"additionalProperties": {
"$ref": "#/definitions/McpElicitationPrimitiveSchema"
},
"type": "object"
},
"required": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationObjectType"
}
},
"required": [
"properties",
"type"
],
"type": "object"
},
"McpElicitationSingleSelectEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationUntitledSingleSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationTitledSingleSelectEnumSchema"
}
]
},
"McpElicitationStringFormat": {
"enum": [
"email",
"uri",
"date",
"date-time"
],
"type": "string"
},
"McpElicitationStringSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"format": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationStringFormat"
},
{
"type": "null"
}
]
},
"maxLength": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minLength": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationStringType": {
"enum": [
"string"
],
"type": "string"
},
"McpElicitationTitledEnumItems": {
"properties": {
"anyOf": {
"items": {
"$ref": "#/definitions/McpElicitationConstOption"
},
"type": "array"
}
},
"required": [
"anyOf"
],
"type": "object"
},
"McpElicitationTitledMultiSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"items": {
"$ref": "#/definitions/McpElicitationTitledEnumItems"
},
"maxItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationArrayType"
}
},
"required": [
"items",
"type"
],
"type": "object"
},
"McpElicitationTitledSingleSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"oneOf": {
"items": {
"$ref": "#/definitions/McpElicitationConstOption"
},
"type": "array"
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"oneOf",
"type"
],
"type": "object"
},
"McpElicitationUntitledEnumItems": {
"properties": {
"enum": {
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"enum",
"type"
],
"type": "object"
},
"McpElicitationUntitledMultiSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"items": {
"$ref": "#/definitions/McpElicitationUntitledEnumItems"
},
"maxItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationArrayType"
}
},
"required": [
"items",
"type"
],
"type": "object"
},
"McpElicitationUntitledSingleSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"enum": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"enum",
"type"
],
"type": "object"
},
"McpServerElicitationRequestParams": {
"oneOf": [
{
"properties": {
"_meta": true,
"message": {
"type": "string"
},
@@ -665,17 +1190,26 @@
],
"type": "string"
},
"requestedSchema": true
"requestedSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationSchema"
},
{
"type": "null"
}
]
}
},
"required": [
"message",
"mode",
"requestedSchema"
"mode"
],
"type": "object"
},
{
"properties": {
"_meta": true,
"elicitationId": {
"type": "string"
},
@@ -1778,6 +1778,7 @@
"oneOf": [
{
"properties": {
"_meta": true,
"message": {
"type": "string"
},
@@ -1798,6 +1799,7 @@
},
{
"properties": {
"_meta": true,
"elicitation_id": {
"type": "string"
},
@@ -3250,6 +3252,13 @@
"server_name": {
"type": "string"
},
"turn_id": {
"description": "Turn ID that this elicitation belongs to, when known.",
"type": [
"string",
"null"
]
},
"type": {
"enum": [
"elicitation_request"
@@ -5289,6 +5298,530 @@
}
]
},
"McpElicitationArrayType": {
"enum": [
"array"
],
"type": "string"
},
"McpElicitationBooleanSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"boolean",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationBooleanType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationBooleanType": {
"enum": [
"boolean"
],
"type": "string"
},
"McpElicitationConstOption": {
"properties": {
"const": {
"type": "string"
},
"title": {
"type": "string"
}
},
"required": [
"const",
"title"
],
"type": "object"
},
"McpElicitationEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationSingleSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationMultiSelectEnumSchema"
}
]
},
"McpElicitationIntegerSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"maximum": {
"format": "int64",
"type": [
"integer",
"null"
]
},
"minimum": {
"format": "int64",
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationIntegerType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationIntegerType": {
"enum": [
"integer"
],
"type": "string"
},
"McpElicitationMultiSelectEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationUntitledMultiSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationTitledMultiSelectEnumSchema"
}
]
},
"McpElicitationNumberSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"maximum": {
"format": "double",
"type": [
"number",
"null"
]
},
"minimum": {
"format": "double",
"type": [
"number",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationNumberType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationNumberType": {
"enum": [
"number"
],
"type": "string"
},
"McpElicitationObjectType": {
"enum": [
"object"
],
"type": "string"
},
"McpElicitationPrimitiveSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationStringSchema"
},
{
"$ref": "#/definitions/McpElicitationNumberSchema"
},
{
"$ref": "#/definitions/McpElicitationIntegerSchema"
},
{
"$ref": "#/definitions/McpElicitationBooleanSchema"
}
]
},
"McpElicitationSchema": {
"additionalProperties": true,
"description": "Typed form schema for MCP `elicitation/create` requests.\n\nThis mirrors the `requestedSchema` shape from the MCP `ElicitRequestFormParams` schema while preserving extension keywords such as Codex-specific `x-codex-*` metadata.",
"properties": {
"$schema": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"properties": {
"additionalProperties": {
"$ref": "#/definitions/McpElicitationPrimitiveSchema"
},
"type": "object"
},
"required": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationObjectType"
}
},
"required": [
"properties",
"type"
],
"type": "object"
},
"McpElicitationSingleSelectEnumSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationUntitledSingleSelectEnumSchema"
},
{
"$ref": "#/definitions/McpElicitationTitledSingleSelectEnumSchema"
}
]
},
"McpElicitationStringFormat": {
"enum": [
"email",
"uri",
"date",
"date-time"
],
"type": "string"
},
"McpElicitationStringSchema": {
"additionalProperties": true,
"properties": {
"description": {
"type": [
"string",
"null"
]
},
"format": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationStringFormat"
},
{
"type": "null"
}
]
},
"maxLength": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minLength": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"type"
],
"type": "object"
},
"McpElicitationStringType": {
"enum": [
"string"
],
"type": "string"
},
"McpElicitationTitledEnumItems": {
"properties": {
"anyOf": {
"items": {
"$ref": "#/definitions/McpElicitationConstOption"
},
"type": "array"
}
},
"required": [
"anyOf"
],
"type": "object"
},
"McpElicitationTitledMultiSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"items": {
"$ref": "#/definitions/McpElicitationTitledEnumItems"
},
"maxItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationArrayType"
}
},
"required": [
"items",
"type"
],
"type": "object"
},
"McpElicitationTitledSingleSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"oneOf": {
"items": {
"$ref": "#/definitions/McpElicitationConstOption"
},
"type": "array"
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"oneOf",
"type"
],
"type": "object"
},
"McpElicitationUntitledEnumItems": {
"properties": {
"enum": {
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"enum",
"type"
],
"type": "object"
},
"McpElicitationUntitledMultiSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"items": {
"$ref": "#/definitions/McpElicitationUntitledEnumItems"
},
"maxItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"minItems": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationArrayType"
}
},
"required": [
"items",
"type"
],
"type": "object"
},
"McpElicitationUntitledSingleSelectEnumSchema": {
"additionalProperties": true,
"properties": {
"default": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
},
"enum": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": [
"string",
"null"
]
},
"type": {
"$ref": "#/definitions/McpElicitationStringType"
}
},
"required": [
"enum",
"type"
],
"type": "object"
},
"McpInvocation": {
"properties": {
"arguments": {
@@ -5322,6 +5855,7 @@
"oneOf": [
{
"properties": {
"_meta": true,
"message": {
"type": "string"
},
@@ -5331,17 +5865,26 @@
],
"type": "string"
},
"requestedSchema": true
"requestedSchema": {
"anyOf": [
{
"$ref": "#/definitions/McpElicitationSchema"
},
{
"type": "null"
}
]
}
},
"required": [
"message",
"mode",
"requestedSchema"
"mode"
],
"type": "object"
},
{
"properties": {
"_meta": true,
"elicitationId": {
"type": "string"
},
@@ -5392,6 +5935,9 @@
"McpServerElicitationRequestResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"_meta": {
"description": "Optional client metadata for form-mode action handling."
},
"action": {
"$ref": "#/definitions/McpServerElicitationAction"
},
@@ -3290,6 +3290,7 @@
"oneOf": [
{
"properties": {
"_meta": true,
"message": {
"type": "string"
},
@@ -3310,6 +3311,7 @@
},
{
"properties": {
"_meta": true,
"elicitation_id": {
"type": "string"
},
@@ -4787,6 +4789,13 @@
"server_name": {
"type": "string"
},
"turn_id": {
"description": "Turn ID that this elicitation belongs to, when known.",
"type": [
"string",
"null"
]
},
"type": {
"enum": [
"elicitation_request"
@@ -3,4 +3,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "./serde_json/JsonValue";
export type ElicitationRequest = { "mode": "form", message: string, requested_schema: JsonValue, } | { "mode": "url", message: string, url: string, elicitation_id: string, };
export type ElicitationRequest = { "mode": "form", _meta?: JsonValue, message: string, requested_schema: JsonValue, } | { "mode": "url", _meta?: JsonValue, message: string, url: string, elicitation_id: string, };
@@ -3,4 +3,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ElicitationRequest } from "./ElicitationRequest";
export type ElicitationRequestEvent = { server_name: string, id: string | number, request: ElicitationRequest, };
export type ElicitationRequestEvent = {
/**
* Turn ID that this elicitation belongs to, when known.
*/
turn_id?: string, server_name: string, id: string | number, request: ElicitationRequest, };
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationArrayType = "array";
@@ -0,0 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationBooleanType } from "./McpElicitationBooleanType";
export type McpElicitationBooleanSchema = { type: McpElicitationBooleanType, title?: string, description?: string, default?: boolean, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationBooleanType = "boolean";
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationConstOption = { const: string, title: string, };
@@ -0,0 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { McpElicitationMultiSelectEnumSchema } from "./McpElicitationMultiSelectEnumSchema";
import type { McpElicitationSingleSelectEnumSchema } from "./McpElicitationSingleSelectEnumSchema";
export type McpElicitationEnumSchema = McpElicitationSingleSelectEnumSchema | McpElicitationMultiSelectEnumSchema;
@@ -0,0 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationIntegerType } from "./McpElicitationIntegerType";
export type McpElicitationIntegerSchema = { type: McpElicitationIntegerType, title?: string, description?: string, minimum?: bigint, maximum?: bigint, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationIntegerType = "integer";
@@ -0,0 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { McpElicitationTitledMultiSelectEnumSchema } from "./McpElicitationTitledMultiSelectEnumSchema";
import type { McpElicitationUntitledMultiSelectEnumSchema } from "./McpElicitationUntitledMultiSelectEnumSchema";
export type McpElicitationMultiSelectEnumSchema = McpElicitationUntitledMultiSelectEnumSchema | McpElicitationTitledMultiSelectEnumSchema;
@@ -0,0 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationNumberType } from "./McpElicitationNumberType";
export type McpElicitationNumberSchema = { type: McpElicitationNumberType, title?: string, description?: string, minimum?: number, maximum?: number, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationNumberType = "number";
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationObjectType = "object";
@@ -0,0 +1,10 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { McpElicitationBooleanSchema } from "./McpElicitationBooleanSchema";
import type { McpElicitationEnumSchema } from "./McpElicitationEnumSchema";
import type { McpElicitationIntegerSchema } from "./McpElicitationIntegerSchema";
import type { McpElicitationNumberSchema } from "./McpElicitationNumberSchema";
import type { McpElicitationStringSchema } from "./McpElicitationStringSchema";
export type McpElicitationPrimitiveSchema = McpElicitationEnumSchema | McpElicitationStringSchema | McpElicitationNumberSchema | McpElicitationIntegerSchema | McpElicitationBooleanSchema;
@@ -0,0 +1,14 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationObjectType } from "./McpElicitationObjectType";
import type { McpElicitationPrimitiveSchema } from "./McpElicitationPrimitiveSchema";
/**
* Typed form schema for MCP `elicitation/create` requests.
*
* This mirrors the `requestedSchema` shape from the MCP `ElicitRequestFormParams` schema while
* preserving extension keywords such as Codex-specific `x-codex-*` metadata.
*/
export type McpElicitationSchema = { $schema?: string, type: McpElicitationObjectType, title?: string, properties: { [key in string]?: McpElicitationPrimitiveSchema }, required?: Array<string>, description?: string, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { McpElicitationTitledSingleSelectEnumSchema } from "./McpElicitationTitledSingleSelectEnumSchema";
import type { McpElicitationUntitledSingleSelectEnumSchema } from "./McpElicitationUntitledSingleSelectEnumSchema";
export type McpElicitationSingleSelectEnumSchema = McpElicitationUntitledSingleSelectEnumSchema | McpElicitationTitledSingleSelectEnumSchema;
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationStringFormat = "email" | "uri" | "date" | "date-time";
@@ -0,0 +1,8 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationStringFormat } from "./McpElicitationStringFormat";
import type { McpElicitationStringType } from "./McpElicitationStringType";
export type McpElicitationStringSchema = { type: McpElicitationStringType, title?: string, description?: string, minLength?: number, maxLength?: number, format?: McpElicitationStringFormat, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type McpElicitationStringType = "string";
@@ -0,0 +1,6 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { McpElicitationConstOption } from "./McpElicitationConstOption";
export type McpElicitationTitledEnumItems = { anyOf: Array<McpElicitationConstOption>, };
@@ -0,0 +1,8 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationArrayType } from "./McpElicitationArrayType";
import type { McpElicitationTitledEnumItems } from "./McpElicitationTitledEnumItems";
export type McpElicitationTitledMultiSelectEnumSchema = { type: McpElicitationArrayType, title?: string, description?: string, minItems?: bigint, maxItems?: bigint, items: McpElicitationTitledEnumItems, default?: Array<string>, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,8 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationConstOption } from "./McpElicitationConstOption";
import type { McpElicitationStringType } from "./McpElicitationStringType";
export type McpElicitationTitledSingleSelectEnumSchema = { type: McpElicitationStringType, title?: string, description?: string, oneOf: Array<McpElicitationConstOption>, default?: string, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,6 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { McpElicitationStringType } from "./McpElicitationStringType";
export type McpElicitationUntitledEnumItems = { type: McpElicitationStringType, enum: Array<string>, };
@@ -0,0 +1,8 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationArrayType } from "./McpElicitationArrayType";
import type { McpElicitationUntitledEnumItems } from "./McpElicitationUntitledEnumItems";
export type McpElicitationUntitledMultiSelectEnumSchema = { type: McpElicitationArrayType, title?: string, description?: string, minItems?: bigint, maxItems?: bigint, items: McpElicitationUntitledEnumItems, default?: Array<string>, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -0,0 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationStringType } from "./McpElicitationStringType";
export type McpElicitationUntitledSingleSelectEnumSchema = { type: McpElicitationStringType, title?: string, description?: string, enum: Array<string>, default?: string, } & ({ [key in string]?: number | string | boolean | Array<JsonValue> | { [key in string]?: JsonValue } | null });
@@ -2,6 +2,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { JsonValue } from "../serde_json/JsonValue";
import type { McpElicitationSchema } from "./McpElicitationSchema";
export type McpServerElicitationRequestParams = { threadId: string,
/**
@@ -12,4 +13,4 @@ export type McpServerElicitationRequestParams = { threadId: string,
* context is app-server correlation rather than part of the protocol identity of the
* elicitation itself.
*/
turnId: string | null, serverName: string, } & ({ "mode": "form", message: string, requestedSchema: JsonValue, } | { "mode": "url", message: string, url: string, elicitationId: string, });
turnId: string | null, serverName: string, } & ({ "mode": "form", _meta: JsonValue | null, message: string, requestedSchema: McpElicitationSchema | null, } | { "mode": "url", _meta: JsonValue | null, message: string, url: string, elicitationId: string, });
@@ -10,4 +10,8 @@ export type McpServerElicitationRequestResponse = { action: McpServerElicitation
*
* This is nullable because decline/cancel responses have no content.
*/
content: JsonValue | null, };
content: JsonValue | null,
/**
* Optional client metadata for form-mode action handling.
*/
_meta: JsonValue | null, };
@@ -97,6 +97,29 @@ export type { LoginAccountParams } from "./LoginAccountParams";
export type { LoginAccountResponse } from "./LoginAccountResponse";
export type { LogoutAccountResponse } from "./LogoutAccountResponse";
export type { McpAuthStatus } from "./McpAuthStatus";
export type { McpElicitationArrayType } from "./McpElicitationArrayType";
export type { McpElicitationBooleanSchema } from "./McpElicitationBooleanSchema";
export type { McpElicitationBooleanType } from "./McpElicitationBooleanType";
export type { McpElicitationConstOption } from "./McpElicitationConstOption";
export type { McpElicitationEnumSchema } from "./McpElicitationEnumSchema";
export type { McpElicitationIntegerSchema } from "./McpElicitationIntegerSchema";
export type { McpElicitationIntegerType } from "./McpElicitationIntegerType";
export type { McpElicitationMultiSelectEnumSchema } from "./McpElicitationMultiSelectEnumSchema";
export type { McpElicitationNumberSchema } from "./McpElicitationNumberSchema";
export type { McpElicitationNumberType } from "./McpElicitationNumberType";
export type { McpElicitationObjectType } from "./McpElicitationObjectType";
export type { McpElicitationPrimitiveSchema } from "./McpElicitationPrimitiveSchema";
export type { McpElicitationSchema } from "./McpElicitationSchema";
export type { McpElicitationSingleSelectEnumSchema } from "./McpElicitationSingleSelectEnumSchema";
export type { McpElicitationStringFormat } from "./McpElicitationStringFormat";
export type { McpElicitationStringSchema } from "./McpElicitationStringSchema";
export type { McpElicitationStringType } from "./McpElicitationStringType";
export type { McpElicitationTitledEnumItems } from "./McpElicitationTitledEnumItems";
export type { McpElicitationTitledMultiSelectEnumSchema } from "./McpElicitationTitledMultiSelectEnumSchema";
export type { McpElicitationTitledSingleSelectEnumSchema } from "./McpElicitationTitledSingleSelectEnumSchema";
export type { McpElicitationUntitledEnumItems } from "./McpElicitationUntitledEnumItems";
export type { McpElicitationUntitledMultiSelectEnumSchema } from "./McpElicitationUntitledMultiSelectEnumSchema";
export type { McpElicitationUntitledSingleSelectEnumSchema } from "./McpElicitationUntitledSingleSelectEnumSchema";
export type { McpServerElicitationAction } from "./McpServerElicitationAction";
export type { McpServerElicitationRequestParams } from "./McpServerElicitationRequestParams";
export type { McpServerElicitationRequestResponse } from "./McpServerElicitationRequestResponse";
@@ -1054,21 +1054,23 @@ mod tests {
#[test]
fn serialize_mcp_server_elicitation_request() -> Result<()> {
let requested_schema: v2::McpElicitationSchema = serde_json::from_value(json!({
"type": "object",
"properties": {
"confirmed": {
"type": "boolean"
}
},
"required": ["confirmed"]
}))?;
let params = v2::McpServerElicitationRequestParams {
thread_id: "thr_123".to_string(),
turn_id: Some("turn_123".to_string()),
server_name: "codex_apps".to_string(),
request: v2::McpServerElicitationRequest::Form {
meta: None,
message: "Allow this request?".to_string(),
requested_schema: json!({
"type": "object",
"properties": {
"confirmed": {
"type": "boolean"
}
},
"required": ["confirmed"]
}),
requested_schema: Some(requested_schema),
},
};
let request = ServerRequest::McpServerElicitationRequest {
@@ -1085,6 +1087,7 @@ mod tests {
"turnId": "turn_123",
"serverName": "codex_apps",
"mode": "form",
"_meta": null,
"message": "Allow this request?",
"requestedSchema": {
"type": "object",
+447 -10
View File
@@ -4142,6 +4142,341 @@ pub struct McpServerElicitationRequestParams {
// association.
}
/// Typed form schema for MCP `elicitation/create` requests.
///
/// This mirrors the `requestedSchema` shape from the MCP `ElicitRequestFormParams` schema while
/// preserving extension keywords such as Codex-specific `x-codex-*` metadata.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationSchema {
#[serde(rename = "$schema", skip_serializing_if = "Option::is_none")]
#[ts(optional, rename = "$schema")]
pub schema_uri: Option<String>,
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationObjectType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
pub properties: BTreeMap<String, McpElicitationPrimitiveSchema>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub required: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export_to = "v2/")]
pub enum McpElicitationObjectType {
Object,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(untagged)]
#[ts(export_to = "v2/")]
pub enum McpElicitationPrimitiveSchema {
Enum(McpElicitationEnumSchema),
String(McpElicitationStringSchema),
Number(McpElicitationNumberSchema),
Integer(McpElicitationIntegerSchema),
Boolean(McpElicitationBooleanSchema),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationStringSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationStringType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub min_length: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub max_length: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub format: Option<McpElicitationStringFormat>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export_to = "v2/")]
pub enum McpElicitationStringType {
String,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "kebab-case")]
#[ts(rename_all = "kebab-case", export_to = "v2/")]
pub enum McpElicitationStringFormat {
Email,
Uri,
Date,
DateTime,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationNumberSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationNumberType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub minimum: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub maximum: Option<f64>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export_to = "v2/")]
pub enum McpElicitationNumberType {
Number,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationIntegerSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationIntegerType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub minimum: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub maximum: Option<i64>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export_to = "v2/")]
pub enum McpElicitationIntegerType {
Integer,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationBooleanSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationBooleanType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub default: Option<bool>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export_to = "v2/")]
pub enum McpElicitationBooleanType {
Boolean,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(untagged)]
#[ts(export_to = "v2/")]
pub enum McpElicitationEnumSchema {
SingleSelect(McpElicitationSingleSelectEnumSchema),
MultiSelect(McpElicitationMultiSelectEnumSchema),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(untagged)]
#[ts(export_to = "v2/")]
pub enum McpElicitationSingleSelectEnumSchema {
Untitled(McpElicitationUntitledSingleSelectEnumSchema),
Titled(McpElicitationTitledSingleSelectEnumSchema),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationUntitledSingleSelectEnumSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationStringType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(rename = "enum")]
#[ts(rename = "enum")]
pub enum_: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub default: Option<String>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationTitledSingleSelectEnumSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationStringType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(rename = "oneOf")]
#[ts(rename = "oneOf")]
pub one_of: Vec<McpElicitationConstOption>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub default: Option<String>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(untagged)]
#[ts(export_to = "v2/")]
pub enum McpElicitationMultiSelectEnumSchema {
Untitled(McpElicitationUntitledMultiSelectEnumSchema),
Titled(McpElicitationTitledMultiSelectEnumSchema),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationUntitledMultiSelectEnumSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationArrayType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub min_items: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub max_items: Option<u64>,
pub items: McpElicitationUntitledEnumItems,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub default: Option<Vec<String>>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct McpElicitationTitledMultiSelectEnumSchema {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationArrayType,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub min_items: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub max_items: Option<u64>,
pub items: McpElicitationTitledEnumItems,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub default: Option<Vec<String>>,
#[serde(default, flatten)]
pub additional: HashMap<String, JsonValue>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export_to = "v2/")]
pub enum McpElicitationArrayType {
Array,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[ts(export_to = "v2/")]
pub struct McpElicitationUntitledEnumItems {
#[serde(rename = "type")]
#[ts(rename = "type")]
pub type_: McpElicitationStringType,
#[serde(rename = "enum")]
#[ts(rename = "enum")]
pub enum_: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[ts(export_to = "v2/")]
pub struct McpElicitationTitledEnumItems {
#[serde(rename = "anyOf", alias = "oneOf")]
#[ts(rename = "anyOf")]
pub any_of: Vec<McpElicitationConstOption>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[ts(export_to = "v2/")]
pub struct McpElicitationConstOption {
#[serde(rename = "const")]
#[ts(rename = "const")]
pub const_: String,
pub title: String,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(tag = "mode", rename_all = "camelCase")]
#[ts(tag = "mode")]
@@ -4150,37 +4485,49 @@ pub enum McpServerElicitationRequest {
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Form {
#[serde(rename = "_meta")]
#[ts(rename = "_meta")]
meta: Option<JsonValue>,
message: String,
requested_schema: JsonValue,
requested_schema: Option<McpElicitationSchema>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Url {
#[serde(rename = "_meta")]
#[ts(rename = "_meta")]
meta: Option<JsonValue>,
message: String,
url: String,
elicitation_id: String,
},
}
impl From<CoreElicitationRequest> for McpServerElicitationRequest {
fn from(value: CoreElicitationRequest) -> Self {
impl TryFrom<CoreElicitationRequest> for McpServerElicitationRequest {
type Error = serde_json::Error;
fn try_from(value: CoreElicitationRequest) -> Result<Self, Self::Error> {
match value {
CoreElicitationRequest::Form {
meta,
message,
requested_schema,
} => Self::Form {
} => Ok(Self::Form {
meta,
message,
requested_schema,
},
requested_schema: serde_json::from_value(requested_schema)?,
}),
CoreElicitationRequest::Url {
meta,
message,
url,
elicitation_id,
} => Self::Url {
} => Ok(Self::Url {
meta,
message,
url,
elicitation_id,
},
}),
}
}
}
@@ -4194,6 +4541,10 @@ pub struct McpServerElicitationRequestResponse {
///
/// This is nullable because decline/cancel responses have no content.
pub content: Option<JsonValue>,
/// Optional client metadata for form-mode action handling.
#[serde(rename = "_meta")]
#[ts(rename = "_meta")]
pub meta: Option<JsonValue>,
}
impl From<McpServerElicitationRequestResponse> for rmcp::model::CreateElicitationResult {
@@ -4210,6 +4561,7 @@ impl From<rmcp::model::CreateElicitationResult> for McpServerElicitationRequestR
Self {
action: value.action.into(),
content: value.content,
meta: None,
}
}
}
@@ -4567,6 +4919,7 @@ mod tests {
content: Some(json!({
"confirmed": true,
})),
meta: None,
}
);
assert_eq!(
@@ -4577,15 +4930,18 @@ mod tests {
#[test]
fn mcp_server_elicitation_request_from_core_url_request() {
let request = McpServerElicitationRequest::from(CoreElicitationRequest::Url {
let request = McpServerElicitationRequest::try_from(CoreElicitationRequest::Url {
meta: None,
message: "Finish sign-in".to_string(),
url: "https://example.com/complete".to_string(),
elicitation_id: "elicitation-123".to_string(),
});
})
.expect("URL request should convert");
assert_eq!(
request,
McpServerElicitationRequest::Url {
meta: None,
message: "Finish sign-in".to_string(),
url: "https://example.com/complete".to_string(),
elicitation_id: "elicitation-123".to_string(),
@@ -4593,11 +4949,91 @@ mod tests {
);
}
#[test]
fn mcp_server_elicitation_request_from_core_form_request() {
let request = McpServerElicitationRequest::try_from(CoreElicitationRequest::Form {
meta: None,
message: "Allow this request?".to_string(),
requested_schema: json!({
"type": "object",
"properties": {
"confirmed": {
"type": "boolean",
}
},
"required": ["confirmed"],
}),
})
.expect("form request should convert");
let expected_schema: McpElicitationSchema = serde_json::from_value(json!({
"type": "object",
"properties": {
"confirmed": {
"type": "boolean",
}
},
"required": ["confirmed"],
}))
.expect("expected schema should deserialize");
assert_eq!(
request,
McpServerElicitationRequest::Form {
meta: None,
message: "Allow this request?".to_string(),
requested_schema: Some(expected_schema),
}
);
}
#[test]
fn mcp_server_elicitation_request_accepts_null_core_form_schema() {
let request = McpServerElicitationRequest::try_from(CoreElicitationRequest::Form {
meta: Some(json!({
"persist": "session",
})),
message: "Allow this request?".to_string(),
requested_schema: JsonValue::Null,
})
.expect("null form schema should convert");
assert_eq!(
request,
McpServerElicitationRequest::Form {
meta: Some(json!({
"persist": "session",
})),
message: "Allow this request?".to_string(),
requested_schema: None,
}
);
}
#[test]
fn mcp_server_elicitation_request_rejects_invalid_core_form_schema() {
let result = McpServerElicitationRequest::try_from(CoreElicitationRequest::Form {
meta: None,
message: "Allow this request?".to_string(),
requested_schema: json!({
"type": "object",
"properties": {
"confirmed": {
"type": "object",
}
},
}),
});
assert!(result.is_err());
}
#[test]
fn mcp_server_elicitation_response_serializes_nullable_content() {
let response = McpServerElicitationRequestResponse {
action: McpServerElicitationAction::Decline,
content: None,
meta: None,
};
assert_eq!(
@@ -4605,6 +5041,7 @@ mod tests {
json!({
"action": "decline",
"content": null,
"_meta": null,
})
);
}
@@ -617,15 +617,43 @@ pub(crate) async fn apply_bespoke_event_handling(
let permission_guard = thread_watch_manager
.note_permission_requested(&conversation_id.to_string())
.await;
let turn_id = {
let state = thread_state.lock().await;
state.active_turn_snapshot().map(|turn| turn.id)
let turn_id = match request.turn_id.clone() {
Some(turn_id) => Some(turn_id),
None => {
let state = thread_state.lock().await;
state.active_turn_snapshot().map(|turn| turn.id)
}
};
let server_name = request.server_name.clone();
let request_body = match request.request.try_into() {
Ok(request_body) => request_body,
Err(err) => {
error!(
error = %err,
server_name,
request_id = ?request.id,
"failed to parse typed MCP elicitation schema"
);
if let Err(err) = conversation
.submit(Op::ResolveElicitation {
server_name: request.server_name,
request_id: request.id,
decision: codex_protocol::approvals::ElicitationAction::Cancel,
content: None,
meta: None,
})
.await
{
error!("failed to submit ResolveElicitation: {err}");
}
return;
}
};
let params = McpServerElicitationRequestParams {
thread_id: conversation_id.to_string(),
turn_id,
server_name: request.server_name.clone(),
request: request.request.into(),
request: request_body,
};
let (pending_request_id, rx) = outgoing
.send_request(ServerRequestPayload::McpServerElicitationRequest(params))
@@ -2044,6 +2072,7 @@ async fn on_mcp_server_elicitation_response(
request_id,
decision: response.action.to_core(),
content: response.content,
meta: response.meta,
})
.await
{
@@ -2061,12 +2090,14 @@ fn mcp_server_elicitation_response_from_client_result(
McpServerElicitationRequestResponse {
action: McpServerElicitationAction::Decline,
content: None,
meta: None,
}
}),
Ok(Err(err)) if is_turn_transition_server_request_error(&err) => {
McpServerElicitationRequestResponse {
action: McpServerElicitationAction::Cancel,
content: None,
meta: None,
}
}
Ok(Err(err)) => {
@@ -2074,6 +2105,7 @@ fn mcp_server_elicitation_response_from_client_result(
McpServerElicitationRequestResponse {
action: McpServerElicitationAction::Decline,
content: None,
meta: None,
}
}
Err(err) => {
@@ -2081,6 +2113,7 @@ fn mcp_server_elicitation_response_from_client_result(
McpServerElicitationRequestResponse {
action: McpServerElicitationAction::Decline,
content: None,
meta: None,
}
}
}
@@ -2491,6 +2524,7 @@ mod tests {
McpServerElicitationRequestResponse {
action: McpServerElicitationAction::Cancel,
content: None,
meta: None,
}
);
}
@@ -16,6 +16,7 @@ use axum::http::header::AUTHORIZATION;
use axum::routing::get;
use codex_app_server_protocol::JSONRPCMessage;
use codex_app_server_protocol::JSONRPCResponse;
use codex_app_server_protocol::McpElicitationSchema;
use codex_app_server_protocol::McpServerElicitationAction;
use codex_app_server_protocol::McpServerElicitationRequest;
use codex_app_server_protocol::McpServerElicitationRequestParams;
@@ -186,12 +187,12 @@ async fn mcp_server_elicitation_round_trip() -> Result<()> {
let ServerRequest::McpServerElicitationRequest { request_id, params } = server_req else {
panic!("expected McpServerElicitationRequest request, got: {server_req:?}");
};
let requested_schema = serde_json::to_value(
let requested_schema: McpElicitationSchema = serde_json::from_value(serde_json::to_value(
ElicitationSchema::builder()
.required_property("confirmed", PrimitiveSchema::Boolean(BooleanSchema::new()))
.build()
.map_err(anyhow::Error::msg)?,
)?;
)?)?;
assert_eq!(
params,
@@ -200,8 +201,9 @@ async fn mcp_server_elicitation_round_trip() -> Result<()> {
turn_id: Some(turn.id.clone()),
server_name: "codex_apps".to_string(),
request: McpServerElicitationRequest::Form {
meta: None,
message: ELICITATION_MESSAGE.to_string(),
requested_schema,
requested_schema: Some(requested_schema),
},
}
);
@@ -214,6 +216,7 @@ async fn mcp_server_elicitation_round_trip() -> Result<()> {
content: Some(json!({
"confirmed": true,
})),
meta: None,
})?,
)
.await?;
+15 -2
View File
@@ -2840,17 +2840,22 @@ impl Session {
let request = match params.request {
McpServerElicitationRequest::Form {
meta,
message,
requested_schema,
} => codex_protocol::approvals::ElicitationRequest::Form {
meta,
message,
requested_schema,
requested_schema: serde_json::to_value(requested_schema)
.expect("typed MCP elicitation schema should serialize"),
},
McpServerElicitationRequest::Url {
meta,
message,
url,
elicitation_id,
} => codex_protocol::approvals::ElicitationRequest::Url {
meta,
message,
url,
elicitation_id,
@@ -2865,6 +2870,7 @@ impl Session {
}
};
let event = EventMsg::ElicitationRequest(ElicitationRequestEvent {
turn_id: params.turn_id,
server_name,
id,
request,
@@ -3953,6 +3959,7 @@ async fn submission_loop(sess: Arc<Session>, config: Arc<Config>, rx_sub: Receiv
request_id,
decision,
content,
meta,
} => {
handlers::resolve_elicitation(
&sess,
@@ -3960,6 +3967,7 @@ async fn submission_loop(sess: Arc<Session>, config: Arc<Config>, rx_sub: Receiv
request_id,
decision,
content,
meta,
)
.await;
false
@@ -4185,6 +4193,7 @@ mod handlers {
request_id: ProtocolRequestId,
decision: codex_protocol::approvals::ElicitationAction,
content: Option<Value>,
meta: Option<Value>,
) {
let action = match decision {
codex_protocol::approvals::ElicitationAction::Accept => ElicitationAction::Accept,
@@ -4196,7 +4205,11 @@ mod handlers {
ElicitationAction::Accept => Some(content.unwrap_or_else(|| serde_json::json!({}))),
ElicitationAction::Decline | ElicitationAction::Cancel => None,
};
let response = ElicitationResponse { action, content };
let response = ElicitationResponse {
action,
content,
meta,
};
let request_id = match request_id {
ProtocolRequestId::String(value) => {
rmcp::model::NumberOrString::String(std::sync::Arc::from(value))
+12 -2
View File
@@ -292,25 +292,34 @@ impl ElicitationRequestManager {
return Ok(ElicitationResponse {
action: ElicitationAction::Decline,
content: None,
meta: None,
});
}
let request = match elicitation {
CreateElicitationRequestParams::FormElicitationParams {
meta,
message,
requested_schema,
..
} => ElicitationRequest::Form {
meta: meta
.map(serde_json::to_value)
.transpose()
.context("failed to serialize MCP elicitation metadata")?,
message,
requested_schema: serde_json::to_value(requested_schema)
.context("failed to serialize MCP elicitation schema")?,
},
CreateElicitationRequestParams::UrlElicitationParams {
meta,
message,
url,
elicitation_id,
..
} => ElicitationRequest::Url {
meta: meta
.map(serde_json::to_value)
.transpose()
.context("failed to serialize MCP elicitation metadata")?,
message,
url,
elicitation_id,
@@ -325,6 +334,7 @@ impl ElicitationRequestManager {
.send(Event {
id: "mcp_elicitation_request".to_string(),
msg: EventMsg::ElicitationRequest(ElicitationRequestEvent {
turn_id: None,
server_name,
id: match id.clone() {
rmcp::model::NumberOrString::String(value) => {
+282 -138
View File
@@ -36,7 +36,6 @@ use codex_rmcp_client::ElicitationAction;
use codex_rmcp_client::ElicitationResponse;
use rmcp::model::ToolAnnotations;
use serde::Serialize;
use serde_json::json;
use std::sync::Arc;
/// Handles the specified tool call dispatches the appropriate
@@ -75,7 +74,7 @@ pub(crate) async fn handle_mcp_tool_call(
arguments: arguments_value.clone(),
};
let metadata = lookup_mcp_tool_metadata(sess.as_ref(), &server, &tool_name).await;
let metadata = lookup_mcp_tool_metadata(sess.as_ref(), turn_context, &server, &tool_name).await;
let app_tool_policy = if server == CODEX_APPS_MCP_SERVER_NAME {
connectors::app_tool_policy(
&turn_context.config,
@@ -117,6 +116,7 @@ pub(crate) async fn handle_mcp_tool_call(
&server,
&tool_name,
metadata.as_ref(),
arguments_value.as_ref(),
app_tool_policy.approval,
)
.await
@@ -341,7 +341,9 @@ struct McpToolApprovalMetadata {
annotations: Option<ToolAnnotations>,
connector_id: Option<String>,
connector_name: Option<String>,
connector_description: Option<String>,
tool_title: Option<String>,
tool_description: Option<String>,
}
const MCP_TOOL_APPROVAL_QUESTION_ID_PREFIX: &str = "mcp_tool_call_approval";
@@ -349,6 +351,16 @@ const MCP_TOOL_APPROVAL_ACCEPT: &str = "Approve Once";
const MCP_TOOL_APPROVAL_ACCEPT_AND_REMEMBER: &str = "Approve this Session";
const MCP_TOOL_APPROVAL_DECLINE: &str = "Deny";
const MCP_TOOL_APPROVAL_CANCEL: &str = "Cancel";
const MCP_TOOL_APPROVAL_PERSIST_KEY: &str = "persist";
const MCP_TOOL_APPROVAL_PERSIST_SESSION: &str = "session";
const MCP_TOOL_APPROVAL_SOURCE_KEY: &str = "source";
const MCP_TOOL_APPROVAL_SOURCE_CONNECTOR: &str = "connector";
const MCP_TOOL_APPROVAL_CONNECTOR_ID_KEY: &str = "connector_id";
const MCP_TOOL_APPROVAL_CONNECTOR_NAME_KEY: &str = "connector_name";
const MCP_TOOL_APPROVAL_CONNECTOR_DESCRIPTION_KEY: &str = "connector_description";
const MCP_TOOL_APPROVAL_TOOL_TITLE_KEY: &str = "tool_title";
const MCP_TOOL_APPROVAL_TOOL_DESCRIPTION_KEY: &str = "tool_description";
const MCP_TOOL_APPROVAL_TOOL_PARAMS_KEY: &str = "tool_params";
#[derive(Debug, Serialize)]
struct McpToolApprovalKey {
@@ -364,6 +376,7 @@ async fn maybe_request_mcp_tool_approval(
server: &str,
tool_name: &str,
metadata: Option<&McpToolApprovalMetadata>,
tool_params: Option<&serde_json::Value>,
approval_mode: AppToolApproval,
) -> Option<McpToolApprovalDecision> {
if approval_mode == AppToolApproval::Approve {
@@ -421,7 +434,10 @@ async fn maybe_request_mcp_tool_approval(
sess,
turn_context,
server,
metadata,
tool_params,
question.clone(),
approval_key.is_some(),
);
let decision = parse_mcp_tool_approval_elicitation_response(
sess.request_mcp_server_elicitation(turn_context, request_id, params)
@@ -465,6 +481,7 @@ fn is_full_access_mode(turn_context: &TurnContext) -> bool {
async fn lookup_mcp_tool_metadata(
sess: &Session,
turn_context: &TurnContext,
server: &str,
tool_name: &str,
) -> Option<McpToolApprovalMetadata> {
@@ -476,17 +493,40 @@ async fn lookup_mcp_tool_metadata(
.list_all_tools()
.await;
tools.into_values().find_map(|tool_info| {
if tool_info.server_name == server && tool_info.tool_name == tool_name {
Some(McpToolApprovalMetadata {
annotations: tool_info.tool.annotations,
connector_id: tool_info.connector_id,
connector_name: tool_info.connector_name,
tool_title: tool_info.tool.title,
})
} else {
None
}
let tool_info = tools
.into_values()
.find(|tool_info| tool_info.server_name == server && tool_info.tool_name == tool_name)?;
let connector_description = if server == CODEX_APPS_MCP_SERVER_NAME {
let connectors = match connectors::list_cached_accessible_connectors_from_mcp_tools(
turn_context.config.as_ref(),
)
.await
{
Some(connectors) => Some(connectors),
None => {
connectors::list_accessible_connectors_from_mcp_tools(turn_context.config.as_ref())
.await
.ok()
}
};
connectors.and_then(|connectors| {
let connector_id = tool_info.connector_id.as_deref()?;
connectors
.into_iter()
.find(|connector| connector.id == connector_id)
.and_then(|connector| connector.description)
})
} else {
None
};
Some(McpToolApprovalMetadata {
annotations: tool_info.tool.annotations,
connector_id: tool_info.connector_id,
connector_name: tool_info.connector_name,
connector_description,
tool_title: tool_info.tool.title,
tool_description: tool_info.tool.description.map(std::borrow::Cow::into_owned),
})
}
@@ -583,18 +623,17 @@ fn build_mcp_tool_approval_elicitation_request(
sess: &Session,
turn_context: &TurnContext,
server: &str,
metadata: Option<&McpToolApprovalMetadata>,
tool_params: Option<&serde_json::Value>,
question: RequestUserInputQuestion,
allow_session_persist: bool,
) -> McpServerElicitationRequestParams {
let requested_schema =
request_user_input_questions_to_elicitation_schema(std::slice::from_ref(&question));
let message = if question.header.trim().is_empty() {
question.question
} else {
format!(
"{header}\n\n{prompt}",
header = question.header,
prompt = question.question
)
let header = question.header;
let prompt = question.question;
format!("{header}\n\n{prompt}")
};
McpServerElicitationRequestParams {
@@ -602,57 +641,80 @@ fn build_mcp_tool_approval_elicitation_request(
turn_id: Some(turn_context.sub_id.clone()),
server_name: server.to_string(),
request: McpServerElicitationRequest::Form {
meta: build_mcp_tool_approval_elicitation_meta(
server,
metadata,
tool_params,
allow_session_persist,
),
message,
requested_schema,
requested_schema: None,
},
}
}
fn request_user_input_questions_to_elicitation_schema(
questions: &[RequestUserInputQuestion],
) -> serde_json::Value {
let questions_metadata = match serde_json::to_value(questions) {
Ok(value) => value,
Err(_) => serde_json::Value::Null,
};
let properties = questions
.iter()
.map(|question| {
let mut property = json!({
"title": question.header,
"description": question.question,
});
if let Some(options) = question.options.as_ref() {
property["type"] = json!("string");
property["enum"] = json!(
options
.iter()
.map(|option| option.label.clone())
.collect::<Vec<_>>()
fn build_mcp_tool_approval_elicitation_meta(
server: &str,
metadata: Option<&McpToolApprovalMetadata>,
tool_params: Option<&serde_json::Value>,
allow_session_persist: bool,
) -> Option<serde_json::Value> {
let mut meta = serde_json::Map::new();
if allow_session_persist {
meta.insert(
MCP_TOOL_APPROVAL_PERSIST_KEY.to_string(),
serde_json::Value::String(MCP_TOOL_APPROVAL_PERSIST_SESSION.to_string()),
);
}
if let Some(metadata) = metadata {
if let Some(tool_title) = metadata.tool_title.as_ref() {
meta.insert(
MCP_TOOL_APPROVAL_TOOL_TITLE_KEY.to_string(),
serde_json::Value::String(tool_title.clone()),
);
}
if let Some(tool_description) = metadata.tool_description.as_ref() {
meta.insert(
MCP_TOOL_APPROVAL_TOOL_DESCRIPTION_KEY.to_string(),
serde_json::Value::String(tool_description.clone()),
);
}
if server == CODEX_APPS_MCP_SERVER_NAME
&& (metadata.connector_id.is_some()
|| metadata.connector_name.is_some()
|| metadata.connector_description.is_some())
{
meta.insert(
MCP_TOOL_APPROVAL_SOURCE_KEY.to_string(),
serde_json::Value::String(MCP_TOOL_APPROVAL_SOURCE_CONNECTOR.to_string()),
);
if let Some(connector_id) = metadata.connector_id.as_deref() {
meta.insert(
MCP_TOOL_APPROVAL_CONNECTOR_ID_KEY.to_string(),
serde_json::Value::String(connector_id.to_string()),
);
property["x-codex-options"] = json!(options);
} else {
property["type"] = json!("string");
}
if question.is_secret {
property["writeOnly"] = json!(true);
if let Some(connector_name) = metadata.connector_name.as_ref() {
meta.insert(
MCP_TOOL_APPROVAL_CONNECTOR_NAME_KEY.to_string(),
serde_json::Value::String(connector_name.clone()),
);
}
(question.id.clone(), property)
})
.collect::<serde_json::Map<_, _>>();
json!({
"type": "object",
"properties": properties,
"required": questions
.iter()
.map(|question| question.id.clone())
.collect::<Vec<_>>(),
"additionalProperties": false,
"x-codex-request-user-input": {
"questions": questions_metadata,
},
})
if let Some(connector_description) = metadata.connector_description.as_ref() {
meta.insert(
MCP_TOOL_APPROVAL_CONNECTOR_DESCRIPTION_KEY.to_string(),
serde_json::Value::String(connector_description.clone()),
);
}
}
}
if let Some(tool_params) = tool_params {
meta.insert(
MCP_TOOL_APPROVAL_TOOL_PARAMS_KEY.to_string(),
tool_params.clone(),
);
}
(!meta.is_empty()).then_some(serde_json::Value::Object(meta))
}
fn parse_mcp_tool_approval_elicitation_response(
@@ -663,10 +725,26 @@ fn parse_mcp_tool_approval_elicitation_response(
return McpToolApprovalDecision::Cancel;
};
match response.action {
ElicitationAction::Accept => parse_mcp_tool_approval_response(
request_user_input_response_from_elicitation_content(response.content),
question_id,
),
ElicitationAction::Accept => {
if response
.meta
.as_ref()
.and_then(serde_json::Value::as_object)
.and_then(|meta| meta.get(MCP_TOOL_APPROVAL_PERSIST_KEY))
.and_then(serde_json::Value::as_str)
== Some(MCP_TOOL_APPROVAL_PERSIST_SESSION)
{
return McpToolApprovalDecision::AcceptAndRemember;
}
match parse_mcp_tool_approval_response(
request_user_input_response_from_elicitation_content(response.content),
question_id,
) {
McpToolApprovalDecision::Cancel => McpToolApprovalDecision::Accept,
decision => decision,
}
}
ElicitationAction::Decline => McpToolApprovalDecision::Decline,
ElicitationAction::Cancel => McpToolApprovalDecision::Cancel,
}
@@ -806,6 +884,23 @@ mod tests {
}
}
fn approval_metadata(
connector_id: Option<&str>,
connector_name: Option<&str>,
connector_description: Option<&str>,
tool_title: Option<&str>,
tool_description: Option<&str>,
) -> McpToolApprovalMetadata {
McpToolApprovalMetadata {
annotations: None,
connector_id: connector_id.map(str::to_string),
connector_name: connector_name.map(str::to_string),
connector_description: connector_description.map(str::to_string),
tool_title: tool_title.map(str::to_string),
tool_description: tool_description.map(str::to_string),
}
}
#[test]
fn approval_required_when_read_only_false_and_destructive() {
let annotations = annotations(Some(false), Some(true), None);
@@ -936,77 +1031,6 @@ mod tests {
assert_eq!(got, original);
}
#[test]
fn elicitation_schema_reuses_request_user_input_question_shape() {
let schema =
request_user_input_questions_to_elicitation_schema(&[RequestUserInputQuestion {
id: "approval".to_string(),
header: "Approve app tool call?".to_string(),
question: "Allow this action?".to_string(),
is_other: false,
is_secret: false,
options: Some(vec![
RequestUserInputQuestionOption {
label: MCP_TOOL_APPROVAL_ACCEPT.to_string(),
description: "Run the tool and continue.".to_string(),
},
RequestUserInputQuestionOption {
label: MCP_TOOL_APPROVAL_DECLINE.to_string(),
description: "Decline this tool call and continue.".to_string(),
},
]),
}]);
assert_eq!(
schema,
serde_json::json!({
"type": "object",
"properties": {
"approval": {
"title": "Approve app tool call?",
"description": "Allow this action?",
"type": "string",
"enum": [
MCP_TOOL_APPROVAL_ACCEPT,
MCP_TOOL_APPROVAL_DECLINE,
],
"x-codex-options": [
{
"label": MCP_TOOL_APPROVAL_ACCEPT,
"description": "Run the tool and continue.",
},
{
"label": MCP_TOOL_APPROVAL_DECLINE,
"description": "Decline this tool call and continue.",
},
],
},
},
"required": ["approval"],
"additionalProperties": false,
"x-codex-request-user-input": {
"questions": [{
"id": "approval",
"header": "Approve app tool call?",
"question": "Allow this action?",
"isOther": false,
"isSecret": false,
"options": [
{
"label": MCP_TOOL_APPROVAL_ACCEPT,
"description": "Run the tool and continue.",
},
{
"label": MCP_TOOL_APPROVAL_DECLINE,
"description": "Decline this tool call and continue.",
},
],
}],
},
})
);
}
#[test]
fn accepted_elicitation_content_converts_to_request_user_input_response() {
let response =
@@ -1029,6 +1053,95 @@ mod tests {
);
}
#[test]
fn approval_elicitation_meta_keeps_session_persist_behavior() {
assert_eq!(
build_mcp_tool_approval_elicitation_meta(
"custom_server",
Some(&approval_metadata(
None,
None,
None,
Some("Run Action"),
Some("Runs the selected action."),
)),
Some(&serde_json::json!({"id": 1})),
true,
),
Some(serde_json::json!({
MCP_TOOL_APPROVAL_PERSIST_KEY: MCP_TOOL_APPROVAL_PERSIST_SESSION,
MCP_TOOL_APPROVAL_TOOL_TITLE_KEY: "Run Action",
MCP_TOOL_APPROVAL_TOOL_DESCRIPTION_KEY: "Runs the selected action.",
MCP_TOOL_APPROVAL_TOOL_PARAMS_KEY: {
"id": 1,
},
}))
);
}
#[test]
fn approval_elicitation_meta_includes_connector_source_for_codex_apps() {
assert_eq!(
build_mcp_tool_approval_elicitation_meta(
CODEX_APPS_MCP_SERVER_NAME,
Some(&approval_metadata(
Some("calendar"),
Some("Calendar"),
Some("Manage events and schedules."),
Some("Run Action"),
Some("Runs the selected action."),
)),
Some(&serde_json::json!({
"calendar_id": "primary",
})),
false,
),
Some(serde_json::json!({
MCP_TOOL_APPROVAL_SOURCE_KEY: MCP_TOOL_APPROVAL_SOURCE_CONNECTOR,
MCP_TOOL_APPROVAL_CONNECTOR_ID_KEY: "calendar",
MCP_TOOL_APPROVAL_CONNECTOR_NAME_KEY: "Calendar",
MCP_TOOL_APPROVAL_CONNECTOR_DESCRIPTION_KEY: "Manage events and schedules.",
MCP_TOOL_APPROVAL_TOOL_TITLE_KEY: "Run Action",
MCP_TOOL_APPROVAL_TOOL_DESCRIPTION_KEY: "Runs the selected action.",
MCP_TOOL_APPROVAL_TOOL_PARAMS_KEY: {
"calendar_id": "primary",
},
}))
);
}
#[test]
fn approval_elicitation_meta_merges_session_persist_with_connector_source() {
assert_eq!(
build_mcp_tool_approval_elicitation_meta(
CODEX_APPS_MCP_SERVER_NAME,
Some(&approval_metadata(
Some("calendar"),
Some("Calendar"),
Some("Manage events and schedules."),
Some("Run Action"),
Some("Runs the selected action."),
)),
Some(&serde_json::json!({
"calendar_id": "primary",
})),
true,
),
Some(serde_json::json!({
MCP_TOOL_APPROVAL_PERSIST_KEY: MCP_TOOL_APPROVAL_PERSIST_SESSION,
MCP_TOOL_APPROVAL_SOURCE_KEY: MCP_TOOL_APPROVAL_SOURCE_CONNECTOR,
MCP_TOOL_APPROVAL_CONNECTOR_ID_KEY: "calendar",
MCP_TOOL_APPROVAL_CONNECTOR_NAME_KEY: "Calendar",
MCP_TOOL_APPROVAL_CONNECTOR_DESCRIPTION_KEY: "Manage events and schedules.",
MCP_TOOL_APPROVAL_TOOL_TITLE_KEY: "Run Action",
MCP_TOOL_APPROVAL_TOOL_DESCRIPTION_KEY: "Runs the selected action.",
MCP_TOOL_APPROVAL_TOOL_PARAMS_KEY: {
"calendar_id": "primary",
},
}))
);
}
#[test]
fn declined_elicitation_response_stays_decline() {
let response = parse_mcp_tool_approval_elicitation_response(
@@ -1037,10 +1150,41 @@ mod tests {
content: Some(serde_json::json!({
"approval": MCP_TOOL_APPROVAL_ACCEPT,
})),
meta: None,
}),
"approval",
);
assert_eq!(response, McpToolApprovalDecision::Decline);
}
#[test]
fn accepted_elicitation_response_uses_session_persist_meta() {
let response = parse_mcp_tool_approval_elicitation_response(
Some(ElicitationResponse {
action: ElicitationAction::Accept,
content: None,
meta: Some(serde_json::json!({
MCP_TOOL_APPROVAL_PERSIST_KEY: MCP_TOOL_APPROVAL_PERSIST_SESSION,
})),
}),
"approval",
);
assert_eq!(response, McpToolApprovalDecision::AcceptAndRemember);
}
#[test]
fn accepted_elicitation_without_content_defaults_to_accept() {
let response = parse_mcp_tool_approval_elicitation_response(
Some(ElicitationResponse {
action: ElicitationAction::Accept,
content: None,
meta: None,
}),
"approval",
);
assert_eq!(response, McpToolApprovalDecision::Accept);
}
}
+1
View File
@@ -692,6 +692,7 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
request_id: ev.id.clone(),
decision: ElicitationAction::Cancel,
content: None,
meta: None,
})
.await?;
}
+10
View File
@@ -196,10 +196,16 @@ impl ExecApprovalRequestEvent {
#[ts(tag = "mode")]
pub enum ElicitationRequest {
Form {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
#[ts(optional, rename = "_meta")]
meta: Option<JsonValue>,
message: String,
requested_schema: JsonValue,
},
Url {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
#[ts(optional, rename = "_meta")]
meta: Option<JsonValue>,
message: String,
url: String,
elicitation_id: String,
@@ -216,6 +222,10 @@ impl ElicitationRequest {
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
pub struct ElicitationRequestEvent {
/// Turn ID that this elicitation belongs to, when known.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub turn_id: Option<String>,
pub server_name: String,
#[ts(type = "string | number")]
pub id: RequestId,
+3
View File
@@ -334,6 +334,9 @@ pub enum Op {
/// Structured user input supplied for accepted elicitations.
#[serde(default, skip_serializing_if = "Option::is_none")]
content: Option<Value>,
/// Optional client metadata associated with the elicitation response.
#[serde(default, skip_serializing_if = "Option::is_none")]
meta: Option<Value>,
},
/// Resolve a request_user_input tool call.
@@ -42,6 +42,7 @@ impl ClientHandler for LoggingClientHandler {
) -> Result<CreateElicitationResult, rmcp::ErrorData> {
(self.send_elicitation)(context.id, request)
.await
.map(Into::into)
.map_err(|err| rmcp::ErrorData::internal_error(err.to_string(), None))
}
+31 -1
View File
@@ -21,6 +21,7 @@ use rmcp::model::CreateElicitationRequestParams;
use rmcp::model::CreateElicitationResult;
use rmcp::model::CustomNotification;
use rmcp::model::CustomRequest;
use rmcp::model::ElicitationAction;
use rmcp::model::Extensions;
use rmcp::model::InitializeRequestParams;
use rmcp::model::InitializeResult;
@@ -42,6 +43,8 @@ use rmcp::transport::auth::AuthError;
use rmcp::transport::auth::OAuthState;
use rmcp::transport::child_process::TokioChildProcess;
use rmcp::transport::streamable_http_client::StreamableHttpClientTransportConfig;
use serde::Deserialize;
use serde::Serialize;
use serde_json::Value;
use tokio::io::AsyncBufReadExt;
use tokio::io::BufReader;
@@ -147,7 +150,34 @@ impl Drop for ProcessGroupGuard {
}
pub type Elicitation = CreateElicitationRequestParams;
pub type ElicitationResponse = CreateElicitationResult;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ElicitationResponse {
pub action: ElicitationAction,
pub content: Option<serde_json::Value>,
#[serde(rename = "_meta")]
pub meta: Option<serde_json::Value>,
}
impl From<CreateElicitationResult> for ElicitationResponse {
fn from(value: CreateElicitationResult) -> Self {
Self {
action: value.action,
content: value.content,
meta: None,
}
}
}
impl From<ElicitationResponse> for CreateElicitationResult {
fn from(value: ElicitationResponse) -> Self {
Self {
action: value.action,
content: value.content,
}
}
}
/// Interface for sending elicitation requests to the UI and awaiting a response.
pub type SendElicitation = Box<
+1
View File
@@ -73,6 +73,7 @@ async fn rmcp_client_can_list_and_read_resources() -> anyhow::Result<()> {
Ok(ElicitationResponse {
action: ElicitationAction::Accept,
content: Some(json!({})),
meta: None,
})
}
.boxed()
+62 -34
View File
@@ -7,6 +7,7 @@ use crate::app_event::WindowsSandboxEnableMode;
use crate::app_event_sender::AppEventSender;
use crate::bottom_pane::ApprovalRequest;
use crate::bottom_pane::FeedbackAudience;
use crate::bottom_pane::McpServerElicitationFormRequest;
use crate::bottom_pane::SelectionItem;
use crate::bottom_pane::SelectionViewParams;
use crate::bottom_pane::popup_consts::standard_popup_hint_line;
@@ -116,6 +117,11 @@ use self::pending_interactive_replay::PendingInteractiveReplayState;
const EXTERNAL_EDITOR_HINT: &str = "Save and close external editor to continue.";
const THREAD_EVENT_CHANNEL_CAPACITY: usize = 32768;
enum ThreadInteractiveRequest {
Approval(ApprovalRequest),
McpServerElicitation(McpServerElicitationFormRequest),
}
/// Baseline cadence for periodic stream commit animation ticks.
///
/// Smooth-mode streaming drains one line per tick, so this interval controls
@@ -1010,41 +1016,55 @@ impl App {
}
}
async fn approval_request_for_thread_event(
async fn interactive_request_for_thread_event(
&self,
thread_id: ThreadId,
event: &Event,
) -> Option<ApprovalRequest> {
) -> Option<ThreadInteractiveRequest> {
let thread_label = Some(self.thread_label(thread_id));
match &event.msg {
EventMsg::ExecApprovalRequest(ev) => Some(ApprovalRequest::Exec {
thread_id,
thread_label,
id: ev.effective_approval_id(),
command: ev.command.clone(),
reason: ev.reason.clone(),
available_decisions: ev.effective_available_decisions(),
network_approval_context: ev.network_approval_context.clone(),
additional_permissions: ev.additional_permissions.clone(),
}),
EventMsg::ApplyPatchApprovalRequest(ev) => Some(ApprovalRequest::ApplyPatch {
thread_id,
thread_label,
id: ev.call_id.clone(),
reason: ev.reason.clone(),
cwd: self
.thread_cwd(thread_id)
.await
.unwrap_or_else(|| self.config.cwd.clone()),
changes: ev.changes.clone(),
}),
EventMsg::ElicitationRequest(ev) => Some(ApprovalRequest::McpElicitation {
thread_id,
thread_label,
server_name: ev.server_name.clone(),
request_id: ev.id.clone(),
message: ev.request.message().to_string(),
}),
EventMsg::ExecApprovalRequest(ev) => {
Some(ThreadInteractiveRequest::Approval(ApprovalRequest::Exec {
thread_id,
thread_label,
id: ev.effective_approval_id(),
command: ev.command.clone(),
reason: ev.reason.clone(),
available_decisions: ev.effective_available_decisions(),
network_approval_context: ev.network_approval_context.clone(),
additional_permissions: ev.additional_permissions.clone(),
}))
}
EventMsg::ApplyPatchApprovalRequest(ev) => Some(ThreadInteractiveRequest::Approval(
ApprovalRequest::ApplyPatch {
thread_id,
thread_label,
id: ev.call_id.clone(),
reason: ev.reason.clone(),
cwd: self
.thread_cwd(thread_id)
.await
.unwrap_or_else(|| self.config.cwd.clone()),
changes: ev.changes.clone(),
},
)),
EventMsg::ElicitationRequest(ev) => {
if let Some(request) =
McpServerElicitationFormRequest::from_event(thread_id, ev.clone())
{
Some(ThreadInteractiveRequest::McpServerElicitation(request))
} else {
Some(ThreadInteractiveRequest::Approval(
ApprovalRequest::McpElicitation {
thread_id,
thread_label,
server_name: ev.server_name.clone(),
request_id: ev.id.clone(),
message: ev.request.message().to_string(),
},
))
}
}
_ => None,
}
}
@@ -1112,8 +1132,8 @@ impl App {
async fn enqueue_thread_event(&mut self, thread_id: ThreadId, event: Event) -> Result<()> {
let refresh_pending_thread_approvals =
ThreadEventStore::event_can_change_pending_thread_approvals(&event);
let inactive_approval_request = if self.active_thread_id != Some(thread_id) {
self.approval_request_for_thread_event(thread_id, &event)
let inactive_interactive_request = if self.active_thread_id != Some(thread_id) {
self.interactive_request_for_thread_event(thread_id, &event)
.await
} else {
None
@@ -1146,8 +1166,16 @@ impl App {
tracing::warn!("thread {thread_id} event channel closed");
}
}
} else if let Some(request) = inactive_approval_request {
self.chat_widget.push_approval_request(request);
} else if let Some(request) = inactive_interactive_request {
match request {
ThreadInteractiveRequest::Approval(request) => {
self.chat_widget.push_approval_request(request);
}
ThreadInteractiveRequest::McpServerElicitation(request) => {
self.chat_widget
.push_mcp_server_elicitation_request(request);
}
}
}
if refresh_pending_thread_approvals {
self.refresh_pending_thread_approvals().await;
@@ -586,9 +586,11 @@ mod tests {
store.push_event(Event {
id: "ev-1".to_string(),
msg: EventMsg::ElicitationRequest(codex_protocol::approvals::ElicitationRequestEvent {
turn_id: Some("turn-1".to_string()),
server_name: "server-1".to_string(),
id: request_id.clone(),
request: codex_protocol::approvals::ElicitationRequest::Form {
meta: None,
message: "Please confirm".to_string(),
requested_schema: serde_json::json!({
"type": "object",
@@ -603,6 +605,7 @@ mod tests {
request_id,
decision: codex_protocol::approvals::ElicitationAction::Accept,
content: None,
meta: None,
});
let snapshot = store.snapshot();
@@ -281,6 +281,7 @@ impl ApprovalOverlay {
request_id: request_id.clone(),
decision,
content: None,
meta: None,
},
});
}
@@ -1,4 +1,5 @@
use crate::bottom_pane::ApprovalRequest;
use crate::bottom_pane::McpServerElicitationFormRequest;
use crate::render::renderable::Renderable;
use codex_protocol::request_user_input::RequestUserInputEvent;
use crossterm::event::KeyEvent;
@@ -71,4 +72,13 @@ pub(crate) trait BottomPaneView: Renderable {
) -> Option<RequestUserInputEvent> {
Some(request)
}
/// Try to handle a supported MCP server elicitation form request; return the original value if
/// not consumed.
fn try_consume_mcp_server_elicitation_request(
&mut self,
request: McpServerElicitationFormRequest,
) -> Option<McpServerElicitationFormRequest> {
Some(request)
}
}
File diff suppressed because it is too large Load Diff
+34
View File
@@ -42,6 +42,7 @@ use std::time::Duration;
mod app_link_view;
mod approval_overlay;
mod mcp_server_elicitation;
mod multi_select_picker;
mod request_user_input;
mod status_line_setup;
@@ -49,6 +50,8 @@ pub(crate) use app_link_view::AppLinkView;
pub(crate) use app_link_view::AppLinkViewParams;
pub(crate) use approval_overlay::ApprovalOverlay;
pub(crate) use approval_overlay::ApprovalRequest;
pub(crate) use mcp_server_elicitation::McpServerElicitationFormRequest;
pub(crate) use mcp_server_elicitation::McpServerElicitationOverlay;
pub(crate) use request_user_input::RequestUserInputOverlay;
mod bottom_pane_view;
@@ -920,6 +923,37 @@ impl BottomPane {
self.push_view(Box::new(modal));
}
pub(crate) fn push_mcp_server_elicitation_request(
&mut self,
request: McpServerElicitationFormRequest,
) {
let request = if let Some(view) = self.view_stack.last_mut() {
match view.try_consume_mcp_server_elicitation_request(request) {
Some(request) => request,
None => {
self.request_redraw();
return;
}
}
} else {
request
};
let modal = McpServerElicitationOverlay::new(
request,
self.app_event_tx.clone(),
self.has_input_focus,
self.enhanced_keys_supported,
self.disable_paste_burst,
);
self.pause_status_timer_for_modal();
self.set_composer_input_enabled(
false,
Some("Respond to the MCP server request to continue.".to_string()),
);
self.push_view(Box::new(modal));
}
fn on_active_view_complete(&mut self) {
self.resume_status_timer_after_modal();
self.set_composer_input_enabled(true, None);
@@ -0,0 +1,19 @@
---
source: tui/src/bottom_pane/mcp_server_elicitation.rs
expression: "render_snapshot(&overlay, Rect::new(0, 0, 120, 16))"
---
Field 1/1
Allow this request?
› 1. Approve Once Run the tool and continue.
2. Approve this Session Run the tool and remember this choice for this session.
3. Deny Decline this tool call and continue.
4. Cancel Cancel this tool call
enter to submit | esc to cancel
@@ -0,0 +1,19 @@
---
source: tui/src/bottom_pane/mcp_server_elicitation.rs
expression: "render_snapshot(&overlay, Rect::new(0, 0, 120, 16))"
---
Field 1/1
Allow this request?
› 1. Approve Once Run the tool and continue.
2. Deny Decline this tool call and continue.
3. Cancel Cancel this tool call
enter to submit | esc to cancel
@@ -0,0 +1,19 @@
---
source: tui/src/bottom_pane/mcp_server_elicitation.rs
expression: "render_snapshot(&overlay, Rect::new(0, 0, 120, 16))"
---
Field 1/1 (1 required unanswered)
Allow this request?
Confirm
Approve the pending action.
› 1. True
2. False
enter to submit | esc to cancel
+25 -9
View File
@@ -224,6 +224,7 @@ use crate::bottom_pane::ExperimentalFeaturesView;
use crate::bottom_pane::FeedbackAudience;
use crate::bottom_pane::InputResult;
use crate::bottom_pane::LocalImageAttachment;
use crate::bottom_pane::McpServerElicitationFormRequest;
use crate::bottom_pane::MentionBinding;
use crate::bottom_pane::QUIT_SHORTCUT_TIMEOUT;
use crate::bottom_pane::SelectionAction;
@@ -2873,15 +2874,21 @@ impl ChatWidget {
server_name: ev.server_name.clone(),
});
let request = ApprovalRequest::McpElicitation {
thread_id: self.thread_id.unwrap_or_default(),
thread_label: None,
server_name: ev.server_name,
request_id: ev.id,
message: ev.request.message().to_string(),
};
self.bottom_pane
.push_approval_request(request, &self.config.features);
let thread_id = self.thread_id.unwrap_or_default();
if let Some(request) = McpServerElicitationFormRequest::from_event(thread_id, ev.clone()) {
self.bottom_pane
.push_mcp_server_elicitation_request(request);
} else {
let request = ApprovalRequest::McpElicitation {
thread_id,
thread_label: None,
server_name: ev.server_name,
request_id: ev.id,
message: ev.request.message().to_string(),
};
self.bottom_pane
.push_approval_request(request, &self.config.features);
}
self.request_redraw();
}
@@ -2891,6 +2898,15 @@ impl ChatWidget {
self.request_redraw();
}
pub(crate) fn push_mcp_server_elicitation_request(
&mut self,
request: McpServerElicitationFormRequest,
) {
self.bottom_pane
.push_mcp_server_elicitation_request(request);
self.request_redraw();
}
pub(crate) fn handle_request_user_input_now(&mut self, ev: RequestUserInputEvent) {
self.flush_answer_stream_with_separator();
self.notify(Notification::UserInputRequested {