---
name: create-env-from-blueprint
description: Create a CloudShare virtual environment from a blueprint, using the CloudShare MCP tools (list_projects, list_blueprints, get_create_from_blueprint_defaults, create_cloudshare_environment_from_blueprint, and related list_* lookups). Use this whenever the user asks to create, spin up, launch, provision, or deploy a CloudShare environment from a blueprint — even if they only name a blueprint, a project, or say "create an env" — since it resolves the project/blueprint/policy/region/snapshot/owner defaults, confirms them with the user, creates the environment, and returns its URL.
---

# CloudShare Environment Creator

Create a CloudShare virtual environment from a blueprint.

## Workflow

### 1. Identify project and blueprint

If the user provided a blueprint name or project name, use them to filter. Otherwise, fetch all options:
- Run `list_projects` (with `purpose: EnvCreationFromBp`) and `list_blueprints` in parallel (blueprints require a `projectId` and `regionId` — get regions via `list_regions` first if needed).
- If multiple projects or blueprints are returned, ask the user to pick one before continuing.

### 2. Get creation defaults

Call `get_create_from_blueprint_defaults` with the resolved `projectId` and `blueprintId`.

**If it succeeds:** use the returned values (project, team, owner, policy, region, snapshot, environmentName, environmentDescription) directly.

**If it returns an error:** fall back to fetching each value individually using the list tools in parallel:
- `list_policies` (projectId) — prefer `isMostUsed` or `isRecentlyUsed`
- `list_regions` (projectId) — prefer `isDefault`
- `get_next_cloudshare_environment_name` (base name = blueprint name)
- `list_teams` (projectId, purpose: EnvCreationFromBp) — if empty, omit `teamId`
- If a team is found, `list_owners` (projectId, teamId, purpose: EnvCreationFromBp) — prefer `isMe` or `isRecentlyAssigned`; if no match, omit `ownerEmail`
- Use the blueprint's `defaultSnapshotId` for the snapshot

### 3. Confirm with the user

Show all resolved values (use names, not IDs) and ask for confirmation before creating:
- Environment name
- Blueprint
- Project
- Policy
- Region
- Snapshot
- Owner (if set)

### 4. Create the environment

Call `create_cloudshare_environment_from_blueprint` with the confirmed values.

### 5. Return the environment URL

The tool returns an environment ID like `ENxxx`. Remove the `EN` prefix to build the URL:

```
https://use.cloudshare.com/Ent/CsClient.mvc/#/app/legacy/Ent/Environment.mvc/View/<id-without-EN>
```

Present it as a sentence with a named link rather than a bare URL, in exactly this format:

```
Here is the link to your environment - [Open - <environment name>](<url>)
```

e.g. `Here is the link to your environment - [Open - Base V.3](https://use.cloudshare.com/...)`. The environment name is the one the user confirmed in step 3 (suffixed per environment when `count` > 1, e.g. `Open - Base V.3.2`). Never show the raw URL. Follow it with a summary (VM name, CPU, RAM, disk, username) for each environment created.

## Quick reference — tool call order

| Step | Tool(s) | Notes |
|---|---|---|
| 1 | `list_projects`, `list_blueprints` (+ `list_regions` if needed) | Run in parallel; narrow by user-given names first |
| 2 | `get_create_from_blueprint_defaults` | One-call happy path |
| 2 (fallback) | `list_policies`, `list_regions`, `get_next_cloudshare_environment_name`, `list_teams`, `list_owners` | Run in parallel; omit `teamId`/`ownerEmail` if nothing matches |
| 3 | — | Confirm resolved values with the user before creating |
| 4 | `create_cloudshare_environment_from_blueprint` | Only after user confirmation |
| 5 | — | Build URL from returned `ENxxx` id, present as `Here is the link to your environment - [Open - <environment name>](<url>)`, summarize VM specs |

## Common mistakes

- Creating the environment before showing the resolved defaults for confirmation (step 3 is not optional).
- Passing a `teamId`/`ownerEmail` when the corresponding lookup came back empty — omit the field instead of guessing.
- Forgetting to strip the `EN` prefix when building the environment URL.
- Presenting the raw URL, or the link without the lead-in sentence `Here is the link to your environment - [Open - <environment name>](<url>)`.
