Skip to content

Commit b7139a7

Browse files
authored
[mcp] Support MCP Apps part 3 - Add mcp tool call support. (#17364)
- [x] Add a new app-server method so that MCP Apps can call their own MCP server directly.
1 parent f8bb088 commit b7139a7

112 files changed

Lines changed: 871 additions & 238 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codex-rs/app-server-protocol/schema/json/ClientRequest.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,27 @@
12771277
],
12781278
"type": "string"
12791279
},
1280+
"McpServerToolCallParams": {
1281+
"properties": {
1282+
"_meta": true,
1283+
"arguments": true,
1284+
"server": {
1285+
"type": "string"
1286+
},
1287+
"threadId": {
1288+
"type": "string"
1289+
},
1290+
"tool": {
1291+
"type": "string"
1292+
}
1293+
},
1294+
"required": [
1295+
"server",
1296+
"threadId",
1297+
"tool"
1298+
],
1299+
"type": "object"
1300+
},
12801301
"MergeStrategy": {
12811302
"enum": [
12821303
"replace",
@@ -4569,6 +4590,30 @@
45694590
"title": "McpServer/resource/readRequest",
45704591
"type": "object"
45714592
},
4593+
{
4594+
"properties": {
4595+
"id": {
4596+
"$ref": "#/definitions/RequestId"
4597+
},
4598+
"method": {
4599+
"enum": [
4600+
"mcpServer/tool/call"
4601+
],
4602+
"title": "McpServer/tool/callRequestMethod",
4603+
"type": "string"
4604+
},
4605+
"params": {
4606+
"$ref": "#/definitions/McpServerToolCallParams"
4607+
}
4608+
},
4609+
"required": [
4610+
"id",
4611+
"method",
4612+
"params"
4613+
],
4614+
"title": "McpServer/tool/callRequest",
4615+
"type": "object"
4616+
},
45724617
{
45734618
"properties": {
45744619
"id": {

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,30 @@
12251225
"title": "McpServer/resource/readRequest",
12261226
"type": "object"
12271227
},
1228+
{
1229+
"properties": {
1230+
"id": {
1231+
"$ref": "#/definitions/v2/RequestId"
1232+
},
1233+
"method": {
1234+
"enum": [
1235+
"mcpServer/tool/call"
1236+
],
1237+
"title": "McpServer/tool/callRequestMethod",
1238+
"type": "string"
1239+
},
1240+
"params": {
1241+
"$ref": "#/definitions/v2/McpServerToolCallParams"
1242+
}
1243+
},
1244+
"required": [
1245+
"id",
1246+
"method",
1247+
"params"
1248+
],
1249+
"title": "McpServer/tool/callRequest",
1250+
"type": "object"
1251+
},
12281252
{
12291253
"properties": {
12301254
"id": {
@@ -9214,6 +9238,51 @@
92149238
"title": "McpServerStatusUpdatedNotification",
92159239
"type": "object"
92169240
},
9241+
"McpServerToolCallParams": {
9242+
"$schema": "http://json-schema.org/draft-07/schema#",
9243+
"properties": {
9244+
"_meta": true,
9245+
"arguments": true,
9246+
"server": {
9247+
"type": "string"
9248+
},
9249+
"threadId": {
9250+
"type": "string"
9251+
},
9252+
"tool": {
9253+
"type": "string"
9254+
}
9255+
},
9256+
"required": [
9257+
"server",
9258+
"threadId",
9259+
"tool"
9260+
],
9261+
"title": "McpServerToolCallParams",
9262+
"type": "object"
9263+
},
9264+
"McpServerToolCallResponse": {
9265+
"$schema": "http://json-schema.org/draft-07/schema#",
9266+
"properties": {
9267+
"_meta": true,
9268+
"content": {
9269+
"items": true,
9270+
"type": "array"
9271+
},
9272+
"isError": {
9273+
"type": [
9274+
"boolean",
9275+
"null"
9276+
]
9277+
},
9278+
"structuredContent": true
9279+
},
9280+
"required": [
9281+
"content"
9282+
],
9283+
"title": "McpServerToolCallResponse",
9284+
"type": "object"
9285+
},
92179286
"McpToolCallError": {
92189287
"properties": {
92199288
"message": {

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,30 @@
18071807
"title": "McpServer/resource/readRequest",
18081808
"type": "object"
18091809
},
1810+
{
1811+
"properties": {
1812+
"id": {
1813+
"$ref": "#/definitions/RequestId"
1814+
},
1815+
"method": {
1816+
"enum": [
1817+
"mcpServer/tool/call"
1818+
],
1819+
"title": "McpServer/tool/callRequestMethod",
1820+
"type": "string"
1821+
},
1822+
"params": {
1823+
"$ref": "#/definitions/McpServerToolCallParams"
1824+
}
1825+
},
1826+
"required": [
1827+
"id",
1828+
"method",
1829+
"params"
1830+
],
1831+
"title": "McpServer/tool/callRequest",
1832+
"type": "object"
1833+
},
18101834
{
18111835
"properties": {
18121836
"id": {
@@ -6010,6 +6034,51 @@
60106034
"title": "McpServerStatusUpdatedNotification",
60116035
"type": "object"
60126036
},
6037+
"McpServerToolCallParams": {
6038+
"$schema": "http://json-schema.org/draft-07/schema#",
6039+
"properties": {
6040+
"_meta": true,
6041+
"arguments": true,
6042+
"server": {
6043+
"type": "string"
6044+
},
6045+
"threadId": {
6046+
"type": "string"
6047+
},
6048+
"tool": {
6049+
"type": "string"
6050+
}
6051+
},
6052+
"required": [
6053+
"server",
6054+
"threadId",
6055+
"tool"
6056+
],
6057+
"title": "McpServerToolCallParams",
6058+
"type": "object"
6059+
},
6060+
"McpServerToolCallResponse": {
6061+
"$schema": "http://json-schema.org/draft-07/schema#",
6062+
"properties": {
6063+
"_meta": true,
6064+
"content": {
6065+
"items": true,
6066+
"type": "array"
6067+
},
6068+
"isError": {
6069+
"type": [
6070+
"boolean",
6071+
"null"
6072+
]
6073+
},
6074+
"structuredContent": true
6075+
},
6076+
"required": [
6077+
"content"
6078+
],
6079+
"title": "McpServerToolCallResponse",
6080+
"type": "object"
6081+
},
60136082
"McpToolCallError": {
60146083
"properties": {
60156084
"message": {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"properties": {
4+
"_meta": true,
5+
"arguments": true,
6+
"server": {
7+
"type": "string"
8+
},
9+
"threadId": {
10+
"type": "string"
11+
},
12+
"tool": {
13+
"type": "string"
14+
}
15+
},
16+
"required": [
17+
"server",
18+
"threadId",
19+
"tool"
20+
],
21+
"title": "McpServerToolCallParams",
22+
"type": "object"
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"properties": {
4+
"_meta": true,
5+
"content": {
6+
"items": true,
7+
"type": "array"
8+
},
9+
"isError": {
10+
"type": [
11+
"boolean",
12+
"null"
13+
]
14+
},
15+
"structuredContent": true
16+
},
17+
"required": [
18+
"content"
19+
],
20+
"title": "McpServerToolCallResponse",
21+
"type": "object"
22+
}

codex-rs/app-server-protocol/schema/typescript/ApplyPatchApprovalParams.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import type { FileChange } from "./FileChange";
55
import type { ThreadId } from "./ThreadId";
66

7-
export type ApplyPatchApprovalParams = { conversationId: ThreadId,
7+
export type ApplyPatchApprovalParams = { conversationId: ThreadId,
88
/**
99
* Use to correlate this with [codex_protocol::protocol::PatchApplyBeginEvent]
1010
* and [codex_protocol::protocol::PatchApplyEndEvent].
1111
*/
12-
callId: string, fileChanges: { [key in string]?: FileChange },
12+
callId: string, fileChanges: { [key in string]?: FileChange },
1313
/**
1414
* Optional explanatory reason (e.g. request for extra write access).
1515
*/
16-
reason: string | null,
16+
reason: string | null,
1717
/**
1818
* When set, the agent is asking the user to allow writes under this root
1919
* for the remainder of the session (unclear if this is honored today).

codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import type { ListMcpServerStatusParams } from "./v2/ListMcpServerStatusParams";
3535
import type { LoginAccountParams } from "./v2/LoginAccountParams";
3636
import type { McpResourceReadParams } from "./v2/McpResourceReadParams";
3737
import type { McpServerOauthLoginParams } from "./v2/McpServerOauthLoginParams";
38+
import type { McpServerToolCallParams } from "./v2/McpServerToolCallParams";
3839
import type { ModelListParams } from "./v2/ModelListParams";
3940
import type { PluginInstallParams } from "./v2/PluginInstallParams";
4041
import type { PluginListParams } from "./v2/PluginListParams";
@@ -65,4 +66,4 @@ import type { WindowsSandboxSetupStartParams } from "./v2/WindowsSandboxSetupSta
6566
/**
6667
* Request from the client to the server.
6768
*/
68-
export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, };
69+
export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "mcpServer/tool/call", id: RequestId, params: McpServerToolCallParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, };

codex-rs/app-server-protocol/schema/typescript/ExecCommandApprovalParams.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import type { ParsedCommand } from "./ParsedCommand";
55
import type { ThreadId } from "./ThreadId";
66

7-
export type ExecCommandApprovalParams = { conversationId: ThreadId,
7+
export type ExecCommandApprovalParams = { conversationId: ThreadId,
88
/**
99
* Use to correlate this with [codex_protocol::protocol::ExecCommandBeginEvent]
1010
* and [codex_protocol::protocol::ExecCommandEndEvent].
1111
*/
12-
callId: string,
12+
callId: string,
1313
/**
1414
* Identifier for this specific approval callback.
1515
*/

codex-rs/app-server-protocol/schema/typescript/InitializeCapabilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
/**
66
* Client-declared capabilities negotiated during initialize.
77
*/
8-
export type InitializeCapabilities = {
8+
export type InitializeCapabilities = {
99
/**
1010
* Opt into receiving experimental API methods and fields.
1111
*/
12-
experimentalApi: boolean,
12+
experimentalApi: boolean,
1313
/**
1414
* Exact notification method names that should be suppressed for this
1515
* connection (for example `thread/started`).

codex-rs/app-server-protocol/schema/typescript/InitializeResponse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
44
import type { AbsolutePathBuf } from "./AbsolutePathBuf";
55

6-
export type InitializeResponse = { userAgent: string,
6+
export type InitializeResponse = { userAgent: string,
77
/**
88
* Absolute path to the server's $CODEX_HOME directory.
99
*/
10-
codexHome: AbsolutePathBuf,
10+
codexHome: AbsolutePathBuf,
1111
/**
1212
* Platform family for the running app-server target, for example
1313
* `"unix"` or `"windows"`.
1414
*/
15-
platformFamily: string,
15+
platformFamily: string,
1616
/**
1717
* Operating system for the running app-server target, for example
1818
* `"macos"`, `"linux"`, or `"windows"`.

0 commit comments

Comments
 (0)