sipeed/picoclaw · error

MCP server %q not found

Error message

MCP server %q not found

What it means

Returned by picoclaw mcp remove <name> when the name is not a key under tools.mcp.servers in the loaded config. The lookup is an exact, case-sensitive map-key match, so any difference in spelling or case fails. Nothing is modified — the config is left untouched.

Source

Thrown at cmd/picoclaw/internal/mcp/remove.go:22

	"fmt"

	"github.com/spf13/cobra"
)

func newRemoveCommand() *cobra.Command {
	return &cobra.Command{
		Use:   "remove <name>",
		Short: "Remove an MCP server from config",
		Args:  cobra.ExactArgs(1),
		RunE: func(cmd *cobra.Command, args []string) error {
			cfg, err := loadConfig()
			if err != nil {
				return err
			}

			name := args[0]
			if _, exists := cfg.Tools.MCP.Servers[name]; !exists {
				return fmt.Errorf("MCP server %q not found", name)
			}

			delete(cfg.Tools.MCP.Servers, name)
			if len(cfg.Tools.MCP.Servers) == 0 {
				cfg.Tools.MCP.Servers = nil
				cfg.Tools.MCP.Enabled = false
			}

			if err := saveValidatedConfig(cfg); err != nil {
				return err
			}

			fmt.Fprintf(cmd.OutOrStdout(), "✓ MCP server %q removed.\n", name)
			return nil
		},
	}
}

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. List what is actually configured: picoclaw mcp list, and copy the exact key
  2. Re-run picoclaw mcp remove <exact-name>
  3. If the list is empty, determine which config file picoclaw loads for this directory and remove the entry there
  4. As a last resort, edit the config file and delete the key under tools.mcp.servers manually

Example fix

# before
$ picoclaw mcp remove Weather
MCP server "Weather" not found

# after
$ picoclaw mcp list
NAME      TYPE     ENABLED
weather   stdio    true
$ picoclaw mcp remove weather
Defensive patterns

Strategy: validation

Validate before calling

cfg, err := loadConfig()
if err != nil {
  return err
}
if _, ok := cfg.Tools.MCP.Servers[name]; !ok {
  names := make([]string, 0, len(cfg.Tools.MCP.Servers))
  for k := range cfg.Tools.MCP.Servers {
    names = append(names, k)
  }
  sort.Strings(names)
  return fmt.Errorf("MCP server %q not found; configured servers: %v", name, names)
}

Type guard

func isMCPServerNotFound(err error) bool {
  return err != nil && strings.Contains(err.Error(), "MCP server") && strings.Contains(err.Error(), "not found")
}

Try / catch

if err := removeCmd.RunE(cmd, args); err != nil {
  if isMCPServerNotFound(err) {
    // list configured names and ask the user to pick, instead of failing
  }
  return err
}

Prevention

When it happens

Trigger: picoclaw mcp remove with a typo'd or wrongly-cased name; removing a server that was already removed; picoclaw resolving a different config file than the one the server was added to (workspace-level vs user config).

Common situations: Scripts written against an old server name; multiple config files (project and global) causing confusion about where the entry lives; names with quotes or spaces pasted incorrectly; CI running with a fresh HOME and an empty config.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/58a2c1cf273ff3ba. Report an issue: GitHub.