@aws/nx-plugin-mcp 1.0.0-rc.45 → 1.0.0-rc.47
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 +63 -47
- package/docs/get_started/existing-project.mdx +4 -0
- package/docs/get_started/quick-start.mdx +1 -1
- package/docs/get_started/tutorials/contribute-generator.mdx +1 -1
- package/docs/get_started/tutorials/dungeon-game/1.mdx +2 -2
- package/docs/get_started/tutorials/dungeon-game/2.mdx +3 -3
- package/docs/guides/agentcore-gateway.mdx +1 -1
- package/docs/guides/connection/py-agent-dynamodb.mdx +1 -1
- package/docs/guides/connection/py-agent-rdb.mdx +1 -1
- package/docs/guides/connection/py-fast-api-dynamodb.mdx +1 -1
- package/docs/guides/connection/py-fast-api-rdb.mdx +2 -2
- package/docs/guides/connection/py-mcp-server-dynamodb.mdx +1 -1
- package/docs/guides/connection/py-mcp-server-rdb.mdx +1 -1
- package/docs/guides/connection/smithy-dynamodb.mdx +1 -1
- package/docs/guides/connection/smithy-rdb.mdx +3 -3
- package/docs/guides/connection/trpc-dynamodb.mdx +1 -1
- package/docs/guides/connection/ts-agent-a2a.mdx +1 -1
- package/docs/guides/connection/ts-agent-dynamodb.mdx +2 -2
- package/docs/guides/connection/ts-agent-gateway.mdx +1 -1
- package/docs/guides/connection/ts-agent-mcp.mdx +1 -1
- package/docs/guides/connection/ts-agent-rdb.mdx +4 -4
- package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +2 -2
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +2 -2
- package/docs/guides/docker-bundling.mdx +2 -2
- package/docs/guides/fastapi.mdx +2 -2
- package/docs/guides/react-website-auth.mdx +3 -3
- package/docs/guides/react-website.mdx +4 -3
- package/docs/guides/runtime-config.mdx +1 -1
- package/docs/guides/trpc.mdx +4 -3
- package/docs/guides/ts-dcr-proxy.mdx +1 -1
- package/docs/guides/ts-dynamodb.mdx +2 -1
- package/docs/guides/ts-mcp-server.mdx +44 -27
- package/docs/guides/ts-nx-plugin.mdx +2 -2
- package/docs/guides/ts-rdb.mdx +3 -2
- package/docs/guides/ts-smithy-api.mdx +3 -2
- package/docs/guides/typescript-infrastructure.mdx +10 -8
- package/docs/guides/typescript-project.mdx +133 -26
- package/docs/guides/workspace.mdx +6 -1
- package/docs/snippets/agent/bedrock-deployment.mdx +4 -4
- package/docs/snippets/agent/runtime-arn.mdx +1 -1
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
- package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +1 -1
- package/docs/snippets/dynamodb/deploying-table.mdx +5 -5
- package/docs/snippets/lambda-function/deploying-your-function.mdx +2 -2
- package/docs/snippets/mcp/bedrock-deployment.mdx +4 -4
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +1 -1
- package/docs/snippets/rdb/cluster-instances.mdx +1 -1
- package/docs/snippets/rdb/deletion-protection.mdx +1 -1
- package/docs/snippets/rdb/deploying.mdx +1 -1
- package/docs/snippets/rdb/encryption-key-rotation.mdx +1 -1
- package/docs/snippets/rdb/engine-version.mdx +2 -2
- package/docs/snippets/rdb/performance-insights.mdx +1 -1
- package/docs/snippets/rdb/rds-proxy.mdx +1 -1
- package/docs/snippets/rdb/removal-policy.mdx +2 -2
- package/docs/snippets/rdb/serverless-capacity.mdx +1 -1
- package/generators.json +9 -9
- package/package.json +1 -1
- package/src/preset/schema.json +5 -0
|
@@ -53,7 +53,7 @@ Additionally, the agent's `<agent-name>-dev` target is updated to depend on the
|
|
|
53
53
|
The Prisma client is instantiated inside `getAgent()`. Since the `ts#agent` generator configures a single Agent per session, the client is also reused for the lifetime of the session:
|
|
54
54
|
|
|
55
55
|
```ts title="packages/my-service/src/my-agent/agent.ts" {1,4}
|
|
56
|
-
import { getPrisma as getMyDb } from '
|
|
56
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
57
57
|
|
|
58
58
|
export const getAgent = async () => {
|
|
59
59
|
const myDb = await getMyDb();
|
|
@@ -67,8 +67,8 @@ export const getAgent = async () => {
|
|
|
67
67
|
Running the generator again with a different target adds the second database alongside the first:
|
|
68
68
|
|
|
69
69
|
```ts title="packages/my-service/src/my-agent/agent.ts" {1,2,5,6}
|
|
70
|
-
import { getPrisma as getMyDb } from '
|
|
71
|
-
import { getPrisma as getOtherDb } from '
|
|
70
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
71
|
+
import { getPrisma as getOtherDb } from '@my-scope/other-db';
|
|
72
72
|
|
|
73
73
|
export const getAgent = async () => {
|
|
74
74
|
const myDb = await getMyDb();
|
|
@@ -88,7 +88,7 @@ The generated agent construct implements `IGrantable` and `IConnectable`, so you
|
|
|
88
88
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
89
89
|
import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
|
|
90
90
|
import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
91
|
-
import { MyDatabase } from '
|
|
91
|
+
import { MyDatabase } from '@my-scope/common-constructs';
|
|
92
92
|
|
|
93
93
|
const db = new MyDatabase(this, 'Db', { vpc, ... });
|
|
94
94
|
|
|
@@ -42,7 +42,7 @@ The generator updates the MCP server's `<mcp-server-name>-dev` target in `projec
|
|
|
42
42
|
Import entity factories from the DynamoDB package and use them inside `createServer`:
|
|
43
43
|
|
|
44
44
|
```ts title="packages/my-service/src/my-mcp/server.ts"
|
|
45
|
-
import { createExampleEntity } from '
|
|
45
|
+
import { createExampleEntity } from '@my-scope/my-table';
|
|
46
46
|
|
|
47
47
|
export const createServer = async () => {
|
|
48
48
|
const server = new McpServer({ name: 'my-service', version: '1.0.0' });
|
|
@@ -67,7 +67,7 @@ To allow the MCP server to access the DynamoDB table, grant the necessary permis
|
|
|
67
67
|
<Fragment slot="cdk">
|
|
68
68
|
|
|
69
69
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
70
|
-
import { MyTable } from '
|
|
70
|
+
import { MyTable } from '@my-scope/common-constructs';
|
|
71
71
|
|
|
72
72
|
const table = new MyTable(this, 'Table');
|
|
73
73
|
const myMcpServer = new MyMcpServer(this, 'MyMcpServer');
|
|
@@ -53,7 +53,7 @@ Additionally, the `<mcp-server-name>-dev` target is updated to depend on the dat
|
|
|
53
53
|
The Prisma client is fetched inside `createServer` and available to all tools and resources registered there:
|
|
54
54
|
|
|
55
55
|
```ts title="packages/my-service/src/my-mcp/server.ts" {1,4}
|
|
56
|
-
import { getPrisma as getMyDb } from '
|
|
56
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
57
57
|
|
|
58
58
|
export const createServer = async () => {
|
|
59
59
|
const myDb = await getMyDb();
|
|
@@ -87,7 +87,7 @@ The generated MCP server construct implements `IGrantable` and `IConnectable`, s
|
|
|
87
87
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
88
88
|
import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
|
|
89
89
|
import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
90
|
-
import { MyDatabase } from '
|
|
90
|
+
import { MyDatabase } from '@my-scope/common-constructs';
|
|
91
91
|
|
|
92
92
|
const db = new MyDatabase(this, 'Db', { vpc, ... });
|
|
93
93
|
|
|
@@ -342,7 +342,7 @@ infra.asset -> ecr: cdk deploy\nbuilds + pushes
|
|
|
342
342
|
|
|
343
343
|
```ts
|
|
344
344
|
import { DockerImageAsset, Platform } from 'aws-cdk-lib/aws-ecr-assets';
|
|
345
|
-
import { findWorkspaceRoot } from '
|
|
345
|
+
import { findWorkspaceRoot } from '@my-scope/common-constructs';
|
|
346
346
|
import * as path from 'path';
|
|
347
347
|
import * as url from 'url';
|
|
348
348
|
|
|
@@ -356,7 +356,7 @@ const image = new DockerImageAsset(this, 'MyImage', {
|
|
|
356
356
|
});
|
|
357
357
|
```
|
|
358
358
|
|
|
359
|
-
The `findWorkspaceRoot` helper is generated by the <Link path="/guides/typescript-infrastructure">`ts#infra`</Link> generator and exported from
|
|
359
|
+
The `findWorkspaceRoot` helper is generated by the <Link path="/guides/typescript-infrastructure">`ts#infra`</Link> generator and exported from `@my-scope/common-constructs`. If you are not using shared constructs, you can hardcode the path to the `dist` directory relative to where `cdk` is invoked from — typically the workspace root — and omit the `findWorkspaceRoot` call entirely.
|
|
360
360
|
|
|
361
361
|
:::note[Running bundle before synth]
|
|
362
362
|
CDK does not run the `bundle`/`docker` targets automatically — you must run `nx build my-project` (or wire the deploy target to depend on `build`) before `cdk deploy`. The generators that use this pattern declare `docker` and `bundle` as dependencies of `build` so this happens transparently.
|
package/docs/guides/fastapi.mdx
CHANGED
|
@@ -445,7 +445,7 @@ The FastAPI generator creates CDK or Terraform infrastructure as code based on y
|
|
|
445
445
|
The CDK construct for deploying your API in the `common/constructs` folder. You can use this in a CDK application:
|
|
446
446
|
|
|
447
447
|
```ts {6-8}
|
|
448
|
-
import { MyApi } from '
|
|
448
|
+
import { MyApi } from '@my-scope/common-constructs';
|
|
449
449
|
|
|
450
450
|
export class ExampleStack extends Stack {
|
|
451
451
|
constructor(scope: Construct, id: string) {
|
|
@@ -473,7 +473,7 @@ This sets up:
|
|
|
473
473
|
If you selected to use `Cognito` authentication, you will need to supply the `identity` property to the API construct:
|
|
474
474
|
|
|
475
475
|
```ts {9}
|
|
476
|
-
import { MyApi, UserIdentity } from '
|
|
476
|
+
import { MyApi, UserIdentity } from '@my-scope/common-constructs';
|
|
477
477
|
|
|
478
478
|
export class ExampleStack extends Stack {
|
|
479
479
|
constructor(scope: Construct, id: string) {
|
|
@@ -149,7 +149,7 @@ You will need to add the user identity infrastructure to your stack, declaring i
|
|
|
149
149
|
```ts title="packages/infra/src/stacks/application-stack.ts" {3,9}
|
|
150
150
|
import { Stack } from 'aws-cdk-lib';
|
|
151
151
|
import { Construct } from 'constructs';
|
|
152
|
-
import { MyWebsite, UserIdentity } from '
|
|
152
|
+
import { MyWebsite, UserIdentity } from '@my-scope/common-constructs';
|
|
153
153
|
|
|
154
154
|
export class ApplicationStack extends Stack {
|
|
155
155
|
constructor(scope: Construct, id: string) {
|
|
@@ -195,7 +195,7 @@ The user identity module automatically adds the necessary <Link path="guides/rea
|
|
|
195
195
|
</Infrastructure>
|
|
196
196
|
|
|
197
197
|
:::caution[Remove localhost callback URLs for production]
|
|
198
|
-
The generated User Pool client allows your CloudFront distribution URL as
|
|
198
|
+
The generated User Pool client allows your CloudFront distribution URL (and any custom domain names configured on it) as OAuth callback/logout URLs, plus `http://localhost:4200` and `http://localhost:4300` for local development against the deployed pool.
|
|
199
199
|
|
|
200
200
|
It is recommended to **remove the `http://localhost` callback/logout URLs for production stages**, keeping the allowlist limited to your real application origins.
|
|
201
201
|
|
|
@@ -218,7 +218,7 @@ In order to grant authenticated users access to perform certain actions, such as
|
|
|
218
218
|
```ts title="packages/infra/src/stacks/application-stack.ts" {12}
|
|
219
219
|
import { Stack } from 'aws-cdk-lib';
|
|
220
220
|
import { Construct } from 'constructs';
|
|
221
|
-
import { MyWebsite, UserIdentity, MyApi } from '
|
|
221
|
+
import { MyWebsite, UserIdentity, MyApi } from '@my-scope/common-constructs';
|
|
222
222
|
|
|
223
223
|
export class ApplicationStack extends Stack {
|
|
224
224
|
constructor(scope: Construct, id: string) {
|
|
@@ -59,6 +59,7 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
59
59
|
- tsconfig.json Base TypeScript configuration for source and tests
|
|
60
60
|
- tsconfig.app.json TypeScript configuration for source code
|
|
61
61
|
- tsconfig.spec.json TypeScript configuration for tests
|
|
62
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
62
63
|
</FileTree>
|
|
63
64
|
|
|
64
65
|
:::note[Without TanStack Router]
|
|
@@ -245,7 +246,7 @@ Your website CDK construct will deploy the `connection` namespace of the runtime
|
|
|
245
246
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
246
247
|
import { Stack } from 'aws-cdk-lib';
|
|
247
248
|
import { Construct } from 'constructs';
|
|
248
|
-
import { MyWebsite, MyApi } from '
|
|
249
|
+
import { MyWebsite, MyApi } from '@my-scope/common-constructs';
|
|
249
250
|
|
|
250
251
|
export class ApplicationStack extends Stack {
|
|
251
252
|
constructor(scope: Construct, id: string) {
|
|
@@ -427,7 +428,7 @@ You can use the CDK construct generated for you in `packages/common/constructs`
|
|
|
427
428
|
```ts title="packages/infra/src/stacks/application-stack.ts" {3, 9}
|
|
428
429
|
import { Stack } from 'aws-cdk-lib';
|
|
429
430
|
import { Construct } from 'constructs';
|
|
430
|
-
import { MyWebsite } from '
|
|
431
|
+
import { MyWebsite } from '@my-scope/common-constructs';
|
|
431
432
|
|
|
432
433
|
export class ApplicationStack extends Stack {
|
|
433
434
|
constructor(scope: Construct, id: string) {
|
|
@@ -447,7 +448,7 @@ This sets up:
|
|
|
447
448
|
5. Automatic deployment of website files and runtime configuration
|
|
448
449
|
</Fragment>
|
|
449
450
|
<Fragment slot="terraform">
|
|
450
|
-
To deploy your website, we recommend using the <Link path="guides/terraform-
|
|
451
|
+
To deploy your website, we recommend using the <Link path="/guides/terraform-project">`terraform#project` generator</Link> to create a Terraform project.
|
|
451
452
|
|
|
452
453
|
You can use the Terraform module generated for you in `packages/common/terraform` to deploy your website.
|
|
453
454
|
|
|
@@ -70,7 +70,7 @@ Generated constructs automatically write relevant configuration to the `connecti
|
|
|
70
70
|
The `RuntimeConfig` CDK construct is a stage-scoped singleton. Use `set()` to write a key into a namespace:
|
|
71
71
|
|
|
72
72
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
73
|
-
import { RuntimeConfig } from '
|
|
73
|
+
import { RuntimeConfig } from '@my-scope/common-constructs';
|
|
74
74
|
|
|
75
75
|
const rc = RuntimeConfig.ensure(this);
|
|
76
76
|
|
package/docs/guides/trpc.mdx
CHANGED
|
@@ -66,6 +66,7 @@ The generator will create the following project structure in the `<directory>/<a
|
|
|
66
66
|
- client
|
|
67
67
|
- index.ts Type-safe client for machine-to-machine API calls
|
|
68
68
|
- tsconfig.json TypeScript configuration
|
|
69
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
69
70
|
- project.json Project configuration and build targets
|
|
70
71
|
|
|
71
72
|
</FileTree>
|
|
@@ -558,7 +559,7 @@ The CDK construct for deploying your API lives in the `common/constructs` folder
|
|
|
558
559
|
|
|
559
560
|
<OptionFilter when={{ auth: ['iam', 'custom'] }} description="CDK usage for IAM or Custom authentication">
|
|
560
561
|
```ts {6-8}
|
|
561
|
-
import { MyApi } from '
|
|
562
|
+
import { MyApi } from '@my-scope/common-constructs';
|
|
562
563
|
|
|
563
564
|
export class ExampleStack extends Stack {
|
|
564
565
|
constructor(scope: Construct, id: string) {
|
|
@@ -577,7 +578,7 @@ When using `Custom` auth, the construct creates a Lambda Authorizer internally f
|
|
|
577
578
|
|
|
578
579
|
<OptionFilter when={{ auth: 'cognito' }} description="CDK usage with Cognito authentication — pass the identity construct">
|
|
579
580
|
```ts {6,9}
|
|
580
|
-
import { MyApi, UserIdentity } from '
|
|
581
|
+
import { MyApi, UserIdentity } from '@my-scope/common-constructs';
|
|
581
582
|
|
|
582
583
|
export class ExampleStack extends Stack {
|
|
583
584
|
constructor(scope: Construct, id: string) {
|
|
@@ -813,7 +814,7 @@ This will automatically reload when you make changes to your API.
|
|
|
813
814
|
You can create a tRPC client to invoke your API in a type-safe manner. If you are calling your tRPC API from another backend, you can use the client in `src/client/index.ts`, for example:
|
|
814
815
|
|
|
815
816
|
```ts
|
|
816
|
-
import { createMyApiClient } from '
|
|
817
|
+
import { createMyApiClient } from '@my-scope/my-api';
|
|
817
818
|
|
|
818
819
|
const client = createMyApiClient({ url: 'https://my-api-url.example.com/' });
|
|
819
820
|
|
|
@@ -28,7 +28,7 @@ MCP clients (such as Claude Code, Kiro CLI or the MCP Inspector) expect to authe
|
|
|
28
28
|
|
|
29
29
|
## Generator Output
|
|
30
30
|
|
|
31
|
-
The generator creates a standalone <Link path="/guides/typescript-project">TypeScript project</Link> containing the Lambda handlers, and infrastructure to deploy them based on your selected `
|
|
31
|
+
The generator creates a standalone <Link path="/guides/typescript-project">TypeScript project</Link> containing the Lambda handlers, and infrastructure to deploy them based on your selected `iac`.
|
|
32
32
|
|
|
33
33
|
<FileTree>
|
|
34
34
|
|
|
@@ -36,6 +36,7 @@ The generator creates the following project structure in the `<directory>/<name>
|
|
|
36
36
|
- example.ts Example ElectroDB entity definition
|
|
37
37
|
- index.ts Entity exports
|
|
38
38
|
- config.json Table configuration including GSI definitions and local development settings
|
|
39
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
39
40
|
- project.json Project configuration and build targets
|
|
40
41
|
</FileTree>
|
|
41
42
|
|
|
@@ -136,7 +137,7 @@ GSIs are defined in `config.json` at the project root under the `tableConfig.glo
|
|
|
136
137
|
In any TypeScript project, import entity factories from your DynamoDB package and use them directly:
|
|
137
138
|
|
|
138
139
|
```ts
|
|
139
|
-
import { createExampleEntity } from '
|
|
140
|
+
import { createExampleEntity } from '@my-scope/my-table';
|
|
140
141
|
|
|
141
142
|
const entity = await createExampleEntity();
|
|
142
143
|
const result = await entity.query.primary({ id: '123' }).go();
|
|
@@ -79,40 +79,57 @@ If you selected `none` for `infra`, no CDK constructs or Terraform modules are g
|
|
|
79
79
|
|
|
80
80
|
### Adding Tools
|
|
81
81
|
|
|
82
|
-
Tools are functions that the AI assistant can call to perform actions.
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
server.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
Tools are functions that the AI assistant can call to perform actions. Each tool lives in its own file under `tools/` that exports a `register<Name>Tool` function, which you then call from `server.ts`. For example, add `tools/my-tool.ts`:
|
|
83
|
+
|
|
84
|
+
```typescript title="tools/my-tool.ts"
|
|
85
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
86
|
+
import { z } from 'zod';
|
|
87
|
+
|
|
88
|
+
export const registerMyTool = (server: McpServer) => {
|
|
89
|
+
server.registerTool("toolName", {
|
|
90
|
+
description: "tool description",
|
|
91
|
+
inputSchema: { param1: z.string(), param2: z.number() } // Input schema using Zod
|
|
92
|
+
},
|
|
93
|
+
async ({ param1, param2 }) => {
|
|
94
|
+
// Tool implementation
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: "text", text: "Result" }]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Then register it in `server.ts`:
|
|
104
|
+
|
|
105
|
+
```typescript title="server.ts"
|
|
106
|
+
import { registerMyTool } from './tools/my-tool.js';
|
|
107
|
+
|
|
108
|
+
registerMyTool(server);
|
|
96
109
|
```
|
|
97
110
|
|
|
98
111
|
### Adding Resources
|
|
99
112
|
|
|
100
|
-
Resources provide context to the AI assistant. You can add static resources from files or dynamic resources:
|
|
113
|
+
Resources provide context to the AI assistant. Like tools, each resource lives in its own file under `resources/` that exports a `register<Name>Resource` function called from `server.ts`. You can add static resources from files or dynamic resources:
|
|
114
|
+
|
|
115
|
+
```typescript title="resources/my-resource.ts"
|
|
116
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
101
117
|
|
|
102
|
-
|
|
103
|
-
const exampleContext = 'some context to return';
|
|
118
|
+
export const registerMyResource = (server: McpServer) => {
|
|
119
|
+
const exampleContext = 'some context to return';
|
|
104
120
|
|
|
105
|
-
server.registerResource('resource-name', 'example://resource', {}, async (uri) => ({
|
|
106
|
-
|
|
107
|
-
}));
|
|
121
|
+
server.registerResource('resource-name', 'example://resource', {}, async (uri) => ({
|
|
122
|
+
contents: [{ uri: uri.href, text: exampleContext }],
|
|
123
|
+
}));
|
|
108
124
|
|
|
109
|
-
// Dynamic resource
|
|
110
|
-
server.registerResource('dynamic-resource', 'dynamic://resource', {}, async (uri) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
125
|
+
// Dynamic resource
|
|
126
|
+
server.registerResource('dynamic-resource', 'dynamic://resource', {}, async (uri) => {
|
|
127
|
+
const data = await fetchSomeData();
|
|
128
|
+
return {
|
|
129
|
+
contents: [{ uri: uri.href, text: data }],
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
};
|
|
116
133
|
```
|
|
117
134
|
|
|
118
135
|
## Configuring with AI Assistants
|
|
@@ -55,14 +55,14 @@ The generator will create the following project structure:
|
|
|
55
55
|
|
|
56
56
|
### Adding Generators
|
|
57
57
|
|
|
58
|
-
Once you have your plugin project, you can add generators using the <Link path="/guides/
|
|
58
|
+
Once you have your plugin project, you can add generators using the <Link path="/guides/nx-generator">`ts#nx-generator`</Link> generator:
|
|
59
59
|
|
|
60
60
|
<RunGenerator generator="ts#nx-generator" requiredParameters={{ pluginProject: 'your-plugin' }} />
|
|
61
61
|
|
|
62
62
|
This will add a new generator to your plugin.
|
|
63
63
|
|
|
64
64
|
:::tip[Generator Documentation]
|
|
65
|
-
Read the <Link path="/guides/
|
|
65
|
+
Read the <Link path="/guides/nx-generator">`ts#nx-generator` guide</Link> for details about how to implement generators.
|
|
66
66
|
:::
|
|
67
67
|
|
|
68
68
|
Make sure to write a detailed `README.md` for your generator, since this is used by the MCP Server's `generator-guide` tool.
|
package/docs/guides/ts-rdb.mdx
CHANGED
|
@@ -47,6 +47,7 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
47
47
|
- .gitignore Git ignore entries including generated Prisma client output
|
|
48
48
|
- config.json Local development connection details and runtime config key
|
|
49
49
|
- Dockerfile Container image definition for the migration handler
|
|
50
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
50
51
|
- project.json Project configuration and build targets
|
|
51
52
|
- prisma.config.ts Configuration for Prisma CLI
|
|
52
53
|
</FileTree>
|
|
@@ -173,7 +174,7 @@ Replace `<engine>` with your container engine (`docker` or `finch`), `<scope>` w
|
|
|
173
174
|
In any TypeScript project, import `getPrisma` from your database package and call it to get a type-safe Prisma client:
|
|
174
175
|
|
|
175
176
|
```ts
|
|
176
|
-
import { getPrisma } from '
|
|
177
|
+
import { getPrisma } from '@my-scope/db';
|
|
177
178
|
|
|
178
179
|
const prisma = await getPrisma();
|
|
179
180
|
const users = await prisma.user.findMany({ orderBy: { id: 'asc' } });
|
|
@@ -340,7 +341,7 @@ export const listExampleTable = publicProcedure
|
|
|
340
341
|
If you are using the [middleware pattern](#injecting-the-prisma-client-via-middleware), add the `$disconnect()` call to the middleware so all procedures built on it are covered automatically:
|
|
341
342
|
|
|
342
343
|
```ts title="packages/api/src/middleware/db.ts"
|
|
343
|
-
import { getPrisma } from '
|
|
344
|
+
import { getPrisma } from '@my-scope/db';
|
|
344
345
|
import { initTRPC } from '@trpc/server';
|
|
345
346
|
|
|
346
347
|
export interface IDbContext {
|
|
@@ -46,6 +46,7 @@ The generator creates two related projects in the `<directory>/<api-name>` direc
|
|
|
46
46
|
<FileTree>
|
|
47
47
|
|
|
48
48
|
- **model/** Smithy model project
|
|
49
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
49
50
|
- project.json Project configuration and build targets
|
|
50
51
|
- smithy-build.json Smithy build configuration
|
|
51
52
|
- build.Dockerfile Docker configuration for building Smithy artifacts
|
|
@@ -588,7 +589,7 @@ The generator creates CDK or Terraform infrastructure based on your selected `ia
|
|
|
588
589
|
The CDK construct for deploying your API is in the `common/constructs` folder:
|
|
589
590
|
|
|
590
591
|
```ts {6-8}
|
|
591
|
-
import { MyApi } from '
|
|
592
|
+
import { MyApi } from '@my-scope/common-constructs';
|
|
592
593
|
|
|
593
594
|
export class ExampleStack extends Stack {
|
|
594
595
|
constructor(scope: Construct, id: string) {
|
|
@@ -615,7 +616,7 @@ This sets up:
|
|
|
615
616
|
If you selected `Cognito` authentication, you will need to supply the `identity` property to the API construct:
|
|
616
617
|
|
|
617
618
|
```ts {9}
|
|
618
|
-
import { MyApi, UserIdentity } from '
|
|
619
|
+
import { MyApi, UserIdentity } from '@my-scope/common-constructs';
|
|
619
620
|
|
|
620
621
|
export class ExampleStack extends Stack {
|
|
621
622
|
constructor(scope: Construct, id: string) {
|
|
@@ -38,6 +38,7 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
38
38
|
- stacks CDK Stack definitions
|
|
39
39
|
- application-stack.ts Main application stack
|
|
40
40
|
- cdk.json CDK configuration
|
|
41
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
41
42
|
- project.json Project configuration and build targets
|
|
42
43
|
- checkov.yml Checkov configuration file
|
|
43
44
|
|
|
@@ -102,10 +103,11 @@ The `env` property tells CDK which AWS account and region to deploy to. `CDK_DEF
|
|
|
102
103
|
If you generated with `stageConfig`, the `main.ts` reads account and region from a centralized config file instead, falling back to environment variables when no config is set:
|
|
103
104
|
|
|
104
105
|
```ts title="src/main.ts (with stageConfig)"
|
|
105
|
-
import
|
|
106
|
+
import { resolveStage } from '@my-scope/common-infra-config';
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
// Looks up the stage under this project (packages/infra), falling back to
|
|
109
|
+
// shared stages. Returns undefined when no config exists for the stage.
|
|
110
|
+
const sandboxConfig = resolveStage('packages/infra', 'my-app-sandbox');
|
|
109
111
|
|
|
110
112
|
new ApplicationStage(app, 'my-app-sandbox', {
|
|
111
113
|
env: {
|
|
@@ -242,7 +244,7 @@ Each stage config includes a required `region` and an optional `account`:
|
|
|
242
244
|
The generated `main.ts` reads these values from the config so that CDK synthesis and deployment use the same environment settings:
|
|
243
245
|
|
|
244
246
|
```ts title="src/main.ts"
|
|
245
|
-
const sandboxConfig =
|
|
247
|
+
const sandboxConfig = resolveStage('packages/infra', 'my-app-sandbox');
|
|
246
248
|
new ApplicationStage(app, 'my-app-sandbox', {
|
|
247
249
|
env: {
|
|
248
250
|
account: sandboxConfig?.account ?? process.env.CDK_DEFAULT_ACCOUNT,
|
|
@@ -270,7 +272,7 @@ If, for example, you created a tRPC API called `my-api`, you can simply import a
|
|
|
270
272
|
```ts title="src/stacks/application-stack.ts" {3, 9-12}
|
|
271
273
|
import { Stack, StackProps } from 'aws-cdk-lib';
|
|
272
274
|
import { Construct } from 'constructs';
|
|
273
|
-
import { MyApi } from '
|
|
275
|
+
import { MyApi } from '@my-scope/common-constructs';
|
|
274
276
|
|
|
275
277
|
export class ApplicationStack extends Stack {
|
|
276
278
|
constructor(scope: Construct, id: string, props?: StackProps) {
|
|
@@ -291,7 +293,7 @@ If you have used the <Link path="guides/react-website">React Website</Link> gene
|
|
|
291
293
|
```ts title="src/stacks/application-stack.ts" {3, 9-10}
|
|
292
294
|
import { Stack, StackProps } from 'aws-cdk-lib';
|
|
293
295
|
import { Construct } from 'constructs';
|
|
294
|
-
import { MyWebsite } from '
|
|
296
|
+
import { MyWebsite } from '@my-scope/common-constructs';
|
|
295
297
|
|
|
296
298
|
export class ApplicationStack extends Stack {
|
|
297
299
|
constructor(scope: Construct, id: string, props?: StackProps) {
|
|
@@ -338,7 +340,7 @@ There may be instances where you want to suppress certain rules on resources. Yo
|
|
|
338
340
|
#### Supress a rule on a given construct
|
|
339
341
|
|
|
340
342
|
```typescript
|
|
341
|
-
import { suppressRules } from '
|
|
343
|
+
import { suppressRules } from '@my-scope/common-constructs';
|
|
342
344
|
|
|
343
345
|
// suppresses the CKV_AWS_XXX for the given construct.
|
|
344
346
|
suppressRules(construct, ['CKV_AWS_XXX'], 'Reason');
|
|
@@ -347,7 +349,7 @@ suppressRules(construct, ['CKV_AWS_XXX'], 'Reason');
|
|
|
347
349
|
#### Supress a rule on a descendant construct
|
|
348
350
|
|
|
349
351
|
```typescript
|
|
350
|
-
import { suppressRules } from '
|
|
352
|
+
import { suppressRules } from '@my-scope/common-constructs';
|
|
351
353
|
|
|
352
354
|
// Supresses the CKV_AWS_XXX for the construct or any of its descendants if it is an instance of Bucket
|
|
353
355
|
suppressRules(construct, ['CKV_AWS_XXX'], 'Reason', (construct) => construct instanceof Bucket);
|