Skip to main content
Glama
AkM-2018
by AkM-2018

ExplainCDKNagRule

Get detailed explanations and remediation steps for AWS CDK Nag security rules to ensure infrastructure follows AWS Well-Architected best practices.

Instructions

Explain a specific CDK Nag rule with AWS Well-Architected guidance.

CDK Nag is a crucial tool for ensuring your CDK applications follow AWS security best practices.

Basic implementation:
```typescript
import { App } from 'aws-cdk-lib';
import { AwsSolutionsChecks } from 'cdk-nag';

const app = new App();
// Create your stack
const stack = new MyStack(app, 'MyStack');
// Apply CDK Nag
AwsSolutionsChecks.check(app);
```

Optional integration patterns:

1. Using environment variables:
```typescript
if (process.env.ENABLE_CDK_NAG === 'true') {
  AwsSolutionsChecks.check(app);
}
```

2. Using CDK context parameters:
```typescript
3. Environment-specific application:
```typescript
const environment = app.node.tryGetContext('environment') || 'development';
if (['production', 'staging'].includes(environment)) {
  AwsSolutionsChecks.check(stack);
}
```

For more information on specific rule packs:
- Use resource `cdk-nag://rules/{rule_pack}` to get all rules for a specific pack
- Use resource `cdk-nag://warnings/{rule_pack}` to get warnings for a specific pack
- Use resource `cdk-nag://errors/{rule_pack}` to get errors for a specific pack

Args:
    ctx: MCP context
    rule_id: The CDK Nag rule ID (e.g., 'AwsSolutions-IAM4')

Returns:
    Dictionary with detailed explanation and remediation steps

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYes
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes what the tool does (explains rules) and hints at output format ('detailed explanation and remediation steps'), but lacks critical behavioral details such as whether it's a read-only operation, if it requires external resources, error handling, or performance characteristics. The description adds some context but falls short for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is poorly structured and verbose. It includes extensive code examples and implementation patterns that are irrelevant to the tool's core function of explaining rules, burying the key information. The front-loading is weak, with the purpose stated upfront but followed by distracting content. Sentences like 'CDK Nag is a crucial tool...' don't earn their place in a tool description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, and no output schema, the description is incomplete. It covers the basic purpose and parameter example but misses critical context: no details on output structure, error cases, dependencies, or integration with sibling tools. For a tool with one parameter but rich expected output ('dictionary with detailed explanation'), more completeness is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It provides the parameter 'rule_id' in the Args section with an example ('AwsSolutions-IAM4'), which adds meaning beyond the bare schema. However, it doesn't explain parameter constraints, format rules, or where to find valid rule IDs, leaving gaps in semantic understanding. The value added is moderate but incomplete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Explain a specific CDK Nag rule with AWS Well-Architected guidance.' It specifies the verb ('explain') and resource ('CDK Nag rule'), though it doesn't explicitly differentiate from sibling tools like 'CDKGeneralGuidance' or 'CheckCDKNagSuppressions' which might cover related but different functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no explicit guidance on when to use this tool versus alternatives. While it mentions CDK Nag's importance and includes implementation examples, it doesn't clarify scenarios where this explanation tool is preferred over other siblings like 'CheckCDKNagSuppressions' or general guidance tools. Usage is implied through the examples but not directly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AkM-2018/tmp_cdk_mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server