Skip to content

Commit a1f0eb8

Browse files
authored
Merge pull request #22 from redhat-ai-tools/create-cluster
add create cluster tool
2 parents 0cfbb6a + bb74f78 commit a1f0eb8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ocm_mcp_server.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,34 @@ async def get_cluster(cluster_id: str) -> str:
142142
return format_clusters_response({"items": [data]})
143143

144144

145+
@mcp.tool()
146+
async def create_cluster(
147+
cluster_name: str,
148+
region: str = "us-east-1",
149+
multi_az: bool = False,
150+
nodes: int = 4,
151+
instance_type: str = "m5.xlarge",
152+
) -> str:
153+
"""Provision a new cluster and add it to the collection of clusters. Only supports Classic OSD on AWS."""
154+
url = f"{OCM_API_BASE}/api/clusters_mgmt/v1/clusters"
155+
data = {
156+
"byoc": False,
157+
"name": cluster_name,
158+
"region": {"id": region},
159+
"nodes": {
160+
"compute": nodes,
161+
"compute_machine_type": {"id": instance_type},
162+
},
163+
"managed": True,
164+
"cloud_provider": {"id": "aws"},
165+
"multi_az": multi_az,
166+
"load_balancer_quota": 0,
167+
"storage_quota": {"unit": "B", "value": 107374182400},
168+
}
169+
response = await make_request(url, method="POST", data=data)
170+
return response
171+
172+
145173
@mcp.tool()
146174
async def get_clusters_logs(cluster_id: str) -> str:
147175
"""Get all service logs for a cluster specified by cluster_id"""

0 commit comments

Comments
 (0)