@aws/nx-plugin-mcp 1.0.0-rc.56 → 1.0.0-rc.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,6 +60,7 @@ The generator will add the following files to your existing TypeScript project.
60
60
  - init.ts tRPC initialization
61
61
  - router.ts tRPC router with agent procedures
62
62
  - agent.ts Main agent definition with sample tools
63
+ - session.ts Resolves the SessionManager used to persist conversation state
63
64
  - client.ts Vended client for invoking your agent
64
65
  - agent-core-trpc-client.ts Client factory for connecting to agents on AgentCore Runtime
65
66
  - Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
@@ -79,6 +80,7 @@ The entry point uses the [Strands A2A Express Server](https://strandsagents.com/
79
80
  - agent/ (or custom name if specified)
80
81
  - index.ts A2A Express server entry point
81
82
  - agent.ts Main agent definition with sample tools
83
+ - session.ts Resolves the SessionManager used to persist conversation state
82
84
  - Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
83
85
  - package.json Updated with Strands and Express dependencies
84
86
  - project.json Updated with agent serve targets
@@ -96,6 +98,7 @@ The entry point uses [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui
96
98
  - agent/ (or custom name if specified)
97
99
  - index.ts AG-UI server entry point (Express + SSE)
98
100
  - agent.ts Main agent definition with sample tools
101
+ - session.ts Resolves the SessionManager used to persist conversation state
99
102
  - Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
100
103
  - package.json Updated with Strands and AG-UI dependencies
101
104
  - project.json Updated with agent serve targets
@@ -185,7 +188,7 @@ const letterCounter = tool({
185
188
  });
186
189
 
187
190
  // Add tools to your agent
188
- export const getAgent = async (sessionId: string) => {
191
+ export const getAgent = async () => {
189
192
  return new Agent({
190
193
  systemPrompt: 'You are a helpful assistant with access to various tools.',
191
194
  tools: [letterCounter],
@@ -347,6 +350,29 @@ Your agent is automatically configured with observability using the [AWS Distro
347
350
  You can find traces in the CloudWatch AWS Console, by selecting "GenAI Observability" in the menu. Note that for traces to be populated you will need to enable [Transaction Search](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html).
348
351
 
349
352
  For more details, refer to the [AgentCore documentation on observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-configure.html).
353
+
354
+ ### Session Management
355
+
356
+ The `session` option controls how your agent persists conversation state (message history, tool state, etc.) across invocations, using the Strands SDK's [SessionManager](https://strandsagents.com/docs/user-guide/concepts/agents/session-management/):
357
+
358
+ - **`s3`** (default): The CDK/Terraform infrastructure provisions a dedicated S3 bucket for session data, encrypted with a dedicated KMS key and with all public access blocked; server access logs are delivered to a CloudWatch Logs log group via the same key. The agent's IAM role is granted read/write/list/delete access to the bucket and decrypt/generate-data-key access to the key, and the bucket name is registered alongside the agent's ARN in AppConfig runtime configuration.
359
+ - **`in-memory`**: No bucket is provisioned. Conversation state is kept in memory only for the lifetime of the running process and does not survive restarts or scale-in.
360
+
361
+ This is implemented in the generated `session.ts`, which exports a `getSessionManager()` function resolving a `SessionManager` for the current session.
362
+
363
+ <OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI session wiring">
364
+ Since AG-UI clones a template agent per conversation thread, `getSessionManager` is wired in as a `sessionManagerProvider` on the `StrandsAgent` config in `index.ts`, so a fresh `SessionManager` is resolved for each thread rather than baked into the shared template agent.
365
+ </OptionFilter>
366
+
367
+ <OptionFilter when={{ protocol: ['http', 'a2a'] }} description="HTTP/A2A session wiring">
368
+ Since `withSessionId` already caches one `Agent` instance per session, `getSessionManager` is called directly inside `getAgent`'s `new Agent({ sessionManager: await getSessionManager() })` call in `agent.ts`.
369
+ </OptionFilter>
370
+
371
+ The session ID itself comes from the AgentCore Runtime session (propagated via the `x-amzn-bedrock-agentcore-runtime-session-id` header for A2A/AG-UI, or the WebSocket connection context for HTTP/tRPC) and is bound to an [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage)-based context so `getCurrentSessionId()` can resolve it anywhere in the request — including in any downstream MCP or A2A clients wired up via the <Link path="/guides/connection">`connection` generator</Link>, so the whole call chain shares a consistent session.
372
+
373
+ :::note[Local Development]
374
+ When running locally (`LOCAL_DEV=true`, set automatically by the `-dev` target), session data is always stored on disk under `tmp/agents/strands/<agent-name>` at the workspace root, regardless of the configured `session` option, for convenience.
375
+ :::
350
376
  </OptionFilter>
351
377
 
352
378
  ## Invoking your Agent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.0.0-rc.56",
3
+ "version": "1.0.0-rc.57",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -60,6 +60,14 @@
60
60
  "default": "agentcore",
61
61
  "x-priority": "important"
62
62
  },
63
+ "session": {
64
+ "type": "string",
65
+ "description": "The storage used to persist session for your Agent. Only 'in-memory' is currently supported for Python agents.",
66
+ "x-prompt": "How would you like to persist session for your Agent?",
67
+ "enum": ["in-memory"],
68
+ "default": "in-memory",
69
+ "x-priority": "important"
70
+ },
63
71
  "preferInstallDependencies": {
64
72
  "type": "boolean",
65
73
  "description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
@@ -60,6 +60,14 @@
60
60
  "default": "agentcore",
61
61
  "x-priority": "important"
62
62
  },
63
+ "session": {
64
+ "type": "string",
65
+ "description": "The storage used to persist session for your Agent.",
66
+ "x-prompt": "How would you like to persist session for your Agent?",
67
+ "enum": ["s3", "in-memory"],
68
+ "default": "s3",
69
+ "x-priority": "important"
70
+ },
63
71
  "preferInstallDependencies": {
64
72
  "type": "boolean",
65
73
  "description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",