resource_create_instance
Provision a new IBM Cloud resource instance by specifying name, target region, resource group, and plan ID.
Instructions
Provision a new resource instance (any IBM Cloud service)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| target | Yes | Region or location (e.g. us-south) | |
| resource_group | Yes | Resource group ID | |
| resource_plan_id | Yes | Plan CRN or ID | |
| parameters | No | JSON string of additional parameters |
Implementation Reference
- The `resource_create_instance` tool handler: registers an MCP tool that provisions a new IBM Cloud resource instance via POST to the Resource Controller API. It accepts name, target (region), resource_group, resource_plan_id, and optional parameters (JSON string). The handler includes write permission checking via `w()` (assertWriteAllowed).
server.tool("resource_create_instance", "Provision a new resource instance (any IBM Cloud service)", { name: z.string(), target: z.string().describe("Region or location (e.g. us-south)"), resource_group: z.string().describe("Resource group ID"), resource_plan_id: z.string().describe("Plan CRN or ID"), parameters: z.string().optional().describe("JSON string of additional parameters"), }, async (p) => safeTool(async () => { w(); return client.post(`${base}/resource_instances`, { name:p.name, target:p.target, resource_group:p.resource_group, resource_plan_id:p.resource_plan_id, parameters:p.parameters ? JSON.parse(p.parameters) : undefined, }); })); - Input schema for `resource_create_instance`: name (string), target (string - region/location), resource_group (string - resource group ID), resource_plan_id (string - plan CRN/ID), parameters (optional string - JSON string of additional params).
name: z.string(), target: z.string().describe("Region or location (e.g. us-south)"), resource_group: z.string().describe("Resource group ID"), resource_plan_id: z.string().describe("Plan CRN or ID"), parameters: z.string().optional().describe("JSON string of additional parameters"), - src/tools/resource-management/index.ts:22-33 (registration)Tool registration via `server.tool("resource_create_instance", ...)` within `registerResourceManagementTools()`, which is called from `src/server.ts` line 77.
server.tool("resource_create_instance", "Provision a new resource instance (any IBM Cloud service)", { name: z.string(), target: z.string().describe("Region or location (e.g. us-south)"), resource_group: z.string().describe("Resource group ID"), resource_plan_id: z.string().describe("Plan CRN or ID"), parameters: z.string().optional().describe("JSON string of additional parameters"), }, async (p) => safeTool(async () => { w(); return client.post(`${base}/resource_instances`, { name:p.name, target:p.target, resource_group:p.resource_group, resource_plan_id:p.resource_plan_id, parameters:p.parameters ? JSON.parse(p.parameters) : undefined, }); })); - src/lib/utils.ts:70-77 (helper)The `safeTool` wrapper that catches errors and returns MCP-compatible success/error content. Used by the handler to wrap the async operation.
export async function safeTool<T>(fn: () => Promise<T>): Promise<ReturnType<typeof successContent> | ReturnType<typeof errorContent>> { try { const result = await fn(); return successContent(result); } catch (error) { return errorContent(error); } } - src/lib/utils.ts:14-17 (helper)The `assertWriteAllowed` helper that throws `WriteNotAllowedError` if write operations are disabled (used by the `w()` call in the handler).
export function assertWriteAllowed(allowWrite: boolean): void { if (!allowWrite) { throw new WriteNotAllowedError(); }