@@ -126,6 +126,7 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
126
126
coderPrompt string
127
127
appStatusSlug string
128
128
testBinaryName string
129
+ llmAgentURL url.URL
129
130
130
131
deprecatedCoderMCPClaudeAPIKey string
131
132
)
@@ -164,6 +165,9 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
164
165
if appStatusSlug != "" {
165
166
configureClaudeEnv [envAppStatusSlug ] = appStatusSlug
166
167
}
168
+ if llmAgentURL .String () != "" {
169
+ configureClaudeEnv [envLLMAgentURL ] = llmAgentURL .String ()
170
+ }
167
171
if deprecatedSystemPromptEnv , ok := os .LookupEnv ("SYSTEM_PROMPT" ); ok {
168
172
cliui .Warnf (inv .Stderr , "SYSTEM_PROMPT is deprecated, use CODER_MCP_CLAUDE_SYSTEM_PROMPT instead" )
169
173
systemPrompt = deprecatedSystemPromptEnv
@@ -262,6 +266,12 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
262
266
Flag : "claude-app-status-slug" ,
263
267
Value : serpent .StringOf (& appStatusSlug ),
264
268
},
269
+ {
270
+ Flag : "llm-agent-url" ,
271
+ Description : "The URL of the LLM agent API, used to listen for status updates." ,
272
+ Env : envLLMAgentURL ,
273
+ Value : serpent .URLOf (& llmAgentURL ),
274
+ },
265
275
{
266
276
Name : "test-binary-name" ,
267
277
Description : "Only used for testing." ,
@@ -446,7 +456,9 @@ func (r *RootCmd) mcpServer() *serpent.Command {
446
456
defer srv .queue .Close ()
447
457
448
458
cliui .Infof (inv .Stderr , "Failed to watch screen events" )
449
- // Start the reporter, watcher, and server.
459
+ // Start the reporter, watcher, and server. These are all tied to the
460
+ // lifetime of the MCP server, which is itself tied to the lifetime of the
461
+ // LLM agent.
450
462
if srv .agentClient != nil && appStatusSlug != "" {
451
463
srv .startReporter (ctx , inv )
452
464
if srv .llmClient != nil {
0 commit comments