diff --git a/.changeset/light-goats-compare.md b/.changeset/light-goats-compare.md
new file mode 100644
index 00000000000..332683be873
--- /dev/null
+++ b/.changeset/light-goats-compare.md
@@ -0,0 +1,5 @@
+---
+"@smithy/types": patch
+---
+
+Add Smithy context to `HandlerExecutionContext`
diff --git a/.changeset/modern-vans-jam.md b/.changeset/modern-vans-jam.md
new file mode 100644
index 00000000000..2d677d87f88
--- /dev/null
+++ b/.changeset/modern-vans-jam.md
@@ -0,0 +1,5 @@
+---
+"@smithy/util-middleware": patch
+---
+
+Add `getSmithyContext()` helper function
diff --git a/packages/types/src/middleware.ts b/packages/types/src/middleware.ts
index 833bdd0ca18..7d1c07c70d6 100644
--- a/packages/types/src/middleware.ts
+++ b/packages/types/src/middleware.ts
@@ -481,6 +481,11 @@ export interface MiddlewareStack ex
): InitializeHandler;
}
+/**
+ * @internal
+ */
+export const SMITHY_CONTEXT_KEY = "__smithy_context";
+
/**
* @public
*
@@ -526,6 +531,12 @@ export interface HandlerExecutionContext {
overrideOutputFilterSensitiveLog(...args: any[]): string | void;
}>;
+ /**
+ * @internal
+ * Context for Smithy properties
+ */
+ [SMITHY_CONTEXT_KEY]?: Record;
+
[key: string]: any;
}
diff --git a/packages/util-middleware/src/getSmithyContext.ts b/packages/util-middleware/src/getSmithyContext.ts
new file mode 100644
index 00000000000..70ad89bcf81
--- /dev/null
+++ b/packages/util-middleware/src/getSmithyContext.ts
@@ -0,0 +1,7 @@
+import { HandlerExecutionContext, SMITHY_CONTEXT_KEY } from "@smithy/types";
+
+/**
+ * @internal
+ */
+export const getSmithyContext = (context: HandlerExecutionContext): Record =>
+ context[SMITHY_CONTEXT_KEY] || (context[SMITHY_CONTEXT_KEY] = {});
diff --git a/packages/util-middleware/src/index.ts b/packages/util-middleware/src/index.ts
index 37e779c5d53..3869284e42a 100644
--- a/packages/util-middleware/src/index.ts
+++ b/packages/util-middleware/src/index.ts
@@ -1,3 +1,7 @@
+/**
+ * @internal
+ */
+export * from "./getSmithyContext";
/**
* @internal
*/