Wire agent-control MCP URL into codex agents

This commit is contained in:
Mohamed Boudra
2025-12-23 15:08:34 +07:00
parent e2ba6c8634
commit 077ecae607
2 changed files with 12 additions and 1 deletions
+11 -1
View File
@@ -33,6 +33,10 @@ export interface AgentMcpServerOptions {
* When set, create_agent will auto-inject this as parentAgentId. * When set, create_agent will auto-inject this as parentAgentId.
*/ */
callerAgentId?: string; callerAgentId?: string;
/**
* Agent-control MCP URL to inject for Codex agents spawned via MCP.
*/
agentControlMcpUrl?: string;
} }
const AgentProviderEnum = z.enum( const AgentProviderEnum = z.enum(
@@ -171,7 +175,8 @@ async function serializeSnapshotWithMetadata(
export async function createAgentMcpServer( export async function createAgentMcpServer(
options: AgentMcpServerOptions options: AgentMcpServerOptions
): Promise<McpServer> { ): Promise<McpServer> {
const { agentManager, agentRegistry, callerAgentId } = options; const { agentManager, agentRegistry, callerAgentId, agentControlMcpUrl } =
options;
const waitTracker = new WaitForAgentTracker(); const waitTracker = new WaitForAgentTracker();
const server = new McpServer({ const server = new McpServer({
@@ -274,12 +279,17 @@ export async function createAgentMcpServer(
const normalizedTitle = title?.trim() ?? null; const normalizedTitle = title?.trim() ?? null;
// Use explicit parentAgentId if provided, otherwise default to caller agent ID // Use explicit parentAgentId if provided, otherwise default to caller agent ID
const resolvedParentAgentId = parentAgentId ?? callerAgentId; const resolvedParentAgentId = parentAgentId ?? callerAgentId;
const codexExtra =
provider === "codex" && agentControlMcpUrl
? { codex: { agentControlMcpUrl } }
: undefined;
const snapshot = await agentManager.createAgent({ const snapshot = await agentManager.createAgent({
provider, provider,
cwd: resolvedCwd, cwd: resolvedCwd,
modeId: initialMode, modeId: initialMode,
title: normalizedTitle ?? undefined, title: normalizedTitle ?? undefined,
parentAgentId: resolvedParentAgentId, parentAgentId: resolvedParentAgentId,
extra: codexExtra,
}); });
if (initialPrompt) { if (initialPrompt) {
+1
View File
@@ -123,6 +123,7 @@ async function main() {
agentManager, agentManager,
agentRegistry, agentRegistry,
callerAgentId, callerAgentId,
agentControlMcpUrl: agentMcpUrl,
}); });
const transport = new StreamableHTTPServerTransport({ const transport = new StreamableHTTPServerTransport({