buildInitializeRequest creates the MCP initialize handshake request.
()
| 455 | |
| 456 | // buildInitializeRequest creates the MCP initialize handshake request. |
| 457 | func 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. |
| 483 | func buildInitializedNotification() string { |
no outgoing calls