Skip to content

Commit 70de753

Browse files
tiwilliaclaude
andcommitted
Update documentation for HTPasswd identity provider and ROSA CLI integration
README.md: - Update tool count from 5 to 6 core tools - Add ROSA CLI integration to features section - Document setup_htpasswd_identity_provider tool with complete API - Update project structure to include pkg/htpasswd/ package CLAUDE.md: - Add comprehensive ROSA CLI Integration section - Document external dependencies (ocm-common) - Explain validation flow and input compatibility - Update architecture overview with htpasswd package - Update test coverage information 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent cc1b005 commit 70de753

File tree

2 files changed

+83
-4
lines changed

2 files changed

+83
-4
lines changed

CLAUDE.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
This is a Model Context Protocol (MCP) server for ROSA HCP (Red Hat OpenShift Service on AWS using Hosted Control Planes) written in Go. It enables AI assistants to integrate with Red Hat Managed OpenShift services through 5 core tools: `whoami`, `get_clusters`, `get_cluster`, `create_rosa_hcp_cluster`, and `get_rosa_hcp_prerequisites_guide`.
7+
This is a Model Context Protocol (MCP) server for ROSA HCP (Red Hat OpenShift Service on AWS using Hosted Control Planes) written in Go. It enables AI assistants to integrate with Red Hat Managed OpenShift services through 6 core tools: `whoami`, `get_clusters`, `get_cluster`, `create_rosa_hcp_cluster`, `get_rosa_hcp_prerequisites_guide`, and `setup_htpasswd_identity_provider`.
88

99
## Build and Development Commands
1010

@@ -50,13 +50,18 @@ The codebase follows the Model Context Protocol (MCP) server pattern with clear
5050

5151
**MCP Layer (`pkg/mcp/`):**
5252
- `server.go` - Main MCP server implementation, handles transport (stdio/SSE) and authentication
53-
- `tools.go` - Implements all 4 ROSA HCP tools with parameter validation and OCM client interaction
53+
- `tools.go` - Implements all 6 ROSA HCP tools with parameter validation and OCM client interaction
5454
- `formatters.go` - Human-readable response formatters (not JSON) for AI assistant consumption
5555
- `profiles.go` - Tool profile system for selective tool exposure (currently default profile only)
5656

5757
**OCM Integration (`pkg/ocm/`):**
5858
- `client.go` - OCM SDK wrapper with authenticated connections and structured error handling
5959
- `auth.go` - Transport-agnostic token extraction (SSE headers vs stdio environment variables)
60+
- `htpasswd.go` - HTPasswd identity provider setup methods using ROSA CLI patterns
61+
62+
**ROSA CLI Integration (`pkg/htpasswd/`):**
63+
- `validation.go` - Username, password, and IDP name validation copied from ROSA CLI
64+
- `validation_test.go` - Comprehensive test suite for all validation functions
6065

6166
**Configuration (`pkg/config/`):**
6267
- `config.go` - TOML configuration file support with CLI flag overrides
@@ -87,14 +92,39 @@ Each tool follows this pattern:
8792

8893
All responses are human-readable formatted strings (not JSON) designed for AI assistant consumption. Each tool has a dedicated formatter in `formatters.go` that structures the output consistently.
8994

95+
### ROSA CLI Integration
96+
97+
The HTPasswd identity provider implementation (`setup_htpasswd_identity_provider` tool) integrates directly with ROSA CLI libraries and patterns:
98+
99+
**External Dependencies:**
100+
- `github.com/openshift-online/ocm-common` v0.0.25 - Password validation and HTPasswd hashing utilities
101+
102+
**ROSA CLI Function Integration (~70% code reuse):**
103+
- `UsernameValidator()` - Username format validation (no /, :, % characters)
104+
- `clusterAdminValidator()` - Reserved username check (prevents "cluster-admin")
105+
- `ValidateIdpName()` - IDP name validation with regex pattern matching
106+
- `parseHtpasswordFile()` - HTPasswd file parsing for base64 encoded content
107+
- `ProcessUserInput()` - Handles multiple input formats (users array, single user, htpasswd file)
108+
109+
**Validation Flow:**
110+
1. IDP name validation using ROSA CLI regex patterns
111+
2. Username/password validation with ROSA CLI rules
112+
3. Password hashing with `ocm-common` utilities
113+
4. OCM API integration following ROSA CLI error handling patterns
114+
115+
**Input Compatibility:**
116+
- Users array format: `["user1:password1", "user2:password2"]`
117+
- Single user format: `username` + `password` parameters (backward compatibility)
118+
- HTPasswd file format: Base64-encoded htpasswd file content
119+
90120
## Development Notes
91121

92122
- The project uses `github.com/mark3labs/mcp-go` v0.37.0+ as the MCP framework
93123
- OCM integration via `github.com/openshift-online/ocm-sdk-go`
94124
- Configuration supports CLI flags, environment variables, and TOML files
95125
- Uses glog for structured logging throughout the OCM SDK integration
96126
- OCM client supports configurable client ID (defaults to "cloud-services")
97-
- Only the `pkg/ocm` package currently has test coverage focusing on authentication logic
127+
- Test coverage includes `pkg/ocm` (authentication logic) and `pkg/htpasswd` (ROSA CLI validation functions)
98128
- The server binary is built to `rosa-mcp-server` in the project root
99129

100130
## Container and OpenShift Deployment

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ A Model Context Protocol (MCP) server for ROSA HCP (Red Hat OpenShift Service on
44

55
## Features
66

7-
- **5 Core Tools**: `whoami`, `get_clusters`, `get_cluster`, `create_rosa_hcp_cluster`, `get_rosa_hcp_prerequisites_guide`
7+
- **6 Core Tools**: `whoami`, `get_clusters`, `get_cluster`, `create_rosa_hcp_cluster`, `get_rosa_hcp_prerequisites_guide`, `setup_htpasswd_identity_provider`
8+
- **ROSA CLI Integration**: HTPasswd identity provider setup using proven ROSA CLI validation and patterns
89
- **Dual Transport Support**: stdio and Server-Sent Events (SSE)
910
- **OCM API Integration**: Direct integration with OpenShift Cluster Manager
1011
- **Multi-Region Support**: Configurable AWS regions (default: us-east-1)
@@ -197,6 +198,52 @@ Get the complete workflow prompt for ROSA HCP cluster installation prerequisites
197198
}
198199
```
199200

201+
### 6. setup_htpasswd_identity_provider
202+
Setup an HTPasswd identity provider for a ROSA HCP cluster with username/password authentication.
203+
```json
204+
{
205+
"name": "setup_htpasswd_identity_provider",
206+
"parameters": {
207+
"cluster_id": {
208+
"type": "string",
209+
"description": "Target cluster identifier",
210+
"required": true
211+
},
212+
"name": {
213+
"type": "string",
214+
"description": "Identity provider name",
215+
"default": "htpasswd"
216+
},
217+
"mapping_method": {
218+
"type": "string",
219+
"description": "User mapping method - options: add, claim, generate, lookup",
220+
"default": "claim"
221+
},
222+
"users": {
223+
"type": "array",
224+
"description": "List of username:password pairs [\"user1:password1\", \"user2:password2\"]"
225+
},
226+
"username": {
227+
"type": "string",
228+
"description": "Single user username (for backward compatibility)"
229+
},
230+
"password": {
231+
"type": "string",
232+
"description": "Single user password (for backward compatibility)"
233+
},
234+
"htpasswd_file_content": {
235+
"type": "string",
236+
"description": "Base64-encoded htpasswd file content"
237+
},
238+
"overwrite_existing": {
239+
"type": "boolean",
240+
"description": "Whether to overwrite if IDP with same name exists",
241+
"default": false
242+
}
243+
}
244+
}
245+
```
246+
200247
## ROSA HCP Prerequisites
201248

202249
Before creating clusters, ensure you have:
@@ -238,9 +285,11 @@ Before creating clusters, ensure you have:
238285
├── cmd/rosa-mcp-server/ # Main entry point
239286
├── pkg/
240287
│ ├── config/ # Configuration management
288+
│ ├── htpasswd/ # HTPasswd validation (ROSA CLI integration)
241289
│ ├── mcp/ # MCP server implementation
242290
│ ├── ocm/ # OCM API client wrapper
243291
│ └── version/ # Version information
292+
├── spec/ # Implementation specifications
244293
├── go.mod # Go module definition
245294
└── README.md # This file
246295
```

0 commit comments

Comments
 (0)