From 89040d0720ccfcd6812d83d94b21f7d4ffdc747c Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 1 Apr 2025 15:38:06 +0100 Subject: [PATCH 1/3] fix(cli) exp mcp: remove unnecessary cli flag --- cli/exp_mcp.go | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/cli/exp_mcp.go b/cli/exp_mcp.go index b46a8b4d7f03a..0ea55274a0bcf 100644 --- a/cli/exp_mcp.go +++ b/cli/exp_mcp.go @@ -8,7 +8,6 @@ import ( "path/filepath" "github.com/mark3labs/mcp-go/server" - "golang.org/x/xerrors" "cdr.dev/slog" "cdr.dev/slog/sloggers/sloghuman" @@ -195,16 +194,15 @@ func (*RootCmd) mcpConfigureCursor() *serpent.Command { func (r *RootCmd) mcpServer() *serpent.Command { var ( - client = new(codersdk.Client) - instructions string - allowedTools []string - appStatusSlug string - mcpServerAgent bool + client = new(codersdk.Client) + instructions string + allowedTools []string + appStatusSlug string ) return &serpent.Command{ Use: "server", Handler: func(inv *serpent.Invocation) error { - return mcpServerHandler(inv, client, instructions, allowedTools, appStatusSlug, mcpServerAgent) + return mcpServerHandler(inv, client, instructions, allowedTools, appStatusSlug) }, Short: "Start the Coder MCP server.", Middleware: serpent.Chain( @@ -233,18 +231,12 @@ func (r *RootCmd) mcpServer() *serpent.Command { Value: serpent.StringOf(&appStatusSlug), Default: "", }, - { - Flag: "agent", - Env: "CODER_MCP_SERVER_AGENT", - Description: "Start the MCP server in agent mode, with a different set of tools.", - Value: serpent.BoolOf(&mcpServerAgent), - }, }, } } //nolint:revive // control coupling -func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instructions string, allowedTools []string, appStatusSlug string, mcpServerAgent bool) error { +func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instructions string, allowedTools []string, appStatusSlug string) error { ctx, cancel := context.WithCancel(inv.Context()) defer cancel() @@ -290,13 +282,12 @@ func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instruct AgentClient: agentsdk.New(client.URL), } - if mcpServerAgent { - // Get the workspace agent token from the environment. - agentToken, ok := os.LookupEnv("CODER_AGENT_TOKEN") - if !ok || agentToken == "" { - return xerrors.New("CODER_AGENT_TOKEN is not set") - } + // Get the workspace agent token from the environment. + agentToken, ok := os.LookupEnv("CODER_AGENT_TOKEN") + if ok && agentToken != "" { toolDeps.AgentClient.SetSessionToken(agentToken) + } else { + cliui.Warnf(inv.Stderr, "CODER_AGENT_TOKEN is not set, task reporting will not be available") } // Register tools based on the allowlist (if specified) From 1e507587e2a46f369fab7d1bad90c8ec10353861 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 1 Apr 2025 15:42:44 +0100 Subject: [PATCH 2/3] Update cli/exp_mcp.go --- cli/exp_mcp.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cli/exp_mcp.go b/cli/exp_mcp.go index 0ea55274a0bcf..288a904acd838 100644 --- a/cli/exp_mcp.go +++ b/cli/exp_mcp.go @@ -235,7 +235,6 @@ func (r *RootCmd) mcpServer() *serpent.Command { } } -//nolint:revive // control coupling func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instructions string, allowedTools []string, appStatusSlug string) error { ctx, cancel := context.WithCancel(inv.Context()) defer cancel() From 9ef63a01b284e70d6073ee58c5afc8e6f36ed116 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 1 Apr 2025 15:54:59 +0100 Subject: [PATCH 3/3] warnf if app status slug is not set --- cli/exp_mcp.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/exp_mcp.go b/cli/exp_mcp.go index 288a904acd838..d8834a634085d 100644 --- a/cli/exp_mcp.go +++ b/cli/exp_mcp.go @@ -288,6 +288,9 @@ func mcpServerHandler(inv *serpent.Invocation, client *codersdk.Client, instruct } else { cliui.Warnf(inv.Stderr, "CODER_AGENT_TOKEN is not set, task reporting will not be available") } + if appStatusSlug == "" { + cliui.Warnf(inv.Stderr, "CODER_MCP_APP_STATUS_SLUG is not set, task reporting will not be available.") + } // Register tools based on the allowlist (if specified) reg := codermcp.AllTools() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy