MCPcopy Create free account
hub / github.com/tiann/hapi / buildSessionStartHookConfigArgs

Function buildSessionStartHookConfigArgs

cli/src/codex/utils/codexMcpConfig.ts:97–112  ·  view source on GitHub ↗
(port: number, token: string)

Source from the content-addressed store, hash-verified

95}
96
97export function buildSessionStartHookConfigArgs(port: number, token: string): string[] {
98 const { command, args } = getHappyCliCommand([
99 'hook-forwarder',
100 '--port',
101 String(port),
102 '--token',
103 token
104 ]);
105 const hookCommand = shellJoin([command, ...args]);
106 const escapedHookCommand = escapeTomlString(hookCommand);
107 const hookConfig = `hooks.SessionStart=[{ hooks = [{ type = "command", command = "${escapedHookCommand}" }] }]`;
108 const trustedHash = buildSessionStartHookTrustedHash(hookCommand);
109 const escapedStateKey = escapeTomlString(sessionFlagsHookStateKey());
110 const hookState = `hooks.state={"${escapedStateKey}"={trusted_hash="${trustedHash}"}}`;
111 return ['-c', hookConfig, '-c', hookState];
112}
113
114/**
115 * Build -c arguments for MCP server configuration.

Callers 2

codexLocalFunction · 0.90

Calls 5

getHappyCliCommandFunction · 0.90
escapeTomlStringFunction · 0.85
sessionFlagsHookStateKeyFunction · 0.85
shellJoinFunction · 0.70

Tested by

no test coverage detected