Guide · Amazon Bedrock · Prompt Management

Bedrock Prompt Versions for MCP Servers — CreatePromptVersionCommand, CI/CD Workflow, and Rollback

Bedrock Prompt Management has two states: a mutable draft and one or more immutable versions. The draft is what you edit — via the AWS Console, the SDK, or your IDE. Calling GetPromptCommand without a promptVersion always returns the current draft, including any unsaved changes you are actively working on. CreatePromptVersionCommand takes a snapshot of the draft and creates an immutable version numbered "1", "2", "3" and so on. Once created, a version cannot be modified. Never use the draft in production. An engineer editing the prompt mid-deployment would change what every running MCP server instance uses for new tool calls, with no rollback path. The production-safe pattern is: store the version number in an environment variable (PROMPT_VERSION=3), pass it to GetPromptCommand, and roll forward or back by changing the env var and restarting. This guide covers the versioning API, the CI/CD workflow for graduating a prompt edit to production, listing versions, comparing versions, and deletion. For the prompt creation and fetch APIs, see Prompt Management Overview. For variable rendering, see Prompt Variables. For CHAT template structure, see CHAT vs TEXT Templates.

TL;DR

CreatePromptVersionCommand snapshots the current draft into an immutable version. Version numbers are integers-as-strings: "1", "2". Pass the version number in GetPromptCommand.promptVersion for production. Store the version in an env var (PROMPT_VERSION). Roll back by decrementing the env var and restarting the server — no code change needed. The draft is never shown in ListPromptsCommand results when listing versions.

Draft vs version: the fundamental distinction

When you call CreatePromptCommand, Bedrock creates a prompt with one state: the draft. The draft is mutable — any subsequent call to CreatePromptCommand with an existing promptIdentifier (or an update API if one is exposed) overwrites the draft. If you edit the prompt template in the AWS Console and save, you are modifying the draft.

A version is a frozen copy of the draft at a point in time. CreatePromptVersionCommand creates the copy. After creation, neither the content nor the metadata of a version can change. The version number is assigned by Bedrock sequentially starting at "1". You cannot specify a version number; you cannot create version "5" without first creating versions "1" through "4".

PropertyDraftVersion
MutableYesNo
Identifier in GetPromptCommandOmit promptVersionpromptVersion: "1"
Response version field"DRAFT""1", "2", etc.
Appears in ListPromptsCommand (by prompt)NoYes
Safe for production useNoYes
DeletableOnly by deleting the entire promptYes, independently

Creating a version with CreatePromptVersionCommand

import {
  BedrockClient,
  CreatePromptVersionCommand,
  GetPromptCommand,
  ListPromptsCommand,
} from "@aws-sdk/client-bedrock";

const client = new BedrockClient({ region: "us-east-1" });

// Snapshot the current draft into an immutable version
const versionResponse = await client.send(new CreatePromptVersionCommand({
  promptIdentifier: process.env.PROMPT_ID!,
  description: "v3 — added few-shot JSON examples to improve extraction accuracy",
  // clientToken: crypto.randomUUID(), // Optional: idempotency key for safe retries
}));

const versionNumber = versionResponse.version!; // "3"
const versionArn = versionResponse.arn!;
// ARN: arn:aws:bedrock:us-east-1:123456789012:prompt/ABCDEF123456:3

console.log(`Created version ${versionNumber}`);
console.log(`ARN: ${versionArn}`);

The description field on CreatePromptVersionCommand is for the version, not the prompt. It is a good place to record what changed in this version — equivalent to a commit message. The prompt's own description field is separate and applies to all versions.

Gotcha: creating a version does not advance the draft. After CreatePromptVersionCommand, the draft is still at the same state it was before the call. If you immediately edit the draft again, the next CreatePromptVersionCommand will snapshot those new edits as version "4". Version "3" remains unchanged.

Fetching a specific version

Pass the version number string to GetPromptCommand.promptVersion:

// Fetch version 3 (immutable)
const v3 = await client.send(new GetPromptCommand({
  promptIdentifier: process.env.PROMPT_ID!,
  promptVersion: "3",
}));

console.log("version:", v3.version);         // "3"
console.log("createdAt:", v3.createdAt);
// v3.variants is the snapshot of the variants at the time version 3 was created

// Fetch version 1 (the first snapshot ever made)
const v1 = await client.send(new GetPromptCommand({
  promptIdentifier: process.env.PROMPT_ID!,
  promptVersion: "1",
}));

console.log("template at v1:", v1.variants?.[0].templateConfiguration?.text?.text);

The promptVersion parameter accepts the version number as a string, not an integer. Passing promptVersion: 3 (a TypeScript number) causes a TypeScript type error; pass "3" (a string). Passing a version number that does not exist throws ResourceNotFoundException: Prompt version 99 does not exist for prompt ABCDEF123456.

Listing versions

To see all versions of a prompt, call ListPromptsCommand with promptIdentifier:

const versionsResponse = await client.send(new ListPromptsCommand({
  promptIdentifier: process.env.PROMPT_ID!,
}));

const versions = versionsResponse.promptSummaries ?? [];
// Sorted by version number ascending (1, 2, 3, ...)
for (const v of versions) {
  console.log(`version ${v.version}: ${v.description} (${v.updatedAt?.toISOString()})`);
}

// Get the latest version number
const latestVersion = versions.at(-1)?.version;
console.log("Latest version:", latestVersion); // "4"

// Paginate if the prompt has many versions
let nextToken = versionsResponse.nextToken;
while (nextToken) {
  const page = await client.send(new ListPromptsCommand({
    promptIdentifier: process.env.PROMPT_ID!,
    nextToken,
  }));
  for (const v of page.promptSummaries ?? []) {
    console.log(`version ${v.version}: ${v.description}`);
  }
  nextToken = page.nextToken;
}

The draft is not included in this listing. Only committed versions appear. If you have never called CreatePromptVersionCommand, the listing is empty — the prompt exists but has no versions yet.

CI/CD workflow for prompt graduation

The recommended workflow decouples prompt iteration from code deployments:

  1. Edit the draft. An engineer edits the prompt template in the AWS Console or via SDK. The edit takes effect immediately on GetPromptCommand without promptVersion.
  2. Test against the draft. Run an offline evaluation script that calls GetPromptCommand (no version) and passes test inputs through invokeTextPrompt or invokeChatPrompt. Compare outputs against expected outputs. This is fast — no deployment needed.
  3. Freeze a version. When the draft passes evaluation, call CreatePromptVersionCommand. Record the returned version number (e.g. "4") and the description.
  4. Update the environment variable. Set PROMPT_VERSION=4 in the deployment configuration (ECS task definition, Lambda function config, Kubernetes ConfigMap, etc.).
  5. Deploy the MCP server. The server restarts and reads version "4" at startup. No code change occurred — the diff is purely a configuration change.
  6. Monitor for regressions. If tool call quality drops, set PROMPT_VERSION=3 and redeploy. The rollback completes in seconds.
// evaluation-script.ts — run before creating a version
import { invokeTextPrompt } from "./prompt-utils.js";

const PROMPT_ID = process.env.PROMPT_ID!;
const DRAFT_VERSION = "DRAFT"; // special sentinel — handled by omitting promptVersion

interface EvalCase {
  variables: Record<string, string>;
  expectedSubstrings: string[];
}

const testCases: EvalCase[] = [
  {
    variables: { content: "Amazon S3 stores objects in buckets.", max_sentences: "1" },
    expectedSubstrings: ["S3", "storage"],
  },
  {
    variables: { content: "Lambda runs code without provisioning servers.", max_sentences: "2" },
    expectedSubstrings: ["Lambda", "serverless"],
  },
];

async function evaluateDraft(): Promise<void> {
  let passed = 0;
  for (const tc of testCases) {
    // Call without promptVersion to test the draft
    const output = await invokeTextPrompt(PROMPT_ID, "DRAFT", tc.variables);
    const ok = tc.expectedSubstrings.every(s => output.toLowerCase().includes(s.toLowerCase()));
    console.log(ok ? "PASS" : "FAIL", output.slice(0, 80));
    if (ok) passed++;
  }
  console.log(`${passed}/${testCases.length} test cases passed`);
  if (passed < testCases.length) process.exit(1);
}

await evaluateDraft();

Note: the evaluation script passes a sentinel "DRAFT" string. The invokeTextPrompt helper must handle this by omitting promptVersion from GetPromptCommand when the value equals "DRAFT":

// In invokeTextPrompt / getCachedVariant:
const getPromptInput = {
  promptIdentifier: promptId,
  ...(promptVersion !== "DRAFT" ? { promptVersion } : {}),
};

Comparing two versions

To audit what changed between two versions, fetch both and diff the template text:

async function compareVersions(
  promptId: string,
  versionA: string,
  versionB: string,
): Promise<void> {
  const [a, b] = await Promise.all([
    client.send(new GetPromptCommand({ promptIdentifier: promptId, promptVersion: versionA })),
    client.send(new GetPromptCommand({ promptIdentifier: promptId, promptVersion: versionB })),
  ]);

  const templateA = a.variants?.[0].templateConfiguration?.text?.text ?? "(no text)";
  const templateB = b.variants?.[0].templateConfiguration?.text?.text ?? "(no text)";

  if (templateA === templateB) {
    console.log(`Versions ${versionA} and ${versionB} have identical templates`);
  } else {
    console.log(`--- version ${versionA}`);
    console.log(templateA);
    console.log(`+++ version ${versionB}`);
    console.log(templateB);
  }

  // Also compare inference configuration
  const infA = a.variants?.[0].inferenceConfiguration?.text;
  const infB = b.variants?.[0].inferenceConfiguration?.text;
  if (JSON.stringify(infA) !== JSON.stringify(infB)) {
    console.log("Inference config changed:", infA, "->", infB);
  }
}

Deleting versions and prompts

To delete a specific version without affecting other versions or the draft:

import { DeletePromptCommand } from "@aws-sdk/client-bedrock";

// Delete version 1 only (old, no longer needed)
await client.send(new DeletePromptCommand({
  promptIdentifier: process.env.PROMPT_ID!,
  promptVersion: "1",
}));

// Delete the entire prompt (draft + all versions)
// WARNING: irreversible — all versions are permanently deleted
await client.send(new DeletePromptCommand({
  promptIdentifier: process.env.PROMPT_ID!,
  // omit promptVersion to delete the prompt entirely
}));

Deleting a version that is currently referenced by a running MCP server instance does not break that instance if the template is cached. The next restart will fail with ResourceNotFoundException for the deleted version. Before deleting an old version, verify no running services reference it by checking which PROMPT_VERSION env var values are deployed.

There is no soft-delete or recycle bin for prompts or versions. Deletion is permanent and immediate. Consider keeping all versions until a prompt is fully retired — storage costs for prompt resources are negligible.

Environment variable conventions

A consistent naming convention for the prompt-related environment variables that MCP servers use:

VariableExample valueDescription
SUMMARIZE_PROMPT_IDABCDEF123456Prompt ID (never changes)
SUMMARIZE_PROMPT_VERSION4Version to use in production (bumped on each promotion)
EXTRACT_PROMPT_IDGHIJKL789012Separate prompt for entity extraction
EXTRACT_PROMPT_VERSION2Version for extraction prompt

Keeping _ID and _VERSION as separate variables — rather than a combined ARN — makes rollback a single variable change. It also avoids the temptation to hardcode the prompt ARN (which embeds the region and account ID) in application code.

Monitoring prompt version health with AliveMCP

When an MCP server starts up and fetches a prompt version, three failure modes can occur silently: ResourceNotFoundException (version was deleted), AccessDeniedException (IAM role lost bedrock:GetPrompt permission after a policy rotation), or ThrottlingException (burst of server restarts all fetching prompts simultaneously). AliveMCP monitors your MCP server's health endpoint and alerts within 60 seconds of a startup failure, so a misconfigured PROMPT_VERSION env var is caught immediately after a deployment rather than discovered by users when their tool calls fail.

Related pages in this arc

For related versioning patterns with other Bedrock resources, see Bedrock Agents (agent versions and aliases) and Bedrock Knowledge Base (data source sync).