{"record":{"id":"4c2646d472ae2419","repo":"flipped-aurora/gin-vue-admin","slug":"server-name-mismatch","errorCode":null,"errorMessage":"server name mismatch","messagePattern":"server name mismatch","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/client/client.go","lineNumber":40,"sourceCode":"\n\tctx := context.Background()\n\tif err := client.Start(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\tinitRequest := mcp.InitializeRequest{}\n\tinitRequest.Params.ProtocolVersion = mcp.LATEST_PROTOCOL_VERSION\n\tinitRequest.Params.ClientInfo = mcp.Implementation{\n\t\tName:    name,\n\t\tVersion: version,\n\t}\n\n\tresult, err := client.Initialize(ctx, initRequest)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif result.ServerInfo.Name != serverName {\n\t\treturn nil, errors.New(\"server name mismatch\")\n\t}\n\n\treturn client, nil\n}\n","sourceCodeStart":22,"sourceCodeEnd":45,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/client/client.go#L22-L45","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nclient, err := mcpclient.NewClient(ctx, addr, \"gva-mcp\")\n// after (match the name the server actually advertises)\nclient, err := mcpclient.NewClient(ctx, addr, \"gin-vue-admin-mcp\")","handlingStrategy":"try-catch","validationCode":"// Verify config points at the intended server before connecting\nif (!expectedServerName || !endpointUrl) {\n  throw new Error(\"MCP endpoint and expected server name must be configured\")\n}","typeGuard":null,"tryCatchPattern":"client, err := mcpclient.NewClient(ctx, addr, serverName)\nif err != nil {\n  if err.Error() == \"server name mismatch\" {\n    // log actual advertised name, correct config, and retry\n    return nil, fmt.Errorf(\"endpoint is not the expected MCP server %q: %w\", serverName, err)\n  }\n  return nil, err\n}","preventionTips":["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."],"tags":["mcp","handshake","server-mismatch"],"backgroundTag":"server-identity-mismatch","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}