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

  1. Log both result.ServerInfo.Name and the expected serverName, then pass the actual advertised name to NewClient.
  2. Verify the endpoint URL/port in configuration points at the intended MCP server.
  3. 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

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


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/4c2646d472ae2419. Report an issue: GitHub.