|
| 1 | +# ROSA HCP MCP Server - Comprehensive Requirements Specification |
| 2 | + |
| 3 | +## Problem Statement |
| 4 | +Build a golang-based MCP server for ROSA HCP (Red Hat OpenShift on AWS using Hosted Control Planes) that enables AI assistants to integrate with Red Hat Managed OpenShift services. The server provides essential cluster operations through the Model Context Protocol. |
| 5 | + |
| 6 | +## Solution Overview |
| 7 | +A minimal MVP implementation following the architectural patterns of the OpenShift MCP server (github.com/openshift/openshift-mcp-server) and business logic of the OCM MCP server (github.com/redhat-ai-tools/ocm-mcp), using the mcp-go framework (github.com/mark3labs/mcp-go). |
| 8 | + |
| 9 | +## Functional Requirements |
| 10 | + |
| 11 | +### Core Tools (4 Required) |
| 12 | + |
| 13 | +#### 1. `whoami()` |
| 14 | +- **Description:** "Get the authenticated account" |
| 15 | +- **Parameters:** None |
| 16 | +- **Returns:** Formatted account information (username, organization, etc.) |
| 17 | +- **Implementation:** GET `/api/accounts_mgmt/v1/current_account` |
| 18 | + |
| 19 | +#### 2. `get_clusters(state: string)` |
| 20 | +- **Description:** "Retrieves the list of clusters" |
| 21 | +- **Parameters:** |
| 22 | + - `state` (required): Filter clusters by state (e.g., "ready", "installing", "error") |
| 23 | +- **Returns:** Formatted cluster list with name, ID, API URL, console URL, state, version |
| 24 | +- **Implementation:** GET `/api/clusters_mgmt/v1/clusters` with state filtering |
| 25 | + |
| 26 | +#### 3. `get_cluster(cluster_id: string)` |
| 27 | +- **Description:** "Retrieves the details of the cluster" |
| 28 | +- **Parameters:** |
| 29 | + - `cluster_id` (required): Unique cluster identifier |
| 30 | +- **Returns:** Formatted detailed cluster information |
| 31 | +- **Implementation:** GET `/api/clusters_mgmt/v1/clusters/{cluster_id}` |
| 32 | + |
| 33 | +#### 4. `create_rosa_hcp_cluster(...)` |
| 34 | +- **Description:** "Provision a new ROSA HCP cluster with required configuration" |
| 35 | +- **Parameters (all required except region):** |
| 36 | + - `cluster_name` (required): Name for the cluster |
| 37 | + - `aws_account_id` (required): AWS account ID |
| 38 | + - `billing_account_id` (required): AWS billing account ID |
| 39 | + - `role_arn` (required): IAM installer role ARN |
| 40 | + - `operator_role_prefix` (required): Operator role prefix |
| 41 | + - `oidc_config_id` (required): OIDC configuration ID |
| 42 | + - `subnet_ids` (required): Array of subnet IDs |
| 43 | + - `region` (optional): AWS region (default: "us-east-1") |
| 44 | +- **Returns:** Formatted cluster creation response |
| 45 | +- **Implementation:** POST `/api/clusters_mgmt/v1/clusters` with ROSA HCP payload |
| 46 | + |
| 47 | +### Resources (1 Required) |
| 48 | + |
| 49 | +#### 1. ROSA HCP Prerequisites Documentation |
| 50 | +- **Type:** Static resource |
| 51 | +- **Content:** Documentation of cluster creation requirements |
| 52 | +- **Includes:** IAM role setup, OIDC configuration, networking prerequisites |
| 53 | + |
| 54 | +## Technical Requirements |
| 55 | + |
| 56 | +### Architecture |
| 57 | +- **Framework:** `github.com/mark3labs/mcp-go` v0.37.0+ |
| 58 | +- **Structure:** Follow OpenShift MCP server patterns |
| 59 | + - `Server` struct with OCM client manager |
| 60 | + - `Configuration` struct for settings |
| 61 | + - Profile system (expose all tools for MVP) |
| 62 | + - Context-based authentication handling |
| 63 | + |
| 64 | +### Authentication |
| 65 | +- **Token Source:** OCM offline tokens from https://console.redhat.com/openshift/token |
| 66 | +- **Flow:** OAuth refresh token → access token |
| 67 | +- **Transport Handling:** |
| 68 | + - **SSE Transport:** `X-OCM-OFFLINE-TOKEN` header |
| 69 | + - **Stdio Transport:** `OCM_OFFLINE_TOKEN` environment variable |
| 70 | +- **Multiple Users:** Support concurrent tokens via header-based authentication |
| 71 | + |
| 72 | +### Transport Support |
| 73 | +- **Stdio:** Standard input/output for local integrations |
| 74 | +- **SSE:** Server-Sent Events with HTTP headers for remote access |
| 75 | +- **Configuration:** Command-line flags and TOML config files |
| 76 | + |
| 77 | +### API Integration |
| 78 | +- **SDK:** Use `github.com/openshift-online/ocm-sdk-go` for OCM API client |
| 79 | +- **Base URL:** https://api.openshift.com (configurable) |
| 80 | +- **Authentication:** Bearer token via OAuth refresh flow (handled by OCM SDK) |
| 81 | +- **Endpoints:** |
| 82 | + - OCM Clusters_mgmt API: `/api/clusters_mgmt/v1/` |
| 83 | + - OCM Accounts_mgmt API: `/api/accounts_mgmt/v1/` |
| 84 | +- **Error Handling:** Direct API error propagation without retry logic |
| 85 | + |
| 86 | +### Response Formatting |
| 87 | +- **Output:** Human-readable formatted strings (not JSON) |
| 88 | +- **Patterns:** Dedicated formatter functions like `formatClustersResponse()` |
| 89 | +- **Consistency:** All tools return formatted text for AI assistant consumption |
| 90 | + |
| 91 | +### Configuration |
| 92 | +- **Methods:** Command-line flags, environment variables, TOML config files |
| 93 | +- **Required Settings:** |
| 94 | + - OCM API base URL (default: https://api.openshift.com) |
| 95 | + - Transport mode selection |
| 96 | + - Optional: Port for SSE/HTTP transport |
| 97 | + - Optional: SSE base URL for public endpoints |
| 98 | + |
| 99 | +## Implementation Hints |
| 100 | + |
| 101 | +### File Structure (following OpenShift MCP patterns) |
| 102 | +``` |
| 103 | +cmd/rosa-mcp-server/main.go # Entry point |
| 104 | +pkg/ |
| 105 | + config/config.go # Configuration management |
| 106 | + ocm/ |
| 107 | + client.go # OCM SDK client wrapper |
| 108 | + auth.go # OAuth token handling (via OCM SDK) |
| 109 | + formatter.go # Response formatting |
| 110 | + mcp/ |
| 111 | + server.go # MCP server implementation |
| 112 | + tools.go # Tool implementations |
| 113 | + profiles.go # Profile definitions |
| 114 | + version/version.go # Version information |
| 115 | +``` |
| 116 | + |
| 117 | +### Key Patterns to Follow |
| 118 | +1. **Server Initialization:** Similar to `mcp.NewServer()` in OpenShift MCP |
| 119 | +2. **Context Handling:** Extract tokens from headers/environment in context functions |
| 120 | +3. **Tool Registration:** Register all 4 tools with the mcp-go framework |
| 121 | +4. **Error Wrapping:** Use `NewTextResult()` pattern for consistent error responses |
| 122 | +5. **Middleware:** Logging middleware for tool calls |
| 123 | + |
| 124 | +### Critical Dependencies |
| 125 | +- `github.com/mark3labs/mcp-go` - MCP framework |
| 126 | +- `github.com/openshift-online/ocm-sdk-go` - OCM API client SDK |
| 127 | +- `github.com/BurntSushi/toml` - Configuration files |
| 128 | +- `github.com/spf13/cobra` - CLI interface |
| 129 | + |
| 130 | +## Acceptance Criteria |
| 131 | +1. **Transport Support:** Both stdio and SSE work with token authentication |
| 132 | +2. **Tool Functionality:** All 4 tools return properly formatted responses |
| 133 | +3. **Error Handling:** OCM API errors are exposed to users without modification |
| 134 | +4. **Multi-Region:** Cluster creation supports configurable AWS regions |
| 135 | +5. **Authentication:** Multiple concurrent users supported via header tokens |
| 136 | +6. **Documentation:** Prerequisites resource available to clients |
| 137 | +7. **Configuration:** Configurable via CLI, environment, and config files |
| 138 | + |
| 139 | +## Assumptions |
| 140 | +- Users have pre-configured AWS IAM roles and OIDC configurations |
| 141 | +- OCM API handles all parameter validation for cluster creation |
| 142 | +- No caching required - real-time API data preferred |
| 143 | +- MVP scope excludes cluster lifecycle management beyond creation |
| 144 | +- Unit testing sufficient for MVP (integration tests future enhancement) |
| 145 | +- Profile system will be simple (all tools enabled) with future configurability |
| 146 | + |
| 147 | +## Future Considerations (Do not implement in MVP) |
| 148 | +- Tool selection profiles (rosa-basic, rosa-full) |
| 149 | +- Pre-validation of AWS resources before API calls |
| 150 | +- Cluster lifecycle operations (scaling, upgrading, deletion) |
| 151 | +- Caching for performance optimization |
| 152 | +- Enhanced error recovery and retry logic |
0 commit comments