MCPcopy Index your code
hub / github.com/github/github-mcp-server / buildInitializeRequest

Function buildInitializeRequest

cmd/mcpcurl/main.go:457–480  ·  view source on GitHub ↗

buildInitializeRequest creates the MCP initialize handshake request.

()

Source from the content-addressed store, hash-verified

455
456// buildInitializeRequest creates the MCP initialize handshake request.
457func buildInitializeRequest() (string, error) {
458 id, err := rand.Int(rand.Reader, big.NewInt(10000))
459 if err != nil {
460 return "", fmt.Errorf("failed to generate random ID: %w", err)
461 }
462 msg := map[string]any{
463 "jsonrpc": "2.0",
464 "id": int(id.Int64()),
465 "method": "initialize",
466 "params": map[string]any{
467 "protocolVersion": "2024-11-05",
468 "capabilities": map[string]any{},
469 "clientInfo": map[string]any{
470 "name": "mcpcurl",
471 "version": "0.1.0",
472 },
473 },
474 }
475 data, err := json.Marshal(msg)
476 if err != nil {
477 return "", fmt.Errorf("failed to marshal initialize request: %w", err)
478 }
479 return string(data), nil
480}
481
482// buildInitializedNotification creates the MCP initialized notification.
483func buildInitializedNotification() string {

Callers 2

executeServerCommandFunction · 0.85

Calls

no outgoing calls

Tested by 1