Files
Lucas Manuel Rodriguez 56763d13c1 Move fleet-mcp from tools/ to cmd/ (#49044)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** #43544. 

Moves `fleet-mcp` from `tools/fleet-mcp/` to `cmd/fleet-mcp/`. It is
becoming a production server used by customers, so it now lives under
`cmd/` alongside the other Fleet binaries.

Per the module strategy chosen for this move, it **remains a standalone
Go module** (keeps its own `go.mod`/`go.sum` and isolated deps such as
`mark3labs/mcp-go`, `logrus`, `gorilla/websocket`, `godotenv`) — the
root `github.com/fleetdm/fleet/v4` module is unchanged.

### What changed
- `git mv tools/fleet-mcp/ → cmd/fleet-mcp/` (history preserved as
renames).
- Updated all path references:
  - Root `Makefile` `update-go` module list.
- `.github/workflows/test-fleet-mcp.yml` — trigger paths,
`go-version-file`, `working-directory`.
  - `.github/dependabot.yml` — gomod directory.
  - `cmd/fleet-mcp/render.yaml` — `rootDir`.
- `cmd/fleet-mcp/README.md`, `Makefile`, `schema.go` — path
comments/links.
  - `articles/fleet-mcp.md` — README link.
  - Removed the `fleet-mcp/` row from `tools/README.md`.

### Follow-up (not in this PR)
- The Render service's Blueprint file path must be updated from
`tools/fleet-mcp/render.yaml` to `cmd/fleet-mcp/render.yaml` in the
Render dashboard.

## Testing
- `go build .` in `cmd/fleet-mcp` — OK
- `go test -race -count=1 ./...` — `ok fleet-mcp`

- [x] QA'd all new/changed functionality manually
2026-07-09 13:29:09 -03:00

51 lines
1.4 KiB
Go

package main
import (
"os"
"github.com/joho/godotenv"
"github.com/sirupsen/logrus"
)
// Config holds the server configuration.
type Config struct {
Port string
FleetBaseURL string
FleetAPIKey string
LogLevel logrus.Level
TLSSkipVerify bool // FLEET_TLS_SKIP_VERIFY — skip TLS cert verification (unsafe; for dev only)
TLSCAFile string // FLEET_CA_FILE — path to PEM CA cert for self-signed Fleet instances
MCPAuthToken string // MCP_AUTH_TOKEN — bearer token required on all incoming MCP requests
}
// LoadConfig loads configuration from environment variables, falling back to .env if present.
//
// Secret resolution: FLEET_API_KEY and MCP_AUTH_TOKEN may be supplied via environment variables.
func LoadConfig() *Config {
if err := godotenv.Load(); err != nil {
logrus.Debug("no .env file found, using environment variables")
}
logLevel, err := logrus.ParseLevel(getEnv("LOG_LEVEL", "info"))
if err != nil {
logLevel = logrus.InfoLevel
}
return &Config{
Port: getEnv("PORT", "8080"),
FleetBaseURL: getEnv("FLEET_BASE_URL", "https://localhost:8080"),
FleetAPIKey: os.Getenv("FLEET_API_KEY"),
LogLevel: logLevel,
TLSSkipVerify: os.Getenv("FLEET_TLS_SKIP_VERIFY") == "true",
TLSCAFile: os.Getenv("FLEET_CA_FILE"),
MCPAuthToken: os.Getenv("MCP_AUTH_TOKEN"),
}
}
func getEnv(key, defaultValue string) string {
if v := os.Getenv(key); v != "" {
return v
}
return defaultValue
}