@@ -28,7 +28,7 @@ import (
28
28
29
29
const (
30
30
envAppStatusSlug = "CODER_MCP_APP_STATUS_SLUG"
31
- envLLMAgentURL = "CODER_MCP_LLM_AGENT_URL "
31
+ envAIAgentAPIURL = "CODER_MCP_AI_AGENTAPI_URL "
32
32
)
33
33
34
34
func (r * RootCmd ) mcpCommand () * serpent.Command {
@@ -126,7 +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
+ aiAgentAPIURL url.URL
130
130
131
131
deprecatedCoderMCPClaudeAPIKey string
132
132
)
@@ -165,8 +165,8 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
165
165
if appStatusSlug != "" {
166
166
configureClaudeEnv [envAppStatusSlug ] = appStatusSlug
167
167
}
168
- if llmAgentURL .String () != "" {
169
- configureClaudeEnv [envLLMAgentURL ] = llmAgentURL .String ()
168
+ if aiAgentAPIURL .String () != "" {
169
+ configureClaudeEnv [envAIAgentAPIURL ] = aiAgentAPIURL .String ()
170
170
}
171
171
if deprecatedSystemPromptEnv , ok := os .LookupEnv ("SYSTEM_PROMPT" ); ok {
172
172
cliui .Warnf (inv .Stderr , "SYSTEM_PROMPT is deprecated, use CODER_MCP_CLAUDE_SYSTEM_PROMPT instead" )
@@ -267,10 +267,10 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
267
267
Value : serpent .StringOf (& appStatusSlug ),
268
268
},
269
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 ),
270
+ Flag : "ai-agentapi -url" ,
271
+ Description : "The URL of the AI AgentAPI , used to listen for status updates." ,
272
+ Env : envAIAgentAPIURL ,
273
+ Value : serpent .URLOf (& aiAgentAPIURL ),
274
274
},
275
275
{
276
276
Name : "test-binary-name" ,
@@ -370,11 +370,11 @@ type taskReport struct {
370
370
}
371
371
372
372
type mcpServer struct {
373
- agentClient * agentsdk.Client
374
- appStatusSlug string
375
- client * codersdk.Client
376
- llmClient * agentapi.Client
377
- queue * cliutil.Queue [taskReport ]
373
+ agentClient * agentsdk.Client
374
+ appStatusSlug string
375
+ client * codersdk.Client
376
+ aiAgentAPIClient * agentapi.Client
377
+ queue * cliutil.Queue [taskReport ]
378
378
}
379
379
380
380
func (r * RootCmd ) mcpServer () * serpent.Command {
@@ -383,13 +383,13 @@ func (r *RootCmd) mcpServer() *serpent.Command {
383
383
instructions string
384
384
allowedTools []string
385
385
appStatusSlug string
386
- llmAgentURL url.URL
386
+ aiAgentAPIURL url.URL
387
387
)
388
388
return & serpent.Command {
389
389
Use : "server" ,
390
390
Handler : func (inv * serpent.Invocation ) error {
391
391
// lastUserMessageID is the ID of the last *user* message that we saw. A
392
- // user message only happens when interacting via the LLM agent API (as
392
+ // user message only happens when interacting via the AI AgentAPI (as
393
393
// opposed to interacting with the terminal directly).
394
394
var lastUserMessageID int64
395
395
var lastReport taskReport
@@ -399,14 +399,15 @@ func (r *RootCmd) mcpServer() *serpent.Command {
399
399
// new user message, and the status is "working" and not self-reported
400
400
// (meaning it came from the screen watcher), then it means one of two
401
401
// things:
402
- // 1. The LLM is still working, so there is nothing to update.
403
- // 2. The LLM stopped working, then the user has interacted with the
404
- // terminal directly. For now, we are ignoring these updates. This
405
- // risks missing cases where the user manually submits a new prompt
406
- // and the LLM becomes active and does not update itself, but it
407
- // avoids spamming useless status updates as the user is typing, so
408
- // the tradeoff is worth it. In the future, if we can reliably
409
- // distinguish between user and LLM activity, we can change this.
402
+ // 1. The AI agent is still working, so there is nothing to update.
403
+ // 2. The AI agent stopped working, then the user has interacted with
404
+ // the terminal directly. For now, we are ignoring these updates.
405
+ // This risks missing cases where the user manually submits a new
406
+ // prompt and the AI agent becomes active and does not update itself,
407
+ // but it avoids spamming useless status updates as the user is
408
+ // typing, so the tradeoff is worth it. In the future, if we can
409
+ // reliably distinguish between user and AI agent activity, we can
410
+ // change this.
410
411
if report .messageID > lastUserMessageID {
411
412
report .state = codersdk .WorkspaceAppStatusStateWorking
412
413
} else if report .state == codersdk .WorkspaceAppStatusStateWorking && ! report .selfReported {
@@ -475,20 +476,20 @@ func (r *RootCmd) mcpServer() *serpent.Command {
475
476
cliui .Infof (inv .Stderr , "Task reporter : Enabled" )
476
477
}
477
478
478
- // Try to create a client for the LLM agent API , which is used to get the
479
+ // Try to create a client for the AI AgentAPI , which is used to get the
479
480
// screen status to make the status reporting more robust. No auth
480
481
// needed, so no validation.
481
- if llmAgentURL .String () == "" {
482
- cliui .Infof (inv .Stderr , "LLM agent URL : Not configured" )
482
+ if aiAgentAPIURL .String () == "" {
483
+ cliui .Infof (inv .Stderr , "AI AgentAPI URL : Not configured" )
483
484
} else {
484
- cliui .Infof (inv .Stderr , "LLM agent URL : %s" , llmAgentURL .String ())
485
- llmClient , err := agentapi .NewClient (llmAgentURL .String ())
485
+ cliui .Infof (inv .Stderr , "AI AgentAPI URL : %s" , aiAgentAPIURL .String ())
486
+ aiAgentAPIClient , err := agentapi .NewClient (aiAgentAPIURL .String ())
486
487
if err != nil {
487
488
cliui .Infof (inv .Stderr , "Screen events : Disabled" )
488
- cliui .Warnf (inv .Stderr , "%s must be set" , envLLMAgentURL )
489
+ cliui .Warnf (inv .Stderr , "%s must be set" , envAIAgentAPIURL )
489
490
} else {
490
491
cliui .Infof (inv .Stderr , "Screen events : Enabled" )
491
- srv .llmClient = llmClient
492
+ srv .aiAgentAPIClient = aiAgentAPIClient
492
493
}
493
494
}
494
495
@@ -499,10 +500,10 @@ func (r *RootCmd) mcpServer() *serpent.Command {
499
500
cliui .Infof (inv .Stderr , "Failed to watch screen events" )
500
501
// Start the reporter, watcher, and server. These are all tied to the
501
502
// lifetime of the MCP server, which is itself tied to the lifetime of the
502
- // LLM agent.
503
+ // AI agent.
503
504
if srv .agentClient != nil && appStatusSlug != "" {
504
505
srv .startReporter (ctx , inv )
505
- if srv .llmClient != nil {
506
+ if srv .aiAgentAPIClient != nil {
506
507
srv .startWatcher (ctx , inv )
507
508
}
508
509
}
@@ -536,10 +537,10 @@ func (r *RootCmd) mcpServer() *serpent.Command {
536
537
Default : "" ,
537
538
},
538
539
{
539
- Flag : "llm-agent -url" ,
540
- Description : "The URL of the LLM agent API , used to listen for status updates." ,
541
- Env : envLLMAgentURL ,
542
- Value : serpent .URLOf (& llmAgentURL ),
540
+ Flag : "ai-agentapi -url" ,
541
+ Description : "The URL of the AI AgentAPI , used to listen for status updates." ,
542
+ Env : envAIAgentAPIURL ,
543
+ Value : serpent .URLOf (& aiAgentAPIURL ),
543
544
},
544
545
},
545
546
}
@@ -549,9 +550,9 @@ func (s *mcpServer) startReporter(ctx context.Context, inv *serpent.Invocation)
549
550
go func () {
550
551
for {
551
552
// TODO: Even with the queue, there is still the potential that a message
552
- // from the screen watcher and a message from the LLM could arrive out of
553
- // order if the timing is just right. We might want to wait a bit, then
554
- // check if the status has changed before committing.
553
+ // from the screen watcher and a message from the AI agent could arrive
554
+ // out of order if the timing is just right. We might want to wait a bit,
555
+ // then check if the status has changed before committing.
555
556
item , ok := s .queue .Pop ()
556
557
if ! ok {
557
558
return
@@ -571,7 +572,7 @@ func (s *mcpServer) startReporter(ctx context.Context, inv *serpent.Invocation)
571
572
}
572
573
573
574
func (s * mcpServer ) startWatcher (ctx context.Context , inv * serpent.Invocation ) {
574
- eventsCh , errCh , err := s .llmClient .SubscribeEvents (ctx )
575
+ eventsCh , errCh , err := s .aiAgentAPIClient .SubscribeEvents (ctx )
575
576
if err != nil {
576
577
cliui .Warnf (inv .Stderr , "Failed to watch screen events: %s" , err )
577
578
return
0 commit comments