@aws/nx-plugin-mcp 1.0.0-rc.17 → 1.0.0-rc.19
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.
- package/bin/aws-nx-mcp.js +9 -1
- package/docs/guides/agentcore-gateway.mdx +1 -0
- package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
- package/docs/guides/connection/py-agent-a2a.mdx +8 -5
- package/docs/guides/connection/py-agent-gateway.mdx +8 -5
- package/docs/guides/connection/py-agent-mcp.mdx +7 -4
- package/docs/guides/connection/ts-agent-a2a.mdx +8 -5
- package/docs/guides/connection/ts-agent-gateway.mdx +7 -5
- package/docs/guides/connection/ts-agent-mcp.mdx +7 -4
- package/docs/guides/connection.mdx +7 -0
- package/docs/guides/trpc.mdx +1 -1
- package/generators.json +9 -1
- package/package.json +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.json +26 -0
package/bin/aws-nx-mcp.js
CHANGED
|
@@ -19753,6 +19753,13 @@ var generators$1 = {
|
|
|
19753
19753
|
"metric": "g49",
|
|
19754
19754
|
"hidden": true
|
|
19755
19755
|
},
|
|
19756
|
+
"agentcore-gateway#gateway-connection": {
|
|
19757
|
+
"factory": "./src/agentcore-gateway/gateway-connection/generator",
|
|
19758
|
+
"schema": "./src/agentcore-gateway/gateway-connection/schema.json",
|
|
19759
|
+
"description": "Connect an AgentCore Gateway to another AgentCore Gateway",
|
|
19760
|
+
"metric": "g52",
|
|
19761
|
+
"hidden": true
|
|
19762
|
+
},
|
|
19756
19763
|
"connection": {
|
|
19757
19764
|
"factory": "./src/connection/generator",
|
|
19758
19765
|
"schema": "./src/connection/schema.json",
|
|
@@ -19776,7 +19783,8 @@ var generators$1 = {
|
|
|
19776
19783
|
"connection/ts-agent-rdb",
|
|
19777
19784
|
"connection/ts-agent-gateway",
|
|
19778
19785
|
"connection/py-agent-gateway",
|
|
19779
|
-
"connection/agentcore-gateway-mcp"
|
|
19786
|
+
"connection/agentcore-gateway-mcp",
|
|
19787
|
+
"connection/agentcore-gateway-gateway"
|
|
19780
19788
|
]
|
|
19781
19789
|
},
|
|
19782
19790
|
"license": {
|
|
@@ -235,5 +235,6 @@ See the connection guide for the full local development story.
|
|
|
235
235
|
## Next steps
|
|
236
236
|
|
|
237
237
|
- Connect an MCP server: <Link path="guides/connection/agentcore-gateway-mcp">`agentcore-gateway#mcp-connection`</Link>
|
|
238
|
+
- Connect another Gateway: <Link path="guides/connection/agentcore-gateway-gateway">`agentcore-gateway#gateway-connection`</Link>
|
|
238
239
|
- Connect a TypeScript Agent: <Link path="guides/connection/ts-agent-gateway">`ts#agent#gateway-connection`</Link>
|
|
239
240
|
- Connect a Python Agent: <Link path="guides/connection/py-agent-gateway">`py#agent#gateway-connection`</Link>
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AgentCore Gateway to AgentCore Gateway
|
|
3
|
+
description: Connect an AgentCore Gateway to another AgentCore Gateway
|
|
4
|
+
when:
|
|
5
|
+
sourceType: agentcore-gateway
|
|
6
|
+
targetType: agentcore-gateway
|
|
7
|
+
---
|
|
8
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
9
|
+
import Link from '@components/link.astro';
|
|
10
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
11
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
12
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
13
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
14
|
+
|
|
15
|
+
The `connection` generator can register an <Link path="guides/agentcore-gateway">AgentCore Gateway</Link> as a target of another AgentCore Gateway. This lets you compose gateways hierarchically — for example a team-level gateway aggregating several domain gateways, each of which fronts its own MCP servers.
|
|
16
|
+
|
|
17
|
+
Once connected, the source Gateway aggregates the target Gateway's tools into its single MCP endpoint. Since the target Gateway already prefixes its tools with its own target names, tools surface through the source Gateway as `<gateway-target-name>___<target-name>___<tool-name>` — each gateway in the chain adds one prefix. Both gateways evaluate their own Cedar policies: the source Gateway authorizes the caller for the prefixed action, then the target Gateway authorizes the source Gateway's execution role for the inner action.
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Before using this generator, ensure you have:
|
|
22
|
+
|
|
23
|
+
1. Two <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> projects
|
|
24
|
+
|
|
25
|
+
Both gateways must have `protocol: mcp`, and the target gateway must have `auth: iam` — the source gateway invokes the target signing with its own execution role, so only the target's inbound auth needs to be IAM. The generator validates this, and also rejects connections that would create a cycle between gateways, which would otherwise recurse infinitely on `tools/list`.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Run the Generator
|
|
30
|
+
|
|
31
|
+
<RunGenerator generator="connection" />
|
|
32
|
+
|
|
33
|
+
Select the aggregating Gateway project as the source and the Gateway to be aggregated as the target.
|
|
34
|
+
|
|
35
|
+
### Options
|
|
36
|
+
|
|
37
|
+
<GeneratorParameters generator="connection" />
|
|
38
|
+
|
|
39
|
+
## Generator Output
|
|
40
|
+
|
|
41
|
+
The generator wires existing projects together rather than emitting new source files. The following files are modified:
|
|
42
|
+
|
|
43
|
+
<FileTree>
|
|
44
|
+
|
|
45
|
+
- packages/\<source-gateway>
|
|
46
|
+
- project.json `<source-gateway>-serve-local` gains a dependency on the target gateway's `<target-gateway>-serve-local`
|
|
47
|
+
- serve-local.ts `ATTACHED_MCP_SERVERS` updated so the local gateway aggregates the target gateway
|
|
48
|
+
|
|
49
|
+
</FileTree>
|
|
50
|
+
|
|
51
|
+
The source Gateway project's `<source-gateway>-serve-local` target gains a dependency on the target Gateway's `<target-gateway>-serve-local` target, so running the source Gateway locally also starts the target gateway (and, transitively, every MCP server attached to it). The target gateway is also registered in the source Gateway project's `serve-local.ts` so the local gateway aggregates its tools.
|
|
52
|
+
|
|
53
|
+
## Adding the gateway target to your stack
|
|
54
|
+
|
|
55
|
+
The generator **cannot** automatically wire the gateway target into your infrastructure because it doesn't know which stack or module instantiates the Gateways. Add a single call to `gateway.addGateway(targetGateway)` yourself.
|
|
56
|
+
|
|
57
|
+
<Infrastructure>
|
|
58
|
+
<Fragment slot="cdk">
|
|
59
|
+
In the stack where you instantiate the Gateways, register the target gateway as a target of the source gateway:
|
|
60
|
+
|
|
61
|
+
```ts title="packages/infra/src/stacks/application-stack.ts" {5-6}
|
|
62
|
+
const innerGateway = new InnerGateway(this, 'InnerGateway');
|
|
63
|
+
const outerGateway = new OuterGateway(this, 'OuterGateway');
|
|
64
|
+
|
|
65
|
+
// Register the inner gateway as a target of the outer gateway. The target
|
|
66
|
+
// name defaults to the inner gateway's `gatewayName` (its class name in
|
|
67
|
+
// kebab-case, e.g. `InnerGateway` -> `inner-gateway`).
|
|
68
|
+
outerGateway.addGateway(innerGateway);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The Gateway target name (the target gateway's `gatewayName` by default) prefixes Cedar action names on the source gateway — the action format is ``AgentCore::Action::"<gatewayTargetName>___<targetName>___<toolName>"``. See the <Link path="guides/agentcore-gateway">Writing Policies section</Link>. Keep the target name short and stable; changing it later invalidates any Cedar policies that reference the old name.
|
|
72
|
+
|
|
73
|
+
To override the default target name, pass `gatewayTargetName`:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
outerGateway.addGateway(innerGateway, { gatewayTargetName: 'inner' });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The construct grants the source gateway's execution role `bedrock-agentcore:InvokeGateway` access to the target gateway, and configures the target with `iamCredentialProvider.service = 'bedrock-agentcore'` so the source gateway signs outbound calls using its own execution role. The target is created after the target gateway and all of its own targets, since AgentCore fetches the target's tools during creation.
|
|
80
|
+
</Fragment>
|
|
81
|
+
<Fragment slot="terraform">
|
|
82
|
+
In the Terraform file where you instantiate the Gateways, wire the gateway target in:
|
|
83
|
+
|
|
84
|
+
```hcl title="packages/infra/src/main.tf" {2-5,11-15,18-36}
|
|
85
|
+
module "inner_gateway" {
|
|
86
|
+
source = "../../common/terraform/src/app/gateways/inner-gateway"
|
|
87
|
+
|
|
88
|
+
# Target ids of the inner gateway's own targets (e.g. its MCP servers), so
|
|
89
|
+
# its gateway_url is not consumed until it serves their tools.
|
|
90
|
+
tool_dependencies = [aws_bedrockagentcore_gateway_target.my_mcp_server.target_id]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module "outer_gateway" {
|
|
94
|
+
source = "../../common/terraform/src/app/gateways/outer-gateway"
|
|
95
|
+
policy_dependencies = [aws_bedrockagentcore_gateway_target.inner_gateway.target_id]
|
|
96
|
+
|
|
97
|
+
additional_iam_policy_statements = [
|
|
98
|
+
{
|
|
99
|
+
Effect = "Allow"
|
|
100
|
+
Action = ["bedrock-agentcore:InvokeGateway"]
|
|
101
|
+
Resource = [module.inner_gateway.gateway_arn]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Register the inner gateway as a target of the outer gateway
|
|
107
|
+
resource "aws_bedrockagentcore_gateway_target" "inner_gateway" {
|
|
108
|
+
gateway_identifier = module.outer_gateway.gateway_id
|
|
109
|
+
name = "inner-gateway"
|
|
110
|
+
|
|
111
|
+
target_configuration {
|
|
112
|
+
mcp {
|
|
113
|
+
mcp_server {
|
|
114
|
+
endpoint = module.inner_gateway.gateway_url
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
credential_provider_configuration {
|
|
120
|
+
gateway_iam_role {
|
|
121
|
+
service = "bedrock-agentcore"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The target `name` (`inner-gateway` above) prefixes Cedar action names on the outer gateway — see the <Link path="guides/agentcore-gateway">Writing Policies section</Link>. The `additional_iam_policy_statements` entry grants the outer gateway's execution role invoke access to the inner gateway, which is required both to fetch the inner gateway's tools at target creation time and to route calls at runtime. `policy_dependencies` ensures Cedar policies referencing this target's actions are created after the target has registered them.
|
|
128
|
+
|
|
129
|
+
:::note[Target ordering]
|
|
130
|
+
AgentCore fetches the inner gateway's tools when the `aws_bedrockagentcore_gateway_target` is created, so the inner gateway must already be serving them. Set the inner gateway's `tool_dependencies` to its own targets' ids: its `gateway_url` then flows through a readiness probe that polls `tools/list` until those tools are served, so the outer gateway's target waits for the inner gateway to be ready.
|
|
131
|
+
:::
|
|
132
|
+
</Fragment>
|
|
133
|
+
</Infrastructure>
|
|
134
|
+
|
|
135
|
+
## Cedar policies across chained gateways
|
|
136
|
+
|
|
137
|
+
Each gateway in the chain evaluates its own policy set:
|
|
138
|
+
|
|
139
|
+
1. The **source gateway** evaluates the original caller (e.g. an agent's execution role) against the prefixed action, e.g. `AgentCore::Action::"inner-gateway___my-mcp___add"`.
|
|
140
|
+
2. The **target gateway** evaluates the source gateway's execution role against the inner action, e.g. `AgentCore::Action::"my-mcp___add"`.
|
|
141
|
+
|
|
142
|
+
This means a tool call through a gateway chain must be permitted at every hop. The default `permit-all.cedar` permits any caller in the same AWS account, which includes the source gateway's role; if you write narrower policies on the target gateway, remember that the principal it sees is the *source gateway's* role, not the original caller.
|
|
143
|
+
|
|
144
|
+
## Local Development
|
|
145
|
+
|
|
146
|
+
Running the source Gateway locally with:
|
|
147
|
+
|
|
148
|
+
<NxCommands commands={["<source-gateway-name>-serve-local"]} />
|
|
149
|
+
|
|
150
|
+
starts the local source gateway, the local target gateway, and every MCP server attached to either, each on its assigned local port. Tool names are prefixed at each hop exactly as deployed (`<gateway-target-name>___<target-name>___<tool-name>`), so agent prompts and Cedar action names remain consistent across local and deployed runs.
|
|
151
|
+
|
|
152
|
+
:::caution[Local fidelity]
|
|
153
|
+
Local development uses **local stand-in gateways** — lightweight MCP aggregators started by each Gateway project, not the AgentCore Gateway service. As a consequence, **Cedar policies are not evaluated locally** at either hop. To exercise Cedar policies, run the agent's `serve` target instead (see the <Link path="guides/connection/ts-agent-gateway">TypeScript</Link> / <Link path="guides/connection/py-agent-gateway">Python</Link> agent-connection guides) so the locally-running agent calls the deployed Gateway.
|
|
154
|
+
:::
|
|
@@ -48,9 +48,12 @@ The generator creates a shared `agent_connection` Python project at `packages/co
|
|
|
48
48
|
- \<scope>\_agent\_connection
|
|
49
49
|
- \_\_init\_\_.py Re-exports per-connection clients
|
|
50
50
|
- core
|
|
51
|
-
- agentcore\
|
|
51
|
+
- agentcore\_endpoints.py Framework-agnostic ARN/URL resolution
|
|
52
|
+
- agentcore\_a2a\_client\_config.py Framework-agnostic A2A client config (signed `ClientConfig`)
|
|
53
|
+
- agentcore\_a2a\_client\_strands.py Strands A2A client wrapping the config
|
|
54
|
+
- auth/ Framework-agnostic SigV4 / session-forwarding `httpx.Auth`
|
|
52
55
|
- app
|
|
53
|
-
- \<target\_agent\_name>\_client.py Per-connection client for each A2A agent
|
|
56
|
+
- \<target\_agent\_name>\_client\_strands.py Per-connection Strands client for each A2A agent
|
|
54
57
|
|
|
55
58
|
</FileTree>
|
|
56
59
|
|
|
@@ -67,11 +70,11 @@ The generator transforms your agent's `agent.py` to wrap the remote A2A agent as
|
|
|
67
70
|
from contextlib import contextmanager
|
|
68
71
|
from strands import Agent, tool
|
|
69
72
|
|
|
70
|
-
from my_scope_agent_connection import
|
|
73
|
+
from my_scope_agent_connection import RemoteAgentClientStrands
|
|
71
74
|
|
|
72
75
|
@contextmanager
|
|
73
76
|
def get_agent(session_id: str):
|
|
74
|
-
remote_agent =
|
|
77
|
+
remote_agent = RemoteAgentClientStrands.create(session_id=session_id)
|
|
75
78
|
|
|
76
79
|
@tool
|
|
77
80
|
def ask_remote_agent(prompt: str) -> str:
|
|
@@ -86,7 +89,7 @@ def get_agent(session_id: str):
|
|
|
86
89
|
|
|
87
90
|
The `session_id` parameter is plumbed through from the caller, ensuring consistency for [Bedrock AgentCore Observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability.html).
|
|
88
91
|
|
|
89
|
-
Under the hood, `
|
|
92
|
+
Under the hood, `RemoteAgentClientStrands.create(session_id=...)` returns a Strands `A2AAgent` configured with an `httpx.AsyncClient` that signs requests with SigV4 when deployed to AWS, and a plain `http://localhost:<port>/` endpoint when `SERVE_LOCAL=true`.
|
|
90
93
|
|
|
91
94
|
## Infrastructure
|
|
92
95
|
|
|
@@ -44,9 +44,12 @@ The generator emits shared core-gateway modules into your `agent_connection` Pyt
|
|
|
44
44
|
- packages/common/agent\_connection
|
|
45
45
|
- \<scope>\_agent\_connection
|
|
46
46
|
- core/
|
|
47
|
-
- agentcore\
|
|
47
|
+
- agentcore\_endpoints.py Framework-agnostic ARN/URL resolution
|
|
48
|
+
- agentcore\_gateway\_mcp\_transport.py Framework-agnostic Gateway MCP transport
|
|
49
|
+
- agentcore\_gateway\_mcp\_client\_strands.py Strands MCP client for the deployed Gateway
|
|
50
|
+
- auth/ Framework-agnostic SigV4 / session-forwarding `httpx.Auth`
|
|
48
51
|
- app/
|
|
49
|
-
- \<gateway\_snake>\_client.py Per-Gateway client wrapper
|
|
52
|
+
- \<gateway\_snake>\_client\_strands.py Per-Gateway Strands client wrapper
|
|
50
53
|
- \_\_init\_\_.py Re-exports the Gateway client
|
|
51
54
|
|
|
52
55
|
</FileTree>
|
|
@@ -65,11 +68,11 @@ The generator transforms your agent's `agent.py` to use the Gateway client:
|
|
|
65
68
|
from contextlib import contextmanager
|
|
66
69
|
from strands import Agent
|
|
67
70
|
|
|
68
|
-
from my_scope_agent_connection import
|
|
71
|
+
from my_scope_agent_connection import MyGatewayClientStrands
|
|
69
72
|
|
|
70
73
|
@contextmanager
|
|
71
74
|
def get_agent():
|
|
72
|
-
my_gateway =
|
|
75
|
+
my_gateway = MyGatewayClientStrands.create()
|
|
73
76
|
with (
|
|
74
77
|
my_gateway,
|
|
75
78
|
):
|
|
@@ -79,7 +82,7 @@ def get_agent():
|
|
|
79
82
|
)
|
|
80
83
|
```
|
|
81
84
|
|
|
82
|
-
`
|
|
85
|
+
`MyGatewayClientStrands.create()` returns a single context-manageable client whose `list_tools_sync()` yields every tool available through the Gateway:
|
|
83
86
|
|
|
84
87
|
- **Deployed mode** (`SERVE_LOCAL` unset): a single `MCPClient` pointed at the Gateway's MCP endpoint, SigV4-signed.
|
|
85
88
|
- **Local mode** (`SERVE_LOCAL=true`): a plain-HTTP `MCPClient` pointed at the local gateway started by the Gateway project's `serve-local` target.
|
|
@@ -48,9 +48,12 @@ The generator creates a shared `agent_connection` Python project at `packages/co
|
|
|
48
48
|
- \<scope>\_agent\_connection
|
|
49
49
|
- \_\_init\_\_.py Re-exports per-connection clients
|
|
50
50
|
- core
|
|
51
|
-
- agentcore\
|
|
51
|
+
- agentcore\_endpoints.py Framework-agnostic ARN/URL resolution
|
|
52
|
+
- agentcore\_mcp\_transport.py Framework-agnostic MCP transport
|
|
53
|
+
- agentcore\_mcp\_client\_strands.py Strands MCP client wrapping the transport
|
|
54
|
+
- auth/ Framework-agnostic SigV4 / session-forwarding `httpx.Auth`
|
|
52
55
|
- app
|
|
53
|
-
- \<mcp\_server\_name>\_client.py Per-connection client for each MCP server
|
|
56
|
+
- \<mcp\_server\_name>\_client\_strands.py Per-connection Strands client for each MCP server
|
|
54
57
|
|
|
55
58
|
</FileTree>
|
|
56
59
|
|
|
@@ -67,11 +70,11 @@ The generator transforms your agent's `agent.py` to use the MCP server's tools:
|
|
|
67
70
|
from contextlib import contextmanager
|
|
68
71
|
from strands import Agent
|
|
69
72
|
|
|
70
|
-
from my_scope_agent_connection import
|
|
73
|
+
from my_scope_agent_connection import MyMcpServerClientStrands
|
|
71
74
|
|
|
72
75
|
@contextmanager
|
|
73
76
|
def get_agent(session_id: str):
|
|
74
|
-
my_mcp_server =
|
|
77
|
+
my_mcp_server = MyMcpServerClientStrands.create(session_id=session_id)
|
|
75
78
|
with (
|
|
76
79
|
my_mcp_server,
|
|
77
80
|
):
|
|
@@ -47,9 +47,12 @@ The generator creates a shared `agent-connection` package and modifies your agen
|
|
|
47
47
|
- packages/common/agent-connection
|
|
48
48
|
- src
|
|
49
49
|
- app
|
|
50
|
-
- \<target-agent-name>-client.ts High-level client for the connected A2A agent
|
|
50
|
+
- \<target-agent-name>-client-strands.ts High-level Strands client for the connected A2A agent
|
|
51
51
|
- core
|
|
52
|
-
- agentcore-
|
|
52
|
+
- agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
|
|
53
|
+
- agentcore-fetch.ts Framework-agnostic SigV4 / JWT / session-forwarding fetch
|
|
54
|
+
- agentcore-a2a-client-config.ts Framework-agnostic A2A client config (signed `clientFactory`)
|
|
55
|
+
- agentcore-a2a-client-strands.ts Strands A2A client wrapping the config
|
|
53
56
|
- index.ts Exports all clients
|
|
54
57
|
- project.json
|
|
55
58
|
- tsconfig.json
|
|
@@ -67,11 +70,11 @@ The generator transforms your agent's `agent.ts` to wrap the remote A2A agent as
|
|
|
67
70
|
|
|
68
71
|
```ts title="packages/example/src/my-agent/agent.ts" {2,5-11,14}
|
|
69
72
|
import { Agent, tool } from '@strands-agents/sdk';
|
|
70
|
-
import {
|
|
73
|
+
import { RemoteAgentClientStrands } from ':my-scope/agent-connection';
|
|
71
74
|
import { z } from 'zod';
|
|
72
75
|
|
|
73
76
|
export const getAgent = async (sessionId: string) => {
|
|
74
|
-
const remoteAgent = await
|
|
77
|
+
const remoteAgent = await RemoteAgentClientStrands.create(sessionId);
|
|
75
78
|
const remoteAgentTool = tool({
|
|
76
79
|
name: 'askRemoteAgent',
|
|
77
80
|
description: 'Delegate a question to the remote RemoteAgent A2A agent and return its reply.',
|
|
@@ -87,7 +90,7 @@ export const getAgent = async (sessionId: string) => {
|
|
|
87
90
|
|
|
88
91
|
The `sessionId` parameter is plumbed through from the caller, ensuring consistency for [Bedrock AgentCore Observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability.html).
|
|
89
92
|
|
|
90
|
-
Under the hood, `
|
|
93
|
+
Under the hood, `RemoteAgentClientStrands.create(sessionId)` returns a Strands `A2AAgent` configured with a SigV4-signing `clientFactory` when deployed to AWS, and a plain `http://localhost:<port>/` endpoint when `SERVE_LOCAL=true`. The signing and endpoint resolution live in the framework-agnostic `agentcore-a2a-client-config.ts`; only the thin `agentcore-a2a-client-strands.ts` depends on Strands.
|
|
91
94
|
|
|
92
95
|
## Infrastructure
|
|
93
96
|
|
|
@@ -44,16 +44,18 @@ The generator emits shared core client files into your `agent-connection` packag
|
|
|
44
44
|
- packages/common/agent-connection
|
|
45
45
|
- src
|
|
46
46
|
- core/
|
|
47
|
-
- agentcore-
|
|
47
|
+
- agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
|
|
48
|
+
- agentcore-gateway-mcp-transport.ts Framework-agnostic Gateway MCP transport
|
|
49
|
+
- agentcore-gateway-mcp-client-strands.ts Strands MCP client for the deployed Gateway
|
|
48
50
|
- app/
|
|
49
|
-
- \<gateway-kebab>-client.ts Per-Gateway client wrapper
|
|
51
|
+
- \<gateway-kebab>-client-strands.ts Per-Gateway Strands client wrapper
|
|
50
52
|
- index.ts Re-exports the Gateway client
|
|
51
53
|
|
|
52
54
|
</FileTree>
|
|
53
55
|
|
|
54
56
|
Additionally, the generator:
|
|
55
57
|
|
|
56
|
-
- Modifies your agent's `agent.ts` to import the Gateway client class, call `<Gateway>
|
|
58
|
+
- Modifies your agent's `agent.ts` to import the Gateway client class, call `<Gateway>ClientStrands.create()`, and register the returned client in the `tools` array
|
|
57
59
|
- Wires the agent's `<agent>-serve-local` target to depend on the Gateway's `<gateway>-serve-local` aggregator
|
|
58
60
|
- Installs the required SigV4 / MCP dependencies
|
|
59
61
|
|
|
@@ -63,10 +65,10 @@ The generator transforms your agent's `agent.ts` to use the Gateway client:
|
|
|
63
65
|
|
|
64
66
|
```ts title="packages/example/src/my-agent/agent.ts" {2,5,8}
|
|
65
67
|
import { Agent } from '@strands-agents/sdk';
|
|
66
|
-
import {
|
|
68
|
+
import { MyGatewayClientStrands } from ':my-scope/agent-connection';
|
|
67
69
|
|
|
68
70
|
export const getAgent = async () => {
|
|
69
|
-
const myGateway = await
|
|
71
|
+
const myGateway = await MyGatewayClientStrands.create();
|
|
70
72
|
return new Agent({
|
|
71
73
|
systemPrompt: '...',
|
|
72
74
|
tools: [myGateway],
|
|
@@ -47,9 +47,12 @@ The generator creates a shared `agent-connection` package and modifies your agen
|
|
|
47
47
|
- packages/common/agent-connection
|
|
48
48
|
- src
|
|
49
49
|
- app
|
|
50
|
-
- \<mcp-server-name>-client.ts High-level client for the connected MCP server
|
|
50
|
+
- \<mcp-server-name>-client-strands.ts High-level Strands client for the connected MCP server
|
|
51
51
|
- core
|
|
52
|
-
- agentcore-
|
|
52
|
+
- agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
|
|
53
|
+
- agentcore-fetch.ts Framework-agnostic SigV4 / JWT / session-forwarding fetch
|
|
54
|
+
- agentcore-mcp-transport.ts Framework-agnostic MCP transport
|
|
55
|
+
- agentcore-mcp-client-strands.ts Strands MCP client wrapping the transport
|
|
53
56
|
- index.ts Exports all clients
|
|
54
57
|
- project.json
|
|
55
58
|
- tsconfig.json
|
|
@@ -67,10 +70,10 @@ The generator transforms your agent's `agent.ts` to use the MCP server's tools:
|
|
|
67
70
|
|
|
68
71
|
```ts title="packages/example/src/my-agent/agent.ts" {2,5,8}
|
|
69
72
|
import { Agent, tool } from '@strands-agents/sdk';
|
|
70
|
-
import {
|
|
73
|
+
import { MyMcpServerClientStrands } from ':my-scope/agent-connection';
|
|
71
74
|
|
|
72
75
|
export const getAgent = async (sessionId: string) => {
|
|
73
|
-
const myMcpServerClient = await
|
|
76
|
+
const myMcpServerClient = await MyMcpServerClientStrands.create(sessionId);
|
|
74
77
|
return new Agent({
|
|
75
78
|
systemPrompt: '...',
|
|
76
79
|
tools: [myMcpServerClient],
|
|
@@ -181,6 +181,13 @@ The Connection generator supports the following connections:
|
|
|
181
181
|
source="agentcore"
|
|
182
182
|
target="mcp"
|
|
183
183
|
/>
|
|
184
|
+
<ConnectionCard
|
|
185
|
+
title="AgentCore Gateway to AgentCore Gateway"
|
|
186
|
+
description="Aggregate an AgentCore Gateway behind another AgentCore Gateway"
|
|
187
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-gateway`}
|
|
188
|
+
source="agentcore"
|
|
189
|
+
target="agentcore"
|
|
190
|
+
/>
|
|
184
191
|
<ConnectionCard
|
|
185
192
|
title="TypeScript Agent to AgentCore Gateway"
|
|
186
193
|
description="Connect a TypeScript Agent to an AgentCore Gateway"
|
package/docs/guides/trpc.mdx
CHANGED
|
@@ -138,7 +138,7 @@ The example `echo` procedure is generated for you in `src/procedures/echo.ts`:
|
|
|
138
138
|
export const echo = publicProcedure
|
|
139
139
|
.input(EchoInputSchema)
|
|
140
140
|
.output(EchoOutputSchema)
|
|
141
|
-
.query((opts) => ({
|
|
141
|
+
.query((opts) => ({ message: opts.input.message }));
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
To break down the above:
|
package/generators.json
CHANGED
|
@@ -16,6 +16,13 @@
|
|
|
16
16
|
"metric": "g49",
|
|
17
17
|
"hidden": true
|
|
18
18
|
},
|
|
19
|
+
"agentcore-gateway#gateway-connection": {
|
|
20
|
+
"factory": "./src/agentcore-gateway/gateway-connection/generator",
|
|
21
|
+
"schema": "./src/agentcore-gateway/gateway-connection/schema.json",
|
|
22
|
+
"description": "Connect an AgentCore Gateway to another AgentCore Gateway",
|
|
23
|
+
"metric": "g52",
|
|
24
|
+
"hidden": true
|
|
25
|
+
},
|
|
19
26
|
"connection": {
|
|
20
27
|
"factory": "./src/connection/generator",
|
|
21
28
|
"schema": "./src/connection/schema.json",
|
|
@@ -39,7 +46,8 @@
|
|
|
39
46
|
"connection/ts-agent-rdb",
|
|
40
47
|
"connection/ts-agent-gateway",
|
|
41
48
|
"connection/py-agent-gateway",
|
|
42
|
-
"connection/agentcore-gateway-mcp"
|
|
49
|
+
"connection/agentcore-gateway-mcp",
|
|
50
|
+
"connection/agentcore-gateway-gateway"
|
|
43
51
|
]
|
|
44
52
|
},
|
|
45
53
|
"license": {
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "agentcore-gateway#gateway-connection",
|
|
4
|
+
"title": "agentcore-gateway#gateway-connection",
|
|
5
|
+
"description": "Connect an AgentCore Gateway to another AgentCore Gateway",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"sourceProject": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The gateway project to add the target gateway to"
|
|
11
|
+
},
|
|
12
|
+
"targetProject": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The gateway project to register as a target"
|
|
15
|
+
},
|
|
16
|
+
"sourceComponent": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The gateway component in the source project"
|
|
19
|
+
},
|
|
20
|
+
"targetComponent": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The gateway component in the target project"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["sourceProject", "targetProject"]
|
|
26
|
+
}
|