Skip to main content

MCP Server

MCP (Model Context Protocol) Server for the MBC CQRS Serverless framework. This package enables interaction with the framework through tools like Claude Code and Cursor.

What is MCP?

Model Context Protocol (MCP) is a protocol for AI tools to interact with applications and frameworks in a standardized way. It provides three main concepts: Resources, Tools, and Prompts.

Features

Resources

Access framework documentation and project information.

Resource URIDescription
mbc://docs/overviewComplete framework documentation
mbc://docs/llms-shortConcise framework overview
mbc://docs/architectureCQRS architecture guide
mbc://docs/errorsError catalog with solutions
mbc://docs/faqFrequently asked questions
mbc://docs/troubleshootingTroubleshooting guide
mbc://docs/securitySecurity best practices
mbc://project/entitiesList of project entities
mbc://project/modulesList of project modules
mbc://project/structureProject directory structure

Tools

Provides code generation and project analysis tools.

ToolDescription
mbc_generate_moduleGenerate a complete CQRS module
mbc_generate_controllerGenerate a controller
mbc_generate_serviceGenerate a service
mbc_generate_entityGenerate an entity
mbc_generate_dtoGenerate a DTO
mbc_validate_cqrsValidate CQRS pattern implementation
mbc_analyze_projectAnalyze project structure
mbc_lookup_errorLook up error solutions
mbc_check_anti_patternsCheck code for common anti-patterns
mbc_health_checkPerform project health check
mbc_explain_codeExplain code in MBC context

Prompts

Provides guided assistance.

PromptDescription
cqrs_implementation_guideStep-by-step CQRS implementation
debug_command_errorDebug command-related errors
migration_guideVersion migration guidance

Installation

npm install @mbc-cqrs-serverless/mcp-server

Or use directly with npx:

npx @mbc-cqrs-serverless/mcp-server

Configuration

Claude Code

Add the following configuration to ~/.claude/claude_desktop_config.json:

{
"mcpServers": {
"mbc-cqrs-serverless": {
"command": "npx",
"args": ["@mbc-cqrs-serverless/mcp-server"],
"env": {
"MBC_PROJECT_PATH": "/path/to/your/project"
}
}
}
}

Cursor

Add to Cursor MCP configuration:

{
"mbc-cqrs-serverless": {
"command": "npx",
"args": ["@mbc-cqrs-serverless/mcp-server"],
"env": {
"MBC_PROJECT_PATH": "/path/to/your/project"
}
}
}

Environment Variables

VariableDescriptionDefault
MBC_PROJECT_PATHPath to project directoryCurrent working directory

Usage Examples

Module Generation

You can ask Claude Code:

"Generate a new Order module with async command handling"

Project Analysis

Analyze project structure.

"Analyze my project structure"

Debug Assistance

Get help debugging errors.

"I'm getting a version mismatch error, help me debug"

Code Analysis Tools

Version Note

Code analysis tools (mbc_check_anti_patterns, mbc_health_check, mbc_explain_code) were added in version 1.0.22.

Anti-Pattern Detection

The mbc_check_anti_patterns tool detects common code issues:

CodeNameSeverityDescription
AP001Direct DynamoDB WriteCriticalUse CommandService instead of direct DynamoDB writes
AP002Ignored Version MismatchHighHandle VersionMismatchError properly with retry
AP003N+1 Query PatternHighUse batch operations instead of loop queries
AP004Full Table ScanHighUse Query with key conditions instead of Scan
AP005Hardcoded TenantCriticalUse getUserContext() for tenant code
AP006Missing Tenant ValidationCriticalNever trust client-provided tenant codes
AP007Throwing in Sync HandlerHighHandle errors gracefully in DataSyncHandler
AP008Hardcoded SecretCriticalUse environment variables or Secrets Manager
AP009Manual JWT ParsingCriticalUse built-in Cognito authorizer
AP010Heavy Module ImportMediumImport only needed functions to reduce cold start

Health Check

The mbc_health_check tool verifies project configuration:

  • MBC framework packages installation
  • NestJS dependencies
  • TypeScript configuration
  • Environment file setup
  • Source directory structure
  • Serverless configuration

Code Explanation

The mbc_explain_code tool analyzes code and explains:

  • NestJS module structure and imports
  • REST controller endpoints
  • Service patterns and dependencies
  • Entity definitions and DynamoDB keys
  • CQRS command publishing patterns
  • Data sync handler behavior

Claude Code Skills

Version Note

Claude Code Skills were added in version 1.0.24.

Claude Code Skills provide guided assistance for MBC CQRS Serverless development. Skills are specialized prompts that help developers with common tasks.

Available Skills

SkillDescription
/mbc-generateGenerate boilerplate code (modules, services, controllers, DTOs, handlers)
/mbc-reviewReview code for best practices and anti-patterns (20 patterns)
/mbc-migrateGuide version migrations and breaking changes
/mbc-debugDebug and troubleshoot common issues

Installing Skills

The easiest way to install skills is using the MBC CLI:

# Install to personal skills directory (available in all projects)
mbc install-skills

# Install to project directory (shared with team via git)
mbc install-skills --project

# List available skills
mbc install-skills --list

# Force overwrite existing skills
mbc install-skills --force

Manual Installation

Alternatively, copy them manually to your Claude Code skills directory:

# Copy to personal skills (available in all projects)
cp -r node_modules/@mbc-cqrs-serverless/mcp-server/skills/* ~/.claude/skills/

# Or copy to project skills (shared with team)
cp -r node_modules/@mbc-cqrs-serverless/mcp-server/skills/* .claude/skills/

/mbc-generate Skill

Generates boilerplate code following MBC CQRS Serverless best practices.

Core Templates:

  • Module, Controller, Service, DTOs, DataSyncHandler

Additional Templates:

  • Event Handler for custom event processing
  • Query Handler for complex searches
  • Elasticsearch Sync Handler
  • GraphQL Resolver

Example Usage:

/mbc-generate
Create an Order module with RDS synchronization

/mbc-review Skill

Reviews code for MBC CQRS Serverless best practices and identifies anti-patterns.

Anti-Patterns Detected (20 patterns):

CodeDescriptionSeverity
AP001Using publishSync instead of publishAsyncWarning
AP002Missing tenantCode in multi-tenant operationsError
AP003Hardcoded version numbersError
AP004Missing DataSyncHandler registrationError
AP005Not handling ConditionalCheckFailedExceptionWarning
AP006Using wrong PK/SK formatError
AP007Missing invokeContext in service methodsError
AP008Not using generateId for entity IDsWarning
AP009Missing DTO validation decoratorsWarning
AP010Deprecated method usageWarning
AP011Missing getCommandSource for tracingWarning
AP012Direct DynamoDB access instead of DataServiceWarning
AP013Missing type declaration in DataSyncHandlerError
AP014Not using DetailKey typeInfo
AP015Hardcoded table namesWarning
AP016Missing error loggingWarning
AP017Incorrect attribute mergingError
AP018Missing Swagger documentationInfo
AP019Not handling pagination correctlyWarning
AP020Circular module dependenciesError

Example Usage:

/mbc-review
Review the code in src/order/order.service.ts

/mbc-migrate Skill

Guides version migrations for MBC CQRS Serverless framework.

Features:

  • Version migration matrix (v1.0.16 to v1.0.23)
  • Detailed migration guides for each version
  • Deprecated API migration instructions
  • Migration checklist (before, during, after)
  • Version compatibility matrix

Example Usage:

/mbc-migrate
I need to upgrade from v1.0.20 to v1.0.23

/mbc-debug Skill

Helps debug and troubleshoot issues in MBC CQRS Serverless applications.

Features:

  • Error code quick lookup
  • 6 debugging workflows (Command, ConditionalCheckFailedException, DataSyncHandler, Tenant, Import, Performance)
  • CloudWatch log queries
  • Local development debugging (LocalStack, Serverless Offline)
  • Troubleshooting decision tree

Example Usage:

/mbc-debug
I'm getting ConditionalCheckFailedException errors