flipped-aurora/gin-vue-admin · error
server name mismatch
Error message
server name mismatch
What it means
Thrown by NewClient in the MCP client package after a successful Initialize handshake when the returned result.ServerInfo.Name differs from the expected serverName. It validates that the connected endpoint really is the MCP server the caller intended, preventing tool calls against the wrong server.
Source
Thrown at server/mcp/client/client.go:40
ctx := context.Background()
if err := client.Start(ctx); err != nil {
return nil, err
}
initRequest := mcp.InitializeRequest{}
initRequest.Params.ProtocolVersion = mcp.LATEST_PROTOCOL_VERSION
initRequest.Params.ClientInfo = mcp.Implementation{
Name: name,
Version: version,
}
result, err := client.Initialize(ctx, initRequest)
if err != nil {
return nil, err
}
if result.ServerInfo.Name != serverName {
return nil, errors.New("server name mismatch")
}
return client, nil
}
View on GitHub (pinned to 3136500ef3)
Solutions
- Log both result.ServerInfo.Name and the expected serverName, then pass the actual advertised name to NewClient.
- Verify the endpoint URL/port in configuration points at the intended MCP server.
- Update the expected serverName if the server was intentionally renamed after an upgrade.
Example fix
// before client, err := mcpclient.NewClient(ctx, addr, "gva-mcp") // after (match the name the server actually advertises) client, err := mcpclient.NewClient(ctx, addr, "gin-vue-admin-mcp")
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify config points at the intended server before connecting
if (!expectedServerName || !endpointUrl) {
throw new Error("MCP endpoint and expected server name must be configured")
} Try / catch
client, err := mcpclient.NewClient(ctx, addr, serverName)
if err != nil {
if err.Error() == "server name mismatch" {
// log actual advertised name, correct config, and retry
return nil, fmt.Errorf("endpoint is not the expected MCP server %q: %w", serverName, err)
}
return nil, err
} Prevention
- Keep serverName in config in sync with the server's advertised Initialize name.
- Re-verify the name after MCP server upgrades or renames.
- Log the advertised ServerInfo.Name on mismatch to speed up diagnosis.
- Pin endpoint URLs per environment to avoid proxies routing to the wrong server.
When it happens
Trigger: Connecting to an MCP endpoint whose Initialize response advertises a server name different from the serverName parameter passed to NewClient; misconfigured endpoint URL; server upgraded/renamed its advertised name.
Common situations: Config pointing at the wrong port or process; MCP server version update changing its advertised name; copy-pasted serverName from another project; proxy routing to a different backend.
Related errors
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
- 未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
- go.mod 中未找到 module 定义
- path 参数是必需的
- description 参数是必需的
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/4c2646d472ae2419.
Report an issue: GitHub.