|
8 | 8 | "path/filepath"
|
9 | 9 |
|
10 | 10 | "github.com/mark3labs/mcp-go/server"
|
11 |
| -"golang.org/x/xerrors" |
12 | 11 |
|
13 | 12 | "cdr.dev/slog"
|
14 | 13 | "cdr.dev/slog/sloggers/sloghuman"
|
@@ -195,16 +194,15 @@ func (*RootCmd) mcpConfigureCursor() *serpent.Command {
|
195 | 194 |
|
196 | 195 | func (r*RootCmd)mcpServer()*serpent.Command {
|
197 | 196 | var (
|
198 |
| -client=new(codersdk.Client) |
199 |
| -instructionsstring |
200 |
| -allowedTools []string |
201 |
| -appStatusSlugstring |
202 |
| -mcpServerAgentbool |
| 197 | +client=new(codersdk.Client) |
| 198 | +instructionsstring |
| 199 | +allowedTools []string |
| 200 | +appStatusSlugstring |
203 | 201 | )
|
204 | 202 | return&serpent.Command{
|
205 | 203 | Use:"server",
|
206 | 204 | Handler:func(inv*serpent.Invocation)error {
|
207 |
| -returnmcpServerHandler(inv,client,instructions,allowedTools,appStatusSlug,mcpServerAgent) |
| 205 | +returnmcpServerHandler(inv,client,instructions,allowedTools,appStatusSlug) |
208 | 206 | },
|
209 | 207 | Short:"Start the Coder MCP server.",
|
210 | 208 | Middleware:serpent.Chain(
|
@@ -233,18 +231,11 @@ func (r *RootCmd) mcpServer() *serpent.Command {
|
233 | 231 | Value:serpent.StringOf(&appStatusSlug),
|
234 | 232 | Default:"",
|
235 | 233 | },
|
236 |
| -{ |
237 |
| -Flag:"agent", |
238 |
| -Env:"CODER_MCP_SERVER_AGENT", |
239 |
| -Description:"Start the MCP server in agent mode, with a different set of tools.", |
240 |
| -Value:serpent.BoolOf(&mcpServerAgent), |
241 |
| -}, |
242 | 234 | },
|
243 | 235 | }
|
244 | 236 | }
|
245 | 237 |
|
246 |
| -//nolint:revive // control coupling |
247 |
| -funcmcpServerHandler(inv*serpent.Invocation,client*codersdk.Client,instructionsstring,allowedTools []string,appStatusSlugstring,mcpServerAgentbool)error { |
| 238 | +funcmcpServerHandler(inv*serpent.Invocation,client*codersdk.Client,instructionsstring,allowedTools []string,appStatusSlugstring)error { |
248 | 239 | ctx,cancel:=context.WithCancel(inv.Context())
|
249 | 240 | defercancel()
|
250 | 241 |
|
@@ -290,13 +281,15 @@ func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instruct
|
290 | 281 | AgentClient:agentsdk.New(client.URL),
|
291 | 282 | }
|
292 | 283 |
|
293 |
| -ifmcpServerAgent { |
294 |
| -// Get the workspace agent token from the environment. |
295 |
| -agentToken,ok:=os.LookupEnv("CODER_AGENT_TOKEN") |
296 |
| -if!ok||agentToken=="" { |
297 |
| -returnxerrors.New("CODER_AGENT_TOKEN is not set") |
298 |
| -} |
| 284 | +// Get the workspace agent token from the environment. |
| 285 | +agentToken,ok:=os.LookupEnv("CODER_AGENT_TOKEN") |
| 286 | +ifok&&agentToken!="" { |
299 | 287 | toolDeps.AgentClient.SetSessionToken(agentToken)
|
| 288 | +}else { |
| 289 | +cliui.Warnf(inv.Stderr,"CODER_AGENT_TOKEN is not set, task reporting will not be available") |
| 290 | +} |
| 291 | +ifappStatusSlug=="" { |
| 292 | +cliui.Warnf(inv.Stderr,"CODER_MCP_APP_STATUS_SLUG is not set, task reporting will not be available.") |
300 | 293 | }
|
301 | 294 |
|
302 | 295 | // Register tools based on the allowlist (if specified)
|
|