@aws/nx-plugin-mcp 0.120.0 → 0.121.0
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 +23 -35
- package/docs/guides/astro-docs.mdx +142 -0
- package/docs/guides/connection/py-agent-a2a.mdx +105 -0
- package/docs/guides/connection/py-agent-mcp.mdx +147 -0
- package/docs/guides/connection/react-agui.mdx +240 -0
- package/docs/guides/connection/react-fastapi.mdx +1476 -0
- package/docs/guides/connection/react-py-agent.mdx +198 -0
- package/docs/guides/connection/react-smithy.mdx +1355 -0
- package/docs/guides/connection/react-trpc.mdx +447 -0
- package/docs/guides/connection/react-ts-agent.mdx +198 -0
- package/docs/guides/connection/smithy-rdb.mdx +161 -0
- package/docs/guides/connection/trpc-rdb.mdx +127 -0
- package/docs/guides/connection/ts-agent-a2a.mdx +106 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +144 -0
- package/docs/guides/connection/ts-agent-rdb.mdx +141 -0
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +135 -0
- package/docs/guides/connection.mdx +126 -0
- package/docs/guides/docker-bundling.mdx +403 -0
- package/docs/guides/fastapi.mdx +509 -0
- package/docs/guides/license.mdx +293 -0
- package/docs/guides/nx-generator.mdx +588 -0
- package/docs/guides/py-agent.mdx +483 -0
- package/docs/guides/py-mcp-server.mdx +161 -0
- package/docs/guides/python-lambda-function.mdx +207 -0
- package/docs/guides/python-project.mdx +228 -0
- package/docs/guides/react-website-auth.mdx +216 -0
- package/docs/guides/react-website.mdx +421 -0
- package/docs/guides/runtime-config.mdx +312 -0
- package/docs/guides/terraform-project.mdx +317 -0
- package/docs/guides/trpc.mdx +816 -0
- package/docs/guides/ts-agent.mdx +436 -0
- package/docs/guides/ts-lambda-function.mdx +218 -0
- package/docs/guides/ts-mcp-server.mdx +169 -0
- package/docs/guides/ts-nx-plugin.mdx +159 -0
- package/docs/guides/ts-rdb.mdx +759 -0
- package/docs/guides/ts-smithy-api.mdx +661 -0
- package/docs/guides/typescript-infrastructure.mdx +408 -0
- package/docs/guides/typescript-project.mdx +312 -0
- package/docs/guides/workspace.mdx +181 -0
- package/docs/snippets/agent/architecture.mdx +72 -0
- package/docs/snippets/agent/bedrock-deployment.mdx +172 -0
- package/docs/snippets/agent/runtime-arn.mdx +64 -0
- package/docs/snippets/api/api-architecture.mdx +93 -0
- package/docs/snippets/api/api-choice-note.mdx +6 -0
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +25 -0
- package/docs/snippets/api/cors-configuration-terraform-note.mdx +28 -0
- package/docs/snippets/api/shared-constructs.mdx +38 -0
- package/docs/snippets/api/type-safe-api-integrations.mdx +643 -0
- package/docs/snippets/api/waf-configuration.mdx +37 -0
- package/docs/snippets/connection/a2a-infrastructure.mdx +63 -0
- package/docs/snippets/connection/lambda-rdb-ssl-requirements.mdx +40 -0
- package/docs/snippets/connection/mcp-server-rdb-ssl-requirements.mdx +35 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +72 -0
- package/docs/snippets/connection/react-agent-infrastructure.mdx +61 -0
- package/docs/snippets/connection/strands-agent-rdb-ssl-requirements.mdx +35 -0
- package/docs/snippets/lambda-function/architecture.mdx +36 -0
- package/docs/snippets/lambda-function/deploying-your-function.mdx +118 -0
- package/docs/snippets/mcp/architecture.mdx +58 -0
- package/docs/snippets/mcp/assistant-docs.mdx +10 -0
- package/docs/snippets/mcp/bedrock-deployment.mdx +167 -0
- package/docs/snippets/mcp/config.mdx +13 -0
- package/docs/snippets/mcp/configuration-py.mdx +42 -0
- package/docs/snippets/mcp/configuration-ts.mdx +53 -0
- package/docs/snippets/mcp/observability.mdx +8 -0
- package/docs/snippets/mcp/shared-constructs.mdx +32 -0
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +602 -0
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +915 -0
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +161 -0
- package/docs/snippets/pdk-migration/example/04-deploy.mdx +229 -0
- package/docs/snippets/pdk-migration/faq/aws-arch.mdx +17 -0
- package/docs/snippets/pdk-migration/faq/cdk-graph.mdx +29 -0
- package/docs/snippets/pdk-migration/faq/infrastructure-python-java.mdx +19 -0
- package/docs/snippets/pdk-migration/faq/pdk-nag.mdx +15 -0
- package/docs/snippets/pdk-migration/faq/pipeline.mdx +15 -0
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +310 -0
- package/docs/snippets/pdk-migration/faq/use-of-projen.mdx +15 -0
- package/docs/snippets/prerequisites.mdx +20 -0
- package/docs/snippets/required-prerequisites.mdx +12 -0
- package/docs/snippets/shared-constructs.mdx +40 -0
- package/docs/snippets/tools/acurl.mdx +73 -0
- package/docs/snippets/ts-bundle.mdx +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: A2A Connection Infrastructure
|
|
3
|
+
---
|
|
4
|
+
import Link from '@components/link.astro';
|
|
5
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
6
|
+
|
|
7
|
+
After running the connection generator, you need to grant the host agent permission to invoke the remote A2A agent.
|
|
8
|
+
|
|
9
|
+
<Infrastructure>
|
|
10
|
+
<Fragment slot="cdk">
|
|
11
|
+
```ts title="packages/infra/src/stacks/application-stack.ts" {5}
|
|
12
|
+
const remoteAgent = new RemoteAgent(this, 'RemoteAgent');
|
|
13
|
+
const myAgent = new MyAgent(this, 'MyAgent');
|
|
14
|
+
|
|
15
|
+
// Grant the host agent permission to invoke the remote A2A agent
|
|
16
|
+
remoteAgent.grantInvokeAccess(myAgent);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`grantInvokeAccess` on an A2A agent wires up both `bedrock-agentcore:InvokeAgentRuntime` and `bedrock-agentcore:GetAgentCard` — the A2A client needs both to fetch the agent card and send messages.
|
|
20
|
+
|
|
21
|
+
The remote agent's AgentCore runtime ARN is automatically registered in the `agentcore` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated CDK construct, so the host agent can discover it at runtime.
|
|
22
|
+
</Fragment>
|
|
23
|
+
<Fragment slot="terraform">
|
|
24
|
+
```hcl title="packages/infra/src/main.tf" {3-6, 11-12, 16-17}
|
|
25
|
+
module "remote_agent" {
|
|
26
|
+
source = "../../common/terraform/src/app/agents/remote-agent"
|
|
27
|
+
|
|
28
|
+
appconfig_application_id = module.runtime_config_appconfig.application_id
|
|
29
|
+
appconfig_application_arn = module.runtime_config_appconfig.application_arn
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module "my_agent" {
|
|
33
|
+
source = "../../common/terraform/src/app/agents/my-agent"
|
|
34
|
+
|
|
35
|
+
appconfig_application_id = module.runtime_config_appconfig.application_id
|
|
36
|
+
appconfig_application_arn = module.runtime_config_appconfig.application_arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# Grant the host agent permission to invoke the remote A2A agent
|
|
40
|
+
resource "aws_iam_policy" "agent_invoke_a2a" {
|
|
41
|
+
name = "AgentInvokeA2aPolicy"
|
|
42
|
+
policy = jsonencode({
|
|
43
|
+
Version = "2012-10-17"
|
|
44
|
+
Statement = [{
|
|
45
|
+
Effect = "Allow"
|
|
46
|
+
Action = [
|
|
47
|
+
"bedrock-agentcore:InvokeAgentRuntime",
|
|
48
|
+
"bedrock-agentcore:GetAgentCard",
|
|
49
|
+
]
|
|
50
|
+
Resource = module.remote_agent.agent_core_runtime_arn
|
|
51
|
+
}]
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
resource "aws_iam_role_policy_attachment" "agent_invoke_a2a" {
|
|
56
|
+
role = module.my_agent.agent_core_runtime_role_arn
|
|
57
|
+
policy_arn = aws_iam_policy.agent_invoke_a2a.arn
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The remote agent's AgentCore runtime ARN is automatically registered in the `agentcore` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated Terraform module, so the host agent can discover it at runtime.
|
|
62
|
+
</Fragment>
|
|
63
|
+
</Infrastructure>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SSL Requirements when Connecting without RDS Proxy
|
|
3
|
+
---
|
|
4
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
5
|
+
|
|
6
|
+
For direct Aurora cluster connections from Node.js 20 or later Lambda runtimes, load the Amazon RDS CA bundle by setting `NODE_EXTRA_CA_CERTS`:
|
|
7
|
+
|
|
8
|
+
<Infrastructure>
|
|
9
|
+
<Fragment slot="cdk">
|
|
10
|
+
|
|
11
|
+
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
12
|
+
const api = new Api(this, 'Api', {
|
|
13
|
+
integrations: Api.defaultIntegrations(this)
|
|
14
|
+
.withDefaultOptions({
|
|
15
|
+
environment: {
|
|
16
|
+
NODE_EXTRA_CA_CERTS: '/var/runtime/ca-cert.pem',
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
.build(),
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
</Fragment>
|
|
24
|
+
<Fragment slot="terraform">
|
|
25
|
+
|
|
26
|
+
```hcl title="packages/infra/src/main.tf"
|
|
27
|
+
module "api" {
|
|
28
|
+
source = "..."
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
environment_variables = {
|
|
32
|
+
NODE_EXTRA_CA_CERTS = "/var/runtime/ca-cert.pem"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</Fragment>
|
|
38
|
+
</Infrastructure>
|
|
39
|
+
|
|
40
|
+
For more details, see the AWS Lambda [SSL/TLS requirements for Amazon RDS connections](https://docs.aws.amazon.com/lambda/latest/dg/services-rds.html#services-rds-tls) and the Amazon RDS Proxy [TLS documentation](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.howitworks.html#rds-proxy-security.tls). When using RDS Proxy, you do not need to configure the RDS CA bundle in your Lambda function.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SSL Requirements when Connecting without RDS Proxy
|
|
3
|
+
---
|
|
4
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
5
|
+
|
|
6
|
+
The connection generator updates the Dockerfile to install the Amazon RDS CA bundle at `/usr/local/share/ca-certificates/rds-bundle.crt`. Set `NODE_EXTRA_CA_CERTS` to that path so Node.js trusts the certificate when connecting without RDS Proxy:
|
|
7
|
+
|
|
8
|
+
<Infrastructure>
|
|
9
|
+
<Fragment slot="cdk">
|
|
10
|
+
|
|
11
|
+
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
12
|
+
new MyMcpServer(this, 'MyMcpServer', {
|
|
13
|
+
...
|
|
14
|
+
environmentVariables: {
|
|
15
|
+
NODE_EXTRA_CA_CERTS: '/usr/local/share/ca-certificates/rds-bundle.crt',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
</Fragment>
|
|
21
|
+
<Fragment slot="terraform">
|
|
22
|
+
|
|
23
|
+
```hcl title="packages/infra/src/main.tf"
|
|
24
|
+
module "my_mcp_server" {
|
|
25
|
+
...
|
|
26
|
+
environment_variables = {
|
|
27
|
+
NODE_EXTRA_CA_CERTS = "/usr/local/share/ca-certificates/rds-bundle.crt"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
</Fragment>
|
|
33
|
+
</Infrastructure>
|
|
34
|
+
|
|
35
|
+
For more details, see the [Amazon RDS SSL/TLS documentation](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html). When using RDS Proxy, you do not need to configure `NODE_EXTRA_CA_CERTS`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: RDB API Infrastructure
|
|
3
|
+
---
|
|
4
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
5
|
+
|
|
6
|
+
To allow your API to connect to the database at runtime, the API Lambda functions must be deployed into the same VPC as the database and granted network and IAM access.
|
|
7
|
+
|
|
8
|
+
<Infrastructure>
|
|
9
|
+
<Fragment slot="cdk">
|
|
10
|
+
|
|
11
|
+
In your application stack, deploy the API into the same VPC as the database, then call `allowDefaultPortFrom` and `grantConnect` to open the network path and grant IAM `rds-db:connect` permission to each Lambda handler:
|
|
12
|
+
|
|
13
|
+
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
14
|
+
import { MyDatabase } from ':my-scope/common-constructs';
|
|
15
|
+
|
|
16
|
+
const db = new MyDatabase(this, 'Db', { vpc, ... });
|
|
17
|
+
|
|
18
|
+
const api = new MyApi(this, 'Api', {
|
|
19
|
+
integrations: MyApi.defaultIntegrations(this)
|
|
20
|
+
.withDefaultOptions({
|
|
21
|
+
vpc,
|
|
22
|
+
vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
|
|
23
|
+
})
|
|
24
|
+
.build(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Object.entries(api.integrations).forEach(([operation, integration]) => {
|
|
28
|
+
db.allowDefaultPortFrom(integration.handler, `Allow ${operation} to connect to the database`);
|
|
29
|
+
db.grantConnect(integration.handler);
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Deploy the API Lambda functions into a **private subnet with egress**, not a private isolated subnet. At runtime, `getPrisma()` retrieves database connection details from AWS AppConfig, which is a public AWS service endpoint that requires outbound internet access.
|
|
34
|
+
|
|
35
|
+
:::note
|
|
36
|
+
This example grants every handler in your API access, but if only some handlers need access it's better to configure individually.
|
|
37
|
+
:::
|
|
38
|
+
|
|
39
|
+
</Fragment>
|
|
40
|
+
<Fragment slot="terraform">
|
|
41
|
+
|
|
42
|
+
Pass the database module outputs into your API module so it can reach the database and read its runtime configuration:
|
|
43
|
+
|
|
44
|
+
```hcl title="packages/infra/src/main.tf"
|
|
45
|
+
module "my_database" {
|
|
46
|
+
source = "../../common/terraform/src/app/dbs/my-database"
|
|
47
|
+
vpc_id = module.vpc.vpc_id
|
|
48
|
+
database_subnet_ids = module.vpc.private_isolated_subnet_ids
|
|
49
|
+
lambda_subnet_ids = module.vpc.private_subnet_ids
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module "api" {
|
|
53
|
+
source = "..."
|
|
54
|
+
vpc_id = module.vpc.vpc_id
|
|
55
|
+
private_subnet_ids = module.vpc.private_subnet_ids
|
|
56
|
+
|
|
57
|
+
appconfig_application_id = module.my_database.appconfig_application_id
|
|
58
|
+
database_cluster_resource_id = module.my_database.cluster_resource_id
|
|
59
|
+
database_runtime_user = module.my_database.database_runtime_user
|
|
60
|
+
database_security_group_id = module.my_database.security_group_id
|
|
61
|
+
database_port = module.my_database.cluster_port
|
|
62
|
+
|
|
63
|
+
environment_variables = {
|
|
64
|
+
RUNTIME_CONFIG_APP_ID = module.my_database.appconfig_application_id
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Deploy the API Lambda functions into **private subnets with egress**, not private isolated subnets. Ensure the API Lambda role has `rds-db:connect` permission and that its security group can reach the database security group on the database port.
|
|
70
|
+
|
|
71
|
+
</Fragment>
|
|
72
|
+
</Infrastructure>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: React to Agent Connection Infrastructure
|
|
3
|
+
---
|
|
4
|
+
import Link from '@components/link.astro';
|
|
5
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
6
|
+
|
|
7
|
+
If your agent uses IAM auth, the Cognito Identity Pool's authenticated role must be granted permission to invoke the agent.
|
|
8
|
+
|
|
9
|
+
<Infrastructure>
|
|
10
|
+
<Fragment slot="cdk">
|
|
11
|
+
```ts title="packages/infra/src/stacks/application-stack.ts" {5}
|
|
12
|
+
const identity = new UserIdentity(this, 'Identity');
|
|
13
|
+
const myAgent = new MyAgent(this, 'MyAgent');
|
|
14
|
+
|
|
15
|
+
// Grant the authenticated Cognito role permission to invoke the agent
|
|
16
|
+
myAgent.grantInvokeAccess(identity.identityPool.authenticatedRole);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`grantInvokeAccess` wires up all AgentCore invoke actions (`InvokeAgentRuntime`, `InvokeAgentRuntimeWithWebSocketStream`) on the agent's runtime ARN.
|
|
20
|
+
</Fragment>
|
|
21
|
+
<Fragment slot="terraform">
|
|
22
|
+
```hcl title="packages/infra/src/main.tf"
|
|
23
|
+
module "identity" {
|
|
24
|
+
source = "../../common/terraform/src/core/user-identity"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module "my_agent" {
|
|
28
|
+
source = "../../common/terraform/src/app/agents/my-agent"
|
|
29
|
+
|
|
30
|
+
appconfig_application_id = module.runtime_config_appconfig.application_id
|
|
31
|
+
appconfig_application_arn = module.runtime_config_appconfig.application_arn
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Grant the authenticated Cognito role permission to invoke the agent
|
|
35
|
+
resource "aws_iam_policy" "invoke_my_agent" {
|
|
36
|
+
name = "InvokeMyAgentPolicy"
|
|
37
|
+
policy = jsonencode({
|
|
38
|
+
Version = "2012-10-17"
|
|
39
|
+
Statement = [{
|
|
40
|
+
Effect = "Allow"
|
|
41
|
+
Action = [
|
|
42
|
+
"bedrock-agentcore:InvokeAgentRuntime",
|
|
43
|
+
"bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream",
|
|
44
|
+
]
|
|
45
|
+
Resource = [
|
|
46
|
+
module.my_agent.agent_core_runtime_arn,
|
|
47
|
+
"${module.my_agent.agent_core_runtime_arn}/*",
|
|
48
|
+
]
|
|
49
|
+
}]
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
resource "aws_iam_role_policy_attachment" "invoke_my_agent" {
|
|
54
|
+
role = module.identity.authenticated_role_name
|
|
55
|
+
policy_arn = aws_iam_policy.invoke_my_agent.arn
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
</Fragment>
|
|
59
|
+
</Infrastructure>
|
|
60
|
+
|
|
61
|
+
If your agent uses Cognito auth, you do not need to define any additional infrastructure to connect your website to your agent.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SSL Requirements when Connecting without RDS Proxy
|
|
3
|
+
---
|
|
4
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
5
|
+
|
|
6
|
+
The connection generator updates the Dockerfile to install the Amazon RDS CA bundle at `/usr/local/share/ca-certificates/rds-bundle.crt`. Set `NODE_EXTRA_CA_CERTS` to that path so Node.js trusts the certificate when connecting without RDS Proxy:
|
|
7
|
+
|
|
8
|
+
<Infrastructure>
|
|
9
|
+
<Fragment slot="cdk">
|
|
10
|
+
|
|
11
|
+
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
12
|
+
new MyAgent(this, 'MyAgent', {
|
|
13
|
+
...
|
|
14
|
+
environmentVariables: {
|
|
15
|
+
NODE_EXTRA_CA_CERTS: '/usr/local/share/ca-certificates/rds-bundle.crt',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
</Fragment>
|
|
21
|
+
<Fragment slot="terraform">
|
|
22
|
+
|
|
23
|
+
```hcl title="packages/infra/src/main.tf"
|
|
24
|
+
module "my_agent" {
|
|
25
|
+
...
|
|
26
|
+
environment_variables = {
|
|
27
|
+
NODE_EXTRA_CA_CERTS = "/usr/local/share/ca-certificates/rds-bundle.crt"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
</Fragment>
|
|
33
|
+
</Infrastructure>
|
|
34
|
+
|
|
35
|
+
For more details, see the [Amazon RDS SSL/TLS documentation](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html). When using RDS Proxy, you do not need to configure `NODE_EXTRA_CA_CERTS`.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Lambda Function Architecture
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The deployed function has the following architecture:
|
|
6
|
+
|
|
7
|
+
```d2 inline=true
|
|
8
|
+
direction: right
|
|
9
|
+
|
|
10
|
+
source: Event Source\n(SNS, SQS, ...) {
|
|
11
|
+
shape: rectangle
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
lambda: Lambda {
|
|
15
|
+
shape: image
|
|
16
|
+
icon: /nx-plugin-for-aws/icons/aws/lambda.svg
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
cw: CloudWatch\n(Logs, Metrics) {
|
|
20
|
+
shape: image
|
|
21
|
+
icon: /nx-plugin-for-aws/icons/aws/cloudwatch.svg
|
|
22
|
+
near: top-right
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
xray: X-Ray\n(Traces) {
|
|
26
|
+
shape: image
|
|
27
|
+
icon: /nx-plugin-for-aws/icons/aws/xray.svg
|
|
28
|
+
near: bottom-right
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
source -> lambda
|
|
32
|
+
lambda -> cw
|
|
33
|
+
lambda -> xray
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The generator vends the function itself; you wire the event source up in your stack to invoke it (for example, an API Gateway integration, an EventBridge rule, an S3 notification or an SQS event source mapping).
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Deploying your Function
|
|
3
|
+
---
|
|
4
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
5
|
+
|
|
6
|
+
This generator creates CDK or Terraform infrastructure as code based on your selected `iacProvider`. You can use this to deploy your function.
|
|
7
|
+
|
|
8
|
+
<Infrastructure>
|
|
9
|
+
<Fragment slot="cdk">
|
|
10
|
+
This generator creates a CDK construct for deploying your function in the `common/constructs` folder. You can use this in a CDK application:
|
|
11
|
+
|
|
12
|
+
```typescript {1, 6}
|
|
13
|
+
import { MyProjectMyFunction } from ':my-scope/common-constructs';
|
|
14
|
+
|
|
15
|
+
export class ExampleStack extends Stack {
|
|
16
|
+
constructor(scope: Construct, id: string) {
|
|
17
|
+
// Add the function to your stack
|
|
18
|
+
const fn = new MyProjectMyFunction(this, 'MyFunction');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This sets up:
|
|
24
|
+
|
|
25
|
+
1. AWS Lambda function
|
|
26
|
+
2. CloudWatch log group
|
|
27
|
+
3. X-Ray tracing configuration
|
|
28
|
+
4. CloudWatch metrics namespace
|
|
29
|
+
|
|
30
|
+
This function can then be used as a target for any lambda [event source](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parser/):
|
|
31
|
+
|
|
32
|
+
:::note[Event Source Matching]
|
|
33
|
+
Ensure the event source matches the selected `eventSource` option to ensure the event is properly handled within your handler function.
|
|
34
|
+
:::
|
|
35
|
+
|
|
36
|
+
The example below demonstrates the CDK code for invoking your lambda function on a schedule using EventBridge:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { Rule, Schedule } from 'aws-cdk-lib/aws-events';
|
|
40
|
+
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
|
|
41
|
+
import { MyProjectMyFunction } from ':my-scope/common-constructs';
|
|
42
|
+
|
|
43
|
+
export class ExampleStack extends Stack {
|
|
44
|
+
constructor(scope: Construct, id: string) {
|
|
45
|
+
// Add the function to your stack
|
|
46
|
+
const fn = new MyProjectMyFunction(this, 'MyFunction');
|
|
47
|
+
|
|
48
|
+
// Add the function to an EventBridge scheduled rule
|
|
49
|
+
const eventRule = new Rule(this, 'MyFunctionScheduleRule', {
|
|
50
|
+
schedule: Schedule.cron({ minute: '15' }),
|
|
51
|
+
targets: [new LambdaFunction(fn)],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
</Fragment>
|
|
57
|
+
<Fragment slot="terraform">
|
|
58
|
+
This generator creates a Terraform module for deploying your function in the `common/terraform` folder. Instantiate the shared `core/asset-bucket` module once per deployment and pass its `bucket_name` into the `asset_bucket_name` input:
|
|
59
|
+
|
|
60
|
+
```hcl
|
|
61
|
+
module "asset_bucket" {
|
|
62
|
+
source = "../../common/terraform/src/core/asset-bucket"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module "my_project_my_function" {
|
|
66
|
+
source = "../../common/terraform/src/app/lambda-functions/my-project-my-function"
|
|
67
|
+
|
|
68
|
+
asset_bucket_name = module.asset_bucket.bucket_name
|
|
69
|
+
|
|
70
|
+
env = {
|
|
71
|
+
SOME_VARIABLE = "some value"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
additional_iam_policy_statements = [
|
|
75
|
+
# Add any additional permissions your function needs
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This sets up:
|
|
81
|
+
|
|
82
|
+
1. AWS Lambda function
|
|
83
|
+
2. CloudWatch log group
|
|
84
|
+
3. X-Ray tracing configuration
|
|
85
|
+
4. CloudWatch metrics namespace
|
|
86
|
+
|
|
87
|
+
This function can then be used as a target for any lambda event source. The example below demonstrates the Terraform code for invoking your lambda function on a schedule using EventBridge:
|
|
88
|
+
|
|
89
|
+
```hcl
|
|
90
|
+
# EventBridge rule for scheduled execution
|
|
91
|
+
resource "aws_cloudwatch_event_rule" "my_function_schedule" {
|
|
92
|
+
name = "my-function-schedule"
|
|
93
|
+
description = "Trigger my function every 15 minutes"
|
|
94
|
+
schedule_expression = "cron(15 * * * ? *)"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# EventBridge target
|
|
98
|
+
resource "aws_cloudwatch_event_target" "lambda_target" {
|
|
99
|
+
rule = aws_cloudwatch_event_rule.my_function_schedule.name
|
|
100
|
+
target_id = "MyFunctionTarget"
|
|
101
|
+
arn = module.my_project_my_function.function_arn
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# Permission for EventBridge to invoke the Lambda function
|
|
105
|
+
resource "aws_lambda_permission" "allow_eventbridge" {
|
|
106
|
+
statement_id = "AllowExecutionFromEventBridge"
|
|
107
|
+
action = "lambda:InvokeFunction"
|
|
108
|
+
function_name = module.my_project_my_function.function_name
|
|
109
|
+
principal = "events.amazonaws.com"
|
|
110
|
+
source_arn = aws_cloudwatch_event_rule.my_function_schedule.arn
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
:::note[Event Source Matching]
|
|
115
|
+
Ensure the event source matches the selected `eventSource` option to ensure the event is properly handled within your handler function.
|
|
116
|
+
:::
|
|
117
|
+
</Fragment>
|
|
118
|
+
</Infrastructure>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MCP Server Architecture
|
|
3
|
+
---
|
|
4
|
+
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
5
|
+
|
|
6
|
+
<Tabs syncKey="computeType">
|
|
7
|
+
<TabItem label="Bedrock AgentCore Runtime" _filter={{ computeType: 'BedrockAgentCoreRuntime' }}>
|
|
8
|
+
|
|
9
|
+
When deployed to [Bedrock AgentCore Runtime](https://aws.amazon.com/bedrock/agentcore/), the MCP server is built into a container image, pushed to Amazon ECR, and run in AgentCore Runtime. AI assistants invoke the AgentCore Runtime data plane endpoint, which forwards `tools/*` and `resources/*` calls to your server over the [streamable HTTP transport](https://modelcontextprotocol.io/specification/draft/basic/transports#streamable-http).
|
|
10
|
+
|
|
11
|
+
```d2 inline=true
|
|
12
|
+
direction: right
|
|
13
|
+
|
|
14
|
+
assistant: AI Assistant {
|
|
15
|
+
shape: image
|
|
16
|
+
icon: /nx-plugin-for-aws/icons/aws/client.svg
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
ecr: ECR {
|
|
20
|
+
shape: image
|
|
21
|
+
icon: /nx-plugin-for-aws/icons/aws/ecr.svg
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
agentcore: MCP Server\n(AgentCore Runtime) {
|
|
25
|
+
shape: image
|
|
26
|
+
icon: /nx-plugin-for-aws/icons/aws/bedrock-agentcore.svg
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
cw: CloudWatch\n(Logs, Metrics) {
|
|
30
|
+
shape: image
|
|
31
|
+
icon: /nx-plugin-for-aws/icons/aws/cloudwatch.svg
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
assistant -> agentcore: Streamable\nHTTP
|
|
35
|
+
ecr -> agentcore: Container\nimage
|
|
36
|
+
agentcore -> cw
|
|
37
|
+
```
|
|
38
|
+
</TabItem>
|
|
39
|
+
<TabItem label="None (local only)" _filter={{ computeType: 'None' }}>
|
|
40
|
+
|
|
41
|
+
With `computeType: None`, no AWS infrastructure is generated. The MCP server is configured for local STDIO and HTTP transports only, and is consumed by AI assistants running on the same machine.
|
|
42
|
+
|
|
43
|
+
```d2 inline=true
|
|
44
|
+
direction: right
|
|
45
|
+
|
|
46
|
+
assistant: AI Assistant {
|
|
47
|
+
shape: image
|
|
48
|
+
icon: /nx-plugin-for-aws/icons/aws/client.svg
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
server: MCP Server\n(local process) {
|
|
52
|
+
shape: rectangle
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
assistant -> server: STDIO\nor\nStreamable HTTP
|
|
56
|
+
```
|
|
57
|
+
</TabItem>
|
|
58
|
+
</Tabs>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MCP AI Assistant docs
|
|
3
|
+
---
|
|
4
|
+
- [Kiro](https://kiro.dev/docs/mcp/configuration/)
|
|
5
|
+
- [Kiro CLI](https://kiro.dev/docs/cli/mcp/)
|
|
6
|
+
- [Claude Code](https://code.claude.com/docs/en/mcp)
|
|
7
|
+
- [Cursor](https://cursor.com/docs/mcp)
|
|
8
|
+
- [Codex](https://github.com/openai/codex)
|
|
9
|
+
- [Cline](https://docs.cline.bot/mcp/mcp-overview)
|
|
10
|
+
- [Roo Code](https://docs.roocode.com/features/mcp/using-mcp-in-roo)
|