flipped-aurora/gin-vue-admin · critical
读取 MCP 配置失败: %w
Error message
读取 MCP 配置失败: %w
What it means
The standalone MCP server loads its YAML config before starting. This error wraps os.ReadFile failure when the config file path cannot be read (missing file, permission denied, path is a directory).
Source
Thrown at server/cmd/mcp/config.go:31
"github.com/flipped-aurora/gin-vue-admin/server/config"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"gopkg.in/yaml.v3"
)
type standaloneConfig struct {
MCP config.MCP `yaml:"mcp"`
AutoCode config.Autocode `yaml:"autocode"`
}
func loadStandaloneConfig() (string, error) {
configPath, err := resolveConfigPath()
if err != nil {
return "", err
}
content, err := os.ReadFile(configPath)
if err != nil {
return "", fmt.Errorf("读取 MCP 配置失败: %w", err)
}
var cfg standaloneConfig
if err := yaml.Unmarshal(content, &cfg); err != nil {
return "", fmt.Errorf("解析 MCP 配置失败: %w", err)
}
applyStandaloneDefaults(configPath, &cfg)
global.GVA_CONFIG.MCP = cfg.MCP
global.GVA_CONFIG.AutoCode = cfg.AutoCode
return configPath, nil
}
func resolveConfigPath() (string, error) {
explicit, err := parseConfigFlag(os.Args[1:])
if err != nil {View on GitHub (pinned to 3136500ef3)
Solutions
- Check the resolved path exists: ls -l <configPath> (the error includes the wrapped os error)
- Run the server from the directory where the config lives, or pass the absolute path via the config flag
- Fix file permissions so the process user can read the file
- Create the config file from the project's example config if missing
Example fix
// before ./mcp-server # expects config.yaml in cwd // after ./mcp-server --config /absolute/path/to/config.yaml
Defensive patterns
Strategy: validation
Validate before calling
info, err := os.Stat(configPath)
if err != nil { log.Fatalf("config missing: %v", err) }
if info.IsDir() { log.Fatalf("config path is a directory: %s", configPath) } Try / catch
cfg, err := loadStandaloneConfig(path)
if err != nil {
var pe *fs.PathError
if errors.As(err, &pe) { fmt.Printf("cannot read %s: %v\n", pe.Path, pe.Err) }
os.Exit(1)
} Prevention
- Use absolute config paths or resolve relative to the binary
- Add a pre-start check in the entry script/systemd unit
- Ship an example config and fail fast with a helpful message
When it happens
Trigger: Running the MCP server when the config file doesn't exist at the resolved path, the process lacks read permission, or the path points to a directory.
Common situations: Wrong working directory so a relative config path resolves incorrectly; config never created; file permissions changed; typo'd --config flag value.
Related errors
- 解析 MCP 配置失败: %w
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
- 未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
- fatal error config file: %w
- fatal error unmarshal config: %w
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/f1126d94682bfeb6.
Report an issue: GitHub.