|
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 |
| - instructions string |
200 |
| - allowedTools []string |
201 |
| - appStatusSlug string |
202 |
| - mcpServerAgent bool |
| 197 | + client = new(codersdk.Client) |
| 198 | + instructions string |
| 199 | + allowedTools []string |
| 200 | + appStatusSlug string |
203 | 201 | )
|
204 | 202 | return &serpent.Command{
|
205 | 203 | Use: "server",
|
206 | 204 | Handler: func(inv *serpent.Invocation) error {
|
207 |
| - return mcpServerHandler(inv, client, instructions, allowedTools, appStatusSlug, mcpServerAgent) |
| 205 | + return mcpServerHandler(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 |
| -func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instructions string, allowedTools []string, appStatusSlug string, mcpServerAgent bool) error { |
| 238 | +func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instructions string, allowedTools []string, appStatusSlug string) error { |
248 | 239 | ctx, cancel := context.WithCancel(inv.Context())
|
249 | 240 | defer cancel()
|
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 |
| - if mcpServerAgent { |
294 |
| - // Get the workspace agent token from the environment. |
295 |
| - agentToken, ok := os.LookupEnv("CODER_AGENT_TOKEN") |
296 |
| - if !ok || agentToken == "" { |
297 |
| - return xerrors.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 | + if ok && 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 | + if appStatusSlug == "" { |
| 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)
|
|
0 commit comments