@jaypie/mcp 0.3.1 → 0.3.4
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/dist/aws-B3dW_-bD.js +1202 -0
- package/dist/aws-B3dW_-bD.js.map +1 -0
- package/dist/index.js +357 -1200
- package/dist/index.js.map +1 -1
- package/dist/suite.d.ts +1 -0
- package/dist/suite.js +1252 -0
- package/dist/suite.js.map +1 -0
- package/package.json +11 -2
- package/prompts/Jaypie_Fabric_MCP.md +22 -2
- package/prompts/Jaypie_Fabric_Package.md +86 -0
- package/prompts/Jaypie_MCP_Package.md +34 -2
- package/release-notes/constructs/1.2.17.md +11 -0
- package/release-notes/fabric/0.1.1.md +17 -0
- package/release-notes/fabric/0.1.2.md +11 -0
- package/release-notes/mcp/0.3.2.md +14 -0
- package/release-notes/mcp/0.3.3.md +12 -0
- package/release-notes/mcp/0.3.4.md +36 -0
- package/skills/agents.md +25 -0
- package/skills/aws.md +107 -0
- package/skills/cdk.md +141 -0
- package/skills/cicd.md +152 -0
- package/skills/datadog.md +129 -0
- package/skills/debugging.md +148 -0
- package/skills/dns.md +134 -0
- package/skills/dynamodb.md +140 -0
- package/skills/errors.md +142 -0
- package/skills/fabric.md +164 -0
- package/skills/index.md +7 -0
- package/skills/jaypie.md +100 -0
- package/skills/legacy.md +97 -0
- package/skills/logs.md +160 -0
- package/skills/mocks.md +174 -0
- package/skills/models.md +195 -0
- package/skills/releasenotes.md +94 -0
- package/skills/secrets.md +155 -0
- package/skills/services.md +175 -0
- package/skills/style.md +190 -0
- package/skills/tests.md +209 -0
- package/skills/tools.md +127 -0
- package/skills/topics.md +116 -0
- package/skills/variables.md +146 -0
- package/skills/writing.md +153 -0
package/skills/aws.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: AWS integration, CLI tools, and cloud services
|
|
3
|
+
related: cdk, dynamodb, secrets, logs
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AWS Integration
|
|
7
|
+
|
|
8
|
+
Jaypie integrates with AWS services through SDK utilities and CLI tools available via the MCP.
|
|
9
|
+
|
|
10
|
+
## MCP AWS Tools
|
|
11
|
+
|
|
12
|
+
The Jaypie MCP provides AWS tools that use your local AWS credentials:
|
|
13
|
+
|
|
14
|
+
### Lambda Functions
|
|
15
|
+
```
|
|
16
|
+
aws_lambda_list_functions - List functions with optional prefix filter
|
|
17
|
+
aws_lambda_get_function - Get function configuration and details
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Step Functions
|
|
21
|
+
```
|
|
22
|
+
aws_stepfunctions_list_executions - List executions for a state machine
|
|
23
|
+
aws_stepfunctions_stop_execution - Stop a running execution
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### CloudWatch Logs
|
|
27
|
+
```
|
|
28
|
+
aws_logs_filter_log_events - Search logs with patterns and time ranges
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### S3
|
|
32
|
+
```
|
|
33
|
+
aws_s3_list_objects - List bucket objects with prefix filtering
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### DynamoDB
|
|
37
|
+
```
|
|
38
|
+
aws_dynamodb_describe_table - Get table metadata and indexes
|
|
39
|
+
aws_dynamodb_scan - Scan table (use sparingly)
|
|
40
|
+
aws_dynamodb_query - Query by partition key
|
|
41
|
+
aws_dynamodb_get_item - Get single item by key
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### SQS
|
|
45
|
+
```
|
|
46
|
+
aws_sqs_list_queues - List queues with prefix filter
|
|
47
|
+
aws_sqs_get_queue_attributes - Get queue attributes
|
|
48
|
+
aws_sqs_receive_message - Peek at queue messages
|
|
49
|
+
aws_sqs_purge_queue - Delete all messages (irreversible)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### CloudFormation
|
|
53
|
+
```
|
|
54
|
+
aws_cloudformation_describe_stack - Get stack details and outputs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Credential Management
|
|
58
|
+
|
|
59
|
+
Tools use the host's AWS credential chain:
|
|
60
|
+
1. Environment variables (`AWS_ACCESS_KEY_ID`, etc.)
|
|
61
|
+
2. `~/.aws/credentials` and `~/.aws/config`
|
|
62
|
+
3. SSO sessions via `aws sso login`
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# List available profiles
|
|
66
|
+
aws_list_profiles
|
|
67
|
+
|
|
68
|
+
# Use a specific profile
|
|
69
|
+
aws_lambda_list_functions --profile production
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Jaypie AWS Package
|
|
73
|
+
|
|
74
|
+
The `@jaypie/aws` package provides SDK utilities:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { getSecret, sendMessage } from "@jaypie/aws";
|
|
78
|
+
|
|
79
|
+
// Get secret from Secrets Manager
|
|
80
|
+
const apiKey = await getSecret("my-api-key");
|
|
81
|
+
|
|
82
|
+
// Send SQS message
|
|
83
|
+
await sendMessage(queueUrl, { action: "process", id: "123" });
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Environment-Based Configuration
|
|
87
|
+
|
|
88
|
+
Use CDK environment variables in Lambda:
|
|
89
|
+
|
|
90
|
+
| Variable | Description |
|
|
91
|
+
|----------|-------------|
|
|
92
|
+
| `CDK_ENV_BUCKET` | S3 bucket name |
|
|
93
|
+
| `CDK_ENV_QUEUE_URL` | SQS queue URL |
|
|
94
|
+
| `CDK_ENV_SNS_TOPIC_ARN` | SNS topic ARN |
|
|
95
|
+
|
|
96
|
+
## Profile Selection
|
|
97
|
+
|
|
98
|
+
When working with multiple AWS accounts:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Set default profile
|
|
102
|
+
export AWS_PROFILE=development
|
|
103
|
+
|
|
104
|
+
# Or specify per-command via MCP tools
|
|
105
|
+
aws_lambda_list_functions --profile production --region us-west-2
|
|
106
|
+
```
|
|
107
|
+
|
package/skills/cdk.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: CDK constructs and deployment patterns
|
|
3
|
+
related: aws, dynamodb, cicd
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CDK Constructs
|
|
7
|
+
|
|
8
|
+
Jaypie provides CDK constructs through `@jaypie/constructs` for deploying AWS infrastructure with best practices built-in.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @jaypie/constructs
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Core Constructs
|
|
17
|
+
|
|
18
|
+
### JaypieLambda
|
|
19
|
+
|
|
20
|
+
Lambda function with Datadog tracing, logging, and error handling:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { JaypieLambda } from "@jaypie/constructs";
|
|
24
|
+
|
|
25
|
+
const handler = new JaypieLambda(this, "ApiHandler", {
|
|
26
|
+
entry: "src/handler.ts",
|
|
27
|
+
handler: "handler",
|
|
28
|
+
environment: {
|
|
29
|
+
PROJECT_ENV: "production",
|
|
30
|
+
PROJECT_KEY: "my-api",
|
|
31
|
+
},
|
|
32
|
+
timeout: Duration.seconds(30),
|
|
33
|
+
memorySize: 512,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### JaypieQueue
|
|
38
|
+
|
|
39
|
+
SQS queue with DLQ and Lambda trigger:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { JaypieQueue } from "@jaypie/constructs";
|
|
43
|
+
|
|
44
|
+
const queue = new JaypieQueue(this, "ProcessQueue", {
|
|
45
|
+
visibilityTimeout: Duration.seconds(60),
|
|
46
|
+
retentionPeriod: Duration.days(7),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Connect to Lambda
|
|
50
|
+
queue.addEventSource(handler);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### JaypieBucket
|
|
54
|
+
|
|
55
|
+
S3 bucket with encryption and lifecycle rules:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { JaypieBucket } from "@jaypie/constructs";
|
|
59
|
+
|
|
60
|
+
const bucket = new JaypieBucket(this, "AssetsBucket", {
|
|
61
|
+
encryption: BucketEncryption.S3_MANAGED,
|
|
62
|
+
lifecycleRules: [
|
|
63
|
+
{ expiration: Duration.days(90), prefix: "temp/" }
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Stack Structure
|
|
69
|
+
|
|
70
|
+
Organize stacks in the `stacks/` directory:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
stacks/
|
|
74
|
+
├── cdk/
|
|
75
|
+
│ ├── src/
|
|
76
|
+
│ │ ├── app.ts # CDK app entry
|
|
77
|
+
│ │ └── stacks/
|
|
78
|
+
│ │ ├── api.ts # API stack
|
|
79
|
+
│ │ └── data.ts # Data stack
|
|
80
|
+
│ ├── cdk.json
|
|
81
|
+
│ └── package.json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Environment Configuration
|
|
85
|
+
|
|
86
|
+
Use environment-specific configuration:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const env = process.env.PROJECT_ENV || "sandbox";
|
|
90
|
+
const nonce = process.env.PROJECT_NONCE || "dev";
|
|
91
|
+
|
|
92
|
+
const stack = new ApiStack(app, `api-${env}-${nonce}`, {
|
|
93
|
+
env: {
|
|
94
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
95
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Deployment
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Deploy to sandbox
|
|
104
|
+
PROJECT_ENV=sandbox PROJECT_NONCE=dev cdk deploy
|
|
105
|
+
|
|
106
|
+
# Deploy to production
|
|
107
|
+
PROJECT_ENV=production PROJECT_NONCE=prod cdk deploy
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Environment Variables
|
|
111
|
+
|
|
112
|
+
Pass configuration to Lambda via environment variables:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
const handler = new JaypieLambda(this, "Handler", {
|
|
116
|
+
environment: {
|
|
117
|
+
CDK_ENV_BUCKET: bucket.bucketName,
|
|
118
|
+
CDK_ENV_QUEUE_URL: queue.queueUrl,
|
|
119
|
+
SECRET_MONGODB_URI: "mongodb-connection-string",
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Grant permissions
|
|
124
|
+
bucket.grantReadWrite(handler);
|
|
125
|
+
queue.grantSendMessages(handler);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Datadog Integration
|
|
129
|
+
|
|
130
|
+
Enable Datadog tracing:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const handler = new JaypieLambda(this, "Handler", {
|
|
134
|
+
datadogApiKeyArn: "arn:aws:secretsmanager:...",
|
|
135
|
+
environment: {
|
|
136
|
+
DD_ENV: "production",
|
|
137
|
+
DD_SERVICE: "my-api",
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
package/skills/cicd.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: GitHub Actions CI/CD workflows
|
|
3
|
+
related: tests, cdk
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CI/CD with GitHub Actions
|
|
7
|
+
|
|
8
|
+
Jaypie projects use GitHub Actions for continuous integration and deployment.
|
|
9
|
+
|
|
10
|
+
## Standard Workflows
|
|
11
|
+
|
|
12
|
+
### npm-check.yml
|
|
13
|
+
|
|
14
|
+
Runs on feature branches (`feat/*`, `fix/*`, `devin/*`):
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
name: npm-check
|
|
18
|
+
|
|
19
|
+
on:
|
|
20
|
+
push:
|
|
21
|
+
branches:
|
|
22
|
+
- 'feat/*'
|
|
23
|
+
- 'fix/*'
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
lint:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- uses: actions/setup-node@v4
|
|
31
|
+
with:
|
|
32
|
+
node-version: 24
|
|
33
|
+
- run: npm ci
|
|
34
|
+
- run: npm run lint
|
|
35
|
+
|
|
36
|
+
typecheck:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/setup-node@v4
|
|
41
|
+
with:
|
|
42
|
+
node-version: 24
|
|
43
|
+
- run: npm ci
|
|
44
|
+
- run: npm run typecheck
|
|
45
|
+
|
|
46
|
+
test:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
strategy:
|
|
49
|
+
matrix:
|
|
50
|
+
node-version: [22, 24, 25]
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
- uses: actions/setup-node@v4
|
|
54
|
+
with:
|
|
55
|
+
node-version: ${{ matrix.node-version }}
|
|
56
|
+
- run: npm ci
|
|
57
|
+
- run: npm run build
|
|
58
|
+
- run: npm test
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### npm-deploy.yml
|
|
62
|
+
|
|
63
|
+
Runs on `main` branch and release tags:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
name: npm-deploy
|
|
67
|
+
|
|
68
|
+
on:
|
|
69
|
+
push:
|
|
70
|
+
branches: [main]
|
|
71
|
+
tags:
|
|
72
|
+
- 'deploy-*'
|
|
73
|
+
- 'rc-*'
|
|
74
|
+
|
|
75
|
+
jobs:
|
|
76
|
+
publish:
|
|
77
|
+
runs-on: ubuntu-latest
|
|
78
|
+
permissions:
|
|
79
|
+
contents: read
|
|
80
|
+
id-token: write
|
|
81
|
+
steps:
|
|
82
|
+
- uses: actions/checkout@v4
|
|
83
|
+
- uses: actions/setup-node@v4
|
|
84
|
+
with:
|
|
85
|
+
node-version: 24
|
|
86
|
+
registry-url: 'https://registry.npmjs.org'
|
|
87
|
+
- run: npm ci
|
|
88
|
+
- run: npm run build
|
|
89
|
+
- run: npm publish --provenance
|
|
90
|
+
env:
|
|
91
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Branch Strategy
|
|
95
|
+
|
|
96
|
+
| Branch Pattern | Purpose | Triggers |
|
|
97
|
+
|---------------|---------|----------|
|
|
98
|
+
| `main` | Production releases | npm-deploy |
|
|
99
|
+
| `feat/*` | Feature development | npm-check |
|
|
100
|
+
| `fix/*` | Bug fixes | npm-check |
|
|
101
|
+
| `rc-*` tags | Release candidates | npm-deploy (--tag rc) |
|
|
102
|
+
|
|
103
|
+
## Testing Matrix
|
|
104
|
+
|
|
105
|
+
Test across multiple Node.js versions:
|
|
106
|
+
|
|
107
|
+
```yaml
|
|
108
|
+
strategy:
|
|
109
|
+
matrix:
|
|
110
|
+
node-version: [22, 24, 25]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Secrets Configuration
|
|
114
|
+
|
|
115
|
+
Required repository secrets:
|
|
116
|
+
|
|
117
|
+
| Secret | Purpose |
|
|
118
|
+
|--------|---------|
|
|
119
|
+
| `NPM_TOKEN` | npm publish authentication |
|
|
120
|
+
| `DATADOG_API_KEY` | Optional: Test tracing |
|
|
121
|
+
|
|
122
|
+
## Workflow Tips
|
|
123
|
+
|
|
124
|
+
### Skip Already-Published Versions
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
- run: |
|
|
128
|
+
CURRENT=$(npm view ${{ github.repository }} version 2>/dev/null || echo "0.0.0")
|
|
129
|
+
LOCAL=$(node -p "require('./package.json').version")
|
|
130
|
+
if [ "$CURRENT" = "$LOCAL" ]; then
|
|
131
|
+
echo "Version already published, skipping"
|
|
132
|
+
exit 0
|
|
133
|
+
fi
|
|
134
|
+
npm publish --provenance
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Conditional Job Execution
|
|
138
|
+
|
|
139
|
+
Run jobs only when specific files change:
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
- uses: dorny/paths-filter@v2
|
|
143
|
+
id: changes
|
|
144
|
+
with:
|
|
145
|
+
filters: |
|
|
146
|
+
src:
|
|
147
|
+
- 'packages/llm/**'
|
|
148
|
+
|
|
149
|
+
- run: npm test -w packages/llm
|
|
150
|
+
if: steps.changes.outputs.src == 'true'
|
|
151
|
+
```
|
|
152
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Datadog integration and observability
|
|
3
|
+
related: logs, debugging, aws
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Datadog Integration
|
|
7
|
+
|
|
8
|
+
Jaypie integrates with Datadog for logging, monitoring, and APM.
|
|
9
|
+
|
|
10
|
+
## MCP Datadog Tools
|
|
11
|
+
|
|
12
|
+
The Jaypie MCP provides tools for querying Datadog:
|
|
13
|
+
|
|
14
|
+
### Log Search
|
|
15
|
+
```
|
|
16
|
+
datadog_logs - Search individual log entries
|
|
17
|
+
datadog_log_analytics - Aggregate logs with groupBy
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Monitoring
|
|
21
|
+
```
|
|
22
|
+
datadog_monitors - List and check monitor status
|
|
23
|
+
datadog_synthetics - List synthetic tests and results
|
|
24
|
+
datadog_metrics - Query timeseries metrics
|
|
25
|
+
datadog_rum - Search Real User Monitoring events
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Environment Variables
|
|
29
|
+
|
|
30
|
+
Configure Datadog tools via environment:
|
|
31
|
+
|
|
32
|
+
| Variable | Description |
|
|
33
|
+
|----------|-------------|
|
|
34
|
+
| `DATADOG_API_KEY` or `DD_API_KEY` | API key |
|
|
35
|
+
| `DATADOG_APP_KEY` or `DD_APP_KEY` | Application key |
|
|
36
|
+
| `DD_ENV` | Default environment filter |
|
|
37
|
+
| `DD_SERVICE` | Default service filter |
|
|
38
|
+
| `DD_SOURCE` | Default log source (default: lambda) |
|
|
39
|
+
|
|
40
|
+
## Common Queries
|
|
41
|
+
|
|
42
|
+
### Search Error Logs
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
datadog_logs --query "status:error" --from "now-1h"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Count Errors by Service
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
datadog_log_analytics --groupBy '["service"]' --query "status:error"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Check Alerting Monitors
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
datadog_monitors --status '["Alert", "Warn"]'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Lambda Integration
|
|
61
|
+
|
|
62
|
+
Enable Datadog tracing in CDK:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { JaypieLambda } from "@jaypie/constructs";
|
|
66
|
+
|
|
67
|
+
const handler = new JaypieLambda(this, "Handler", {
|
|
68
|
+
datadogApiKeyArn: process.env.CDK_ENV_DATADOG_API_KEY_ARN,
|
|
69
|
+
environment: {
|
|
70
|
+
DD_ENV: "production",
|
|
71
|
+
DD_SERVICE: "my-api",
|
|
72
|
+
DD_VERSION: "1.0.0",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Logging Integration
|
|
78
|
+
|
|
79
|
+
Jaypie logging automatically formats for Datadog:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { log } from "jaypie";
|
|
83
|
+
|
|
84
|
+
// Structured logs are indexed by Datadog
|
|
85
|
+
log.info("Request processed", {
|
|
86
|
+
userId: "user-123",
|
|
87
|
+
action: "checkout",
|
|
88
|
+
duration: 150,
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Query Syntax
|
|
93
|
+
|
|
94
|
+
### Log Search Syntax
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
status:error # By status
|
|
98
|
+
@http.status_code:500 # By attribute
|
|
99
|
+
service:my-api # By service
|
|
100
|
+
*timeout* # Wildcard
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Time Ranges
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
now-15m # Last 15 minutes
|
|
107
|
+
now-1h # Last hour
|
|
108
|
+
now-1d # Last day
|
|
109
|
+
2024-01-15T10:00:00Z # Specific time (ISO 8601)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Unified Service Tagging
|
|
113
|
+
|
|
114
|
+
Use consistent tags across services:
|
|
115
|
+
|
|
116
|
+
| Tag | Purpose |
|
|
117
|
+
|-----|---------|
|
|
118
|
+
| `env` | Environment (sandbox, production) |
|
|
119
|
+
| `service` | Service name |
|
|
120
|
+
| `version` | Deployment version |
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
environment: {
|
|
124
|
+
DD_ENV: process.env.PROJECT_ENV,
|
|
125
|
+
DD_SERVICE: process.env.PROJECT_KEY,
|
|
126
|
+
DD_VERSION: process.env.npm_package_version,
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Debugging techniques and troubleshooting
|
|
3
|
+
related: logs, datadog, errors
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging Techniques
|
|
7
|
+
|
|
8
|
+
Strategies for debugging Jaypie applications.
|
|
9
|
+
|
|
10
|
+
## Log-Based Debugging
|
|
11
|
+
|
|
12
|
+
### Enable Debug Logging
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
LOG_LEVEL=debug npm run dev
|
|
16
|
+
LOG_LEVEL=trace npm run dev # Most verbose
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Search Logs via MCP
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
# Find errors in last hour
|
|
23
|
+
datadog_logs --query "status:error" --from "now-1h"
|
|
24
|
+
|
|
25
|
+
# Find specific request
|
|
26
|
+
datadog_logs --query "@requestId:abc-123"
|
|
27
|
+
|
|
28
|
+
# Search CloudWatch directly
|
|
29
|
+
aws_logs_filter_log_events --logGroupName "/aws/lambda/my-function" --filterPattern "ERROR"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Common Issues
|
|
33
|
+
|
|
34
|
+
### "undefined" in Stack Names
|
|
35
|
+
|
|
36
|
+
If you see `undefined` in a CDK stack name, a required variable is missing:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// BAD: undefined if PROJECT_NONCE not set
|
|
40
|
+
const stackName = `api-${process.env.PROJECT_NONCE}`;
|
|
41
|
+
|
|
42
|
+
// GOOD: Provide default
|
|
43
|
+
const nonce = process.env.PROJECT_NONCE || "dev";
|
|
44
|
+
const stackName = `api-${nonce}`;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### "unknown" in Logs
|
|
48
|
+
|
|
49
|
+
`unknown` indicates a value was expected but fell back to a default:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// This produces "unknown" if PROJECT_KEY not set
|
|
53
|
+
log.info("Starting", { project: process.env.PROJECT_KEY || "unknown" });
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Lambda Cold Starts
|
|
57
|
+
|
|
58
|
+
Check initialization time:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
datadog_logs --query "@dd.cold_start:true" --from "now-1h"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Connection Timeouts
|
|
65
|
+
|
|
66
|
+
For database or external service timeouts:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// Check Lambda timeout settings
|
|
70
|
+
aws_lambda_get_function --functionName "my-function"
|
|
71
|
+
|
|
72
|
+
// Look for timeout patterns in logs
|
|
73
|
+
datadog_logs --query "timeout OR ETIMEDOUT" --from "now-1h"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Increase Lambda timeout or optimize slow operations.
|
|
77
|
+
|
|
78
|
+
## Local Testing
|
|
79
|
+
|
|
80
|
+
### Lambda Local Testing
|
|
81
|
+
|
|
82
|
+
Use SAM CLI for local Lambda testing:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cd packages/express/docker
|
|
86
|
+
sam local invoke -e event.json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### DynamoDB Local
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Start local DynamoDB
|
|
93
|
+
docker run -p 8000:8000 amazon/dynamodb-local
|
|
94
|
+
|
|
95
|
+
# Access with AWS CLI
|
|
96
|
+
AWS_ACCESS_KEY_ID=local AWS_SECRET_ACCESS_KEY=local \
|
|
97
|
+
aws dynamodb list-tables --endpoint-url http://127.0.0.1:8000
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Stack Traces
|
|
101
|
+
|
|
102
|
+
### Finding Root Cause
|
|
103
|
+
|
|
104
|
+
Jaypie errors include context:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
try {
|
|
108
|
+
await riskyOperation();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
log.error("Operation failed", {
|
|
111
|
+
error: error.message,
|
|
112
|
+
stack: error.stack,
|
|
113
|
+
context: error.context, // Jaypie errors include this
|
|
114
|
+
});
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Error Classification
|
|
120
|
+
|
|
121
|
+
| Error Type | Cause |
|
|
122
|
+
|------------|-------|
|
|
123
|
+
| ConfigurationError | Missing or invalid config |
|
|
124
|
+
| NotFoundError | Resource doesn't exist |
|
|
125
|
+
| UnauthorizedError | Authentication failed |
|
|
126
|
+
| ForbiddenError | Permission denied |
|
|
127
|
+
| BadRequestError | Invalid input |
|
|
128
|
+
|
|
129
|
+
## Step Function Debugging
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
# List running executions
|
|
133
|
+
aws_stepfunctions_list_executions --stateMachineArn "arn:..." --statusFilter "RUNNING"
|
|
134
|
+
|
|
135
|
+
# Stop stuck execution
|
|
136
|
+
aws_stepfunctions_stop_execution --executionArn "arn:..." --cause "Manual stop for debugging"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Queue Debugging
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
# Check queue depth
|
|
143
|
+
aws_sqs_get_queue_attributes --queueUrl "https://..."
|
|
144
|
+
|
|
145
|
+
# Peek at messages (does not delete)
|
|
146
|
+
aws_sqs_receive_message --queueUrl "https://..." --maxNumberOfMessages 5
|
|
147
|
+
```
|
|
148
|
+
|