context-mapper-mcp
This MCP server lets AI assistants model Domain-Driven Design systems in Context Mapper's CML language and generate diagrams, canvases, and code artifacts from them.
Manage models: create, load, save, and validate CML models; get model statistics
Query the model: list/inspect bounded contexts, aggregates, relationships; search elements by regex pattern
Model bounded contexts: create, update, delete contexts, set responsibilities, vision statements, knowledge levels, and implementation technology
Model aggregates: create/update/delete aggregates and add entities, value objects, DDD-style ID value objects, domain events, commands, and domain services (individually or in bulk via batch creation)
Define context map relationships: Partnership, SharedKernel, and Upstream-Downstream with OHS/PL upstream and ACL/CF downstream patterns, exposed aggregates
Generate diagrams: PlantUML context maps, aggregate class diagrams, full model diagrams, and PNG/SVG context map images (via CLI)
Produce HTML artifacts: interactive, self-contained HTML context map with linked Bounded Context Canvas pages
Work with Bounded Context Canvases: set canvas-only sections, retrieve canvases in DDD Crew JSON/YAML, generate HTML or YAML canvases (saved as sidecar
.canvas.yamlfiles)Generate code/documentation artifacts via Context Mapper CLI: MDSL contracts, Freemarker templates, ubiquitous language glossary, JHipster JDL, and full domain reports
Manage the CLI: check Java/CLI status, configure paths and timeouts, download the CLI from Maven Central, list available generators
Enforce validity: real-time validation of duplicate names, invalid types, reserved keywords, and auto-escaping of reserved attributes
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@context-mapper-mcp List all bounded contexts in my model."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Context Mapper MCP Server
An MCP (Model Context Protocol) server that enables AI assistants to work with Domain-Driven Design models using Context Mapper's CML (Context Mapping Language).
Features
Parse and serialize CML files - Full support for Context Mapper's CML syntax
Manage bounded contexts - Create, update, delete bounded contexts
Work with aggregates - Define entities, value objects, domain events, commands, and services
Context map relationships - Define and manage relationships between bounded contexts (Partnership, SharedKernel, Upstream-Downstream with patterns like OHS, PL, ACL, CF)
Generate PlantUML diagrams - Visualize context maps and aggregate structures
Bounded Context Canvas - Create DDD Crew Bounded Context Canvases (v5), derived from the model and enriched with canvas-only sections
HTML artifacts - Interactive, self-contained HTML context map linked to an HTML canvas per bounded context (works offline, no Java needed)
Real-time validation - Catch errors at creation time, not at save time
ID Value Objects - Dedicated tool for creating DDD-compliant identifier types
Related MCP server: RepoMind-MCP
Validation Features
The server validates models in real-time to prevent common CML errors:
Validation | When | Example Error |
Duplicate names | On create |
|
Invalid types | On create |
|
Reserved names | On create |
|
Reserved attributes | On save | Auto-escaped with |
Valid Attribute Types
Primitives:
String,int,long,boolean,DateTime,BigDecimal,UUIDCollections:
List<Type>,Set<Type>References:
- TypeName(reference to domain objects)
Invalid Types (Rejected)
Map<K,V>,Any,Tuple,Runnable,Callbacks, nested generics
Installation
Claude Code
claude mcp add context-mapper -- npx -y context-mapper-mcp@latestClaude Desktop
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"context-mapper": {
"command": "npx",
"args": ["-y", "context-mapper-mcp@latest"]
}
}
}Available Tools
Model Management
Tool | Description |
| Create a new empty CML model |
| Load a CML file |
| Save model to disk |
| Validate CML syntax and semantics |
| Get model statistics |
Query Tools
Tool | Description |
| List all bounded contexts |
| Get context details |
| List aggregates (optionally filtered by context) |
| Get aggregate with all its elements |
| Search by name pattern (regex) |
| List context map relationships |
Context Tools
Tool | Description |
| Create a context map |
| Create a bounded context |
| Update a bounded context |
| Delete a bounded context |
Aggregate Tools
Tool | Description |
| Create an aggregate |
| Update an aggregate |
| Delete an aggregate |
| Add entity to aggregate |
| Add value object |
| Add ID value object (DDD best practice) |
| Add domain event |
| Add command |
| Add domain service |
| Batch create multiple domain objects in one call |
| Delete entity |
| Delete value object |
| Delete domain event |
| Delete command |
| Delete service |
Batch Creation (cml_batch_add_elements)
Create multiple domain objects in a single call for improved efficiency:
{
"contextName": "CustomerManagement",
"aggregateName": "Customer",
"identifiers": [
{ "name": "CustomerId" }
],
"entities": [
{
"name": "Customer",
"aggregateRoot": true,
"attributes": [
{ "name": "id", "type": "- CustomerId", "key": true },
{ "name": "email", "type": "String" }
]
}
],
"valueObjects": [
{
"name": "Address",
"attributes": [
{ "name": "street", "type": "String" },
{ "name": "city", "type": "String" }
]
}
],
"domainEvents": [
{ "name": "CustomerRegistered", "attributes": [{ "name": "customerId", "type": "- CustomerId" }] }
],
"commands": [
{ "name": "RegisterCustomer", "attributes": [{ "name": "email", "type": "String" }] }
]
}Benefits:
Faster: Single round-trip instead of 8+ individual calls
Atomic validation: All elements validated before any are created
Error handling: Use
failFast: falseto collect all errors at once
Relationship Tools
Tool | Description |
| Create context map relationship |
| Update relationship |
| Delete relationship |
| Get relationship details |
Supported relationship types:
Partnership - Symmetric, both contexts cooperate
SharedKernel - Symmetric, shared code/models
UpstreamDownstream - Asymmetric with patterns:
Upstream: OHS (Open Host Service), PL (Published Language)
Downstream: ACL (Anticorruption Layer), CF (Conformist)
Generation Tools
Tool | Description |
| Generate PlantUML context map |
| Generate aggregate class diagram |
| Generate full model diagram |
| Generate an interactive HTML context map plus a linked canvas page per context |
Bounded Context Canvas Tools
Tool | Description |
| Set canvas sections CML cannot express (strategic classification, domain roles, business decisions, assumptions, verification metrics, open questions, extra collaborators and terms) |
| Get a context's canvas in the DDD Crew canonical format (JSON or YAML) |
| Write canvases as HTML pages or as DDD Crew YAML for one or all contexts |
Canvas sections are filled from the model where possible:
Canvas section | Derived from |
Purpose |
|
Inbound / outbound communication | Context map relationships: downstreams receive the domain events of the upstream's exposed aggregates (all aggregates when none are exposed); commands are attributed to downstreams only when aggregates are exposed explicitly. Relationship patterns (OHS, PL, ACL, CF, Partnership, Shared Kernel) become the relationship label. |
Ubiquitous language | Aggregates, entities and value objects (identifier-only value objects are skipped), with their documentation as definition |
Explicitly set entries take precedence over derived ones with the same collaborator or term. Canvas data is saved by cml_save_model to a sidecar file next to the model (model.cml → model.canvas.yaml) in the DDD Crew YAML format, one YAML document per bounded context, and loaded again by cml_load_model.
Example CML File
ContextMap ECommerceContextMap {
type = AS_IS
contains CustomerManagement, OrderManagement, Inventory
CustomerManagement [U,OHS,PL] -> [D,ACL] OrderManagement
OrderManagement [U] -> [D,CF] Inventory
}
BoundedContext CustomerManagement {
domainVisionStatement = "Manages customer data"
implementationTechnology = "TypeScript"
Aggregate Customer {
Entity Customer {
aggregateRoot
key String customerId
String email
String firstName
}
ValueObject Address {
String street
String city
}
DomainEvent CustomerRegistered {
String customerId
Date registeredAt
}
Command RegisterCustomer {
String email
String firstName
}
}
}Development
git clone https://github.com/thijs-hakkenberg/contextmapper_mcp.git
cd contextmapper_mcp
npm install
npm run build
npm testArchitecture
Parser: Chevrotain-based lexer and parser for CML syntax
Writer: Serializes model back to CML format
Validation: Checks model consistency and semantic rules
Tools: MCP tool implementations for all operations
Generators: PlantUML diagram generators, HTML context map and Bounded Context Canvas generators, Context Mapper CLI integration
License
MIT
Available Tools
47 toolscml_add_commandB
Add a command to an aggregate
Inputs: name (required), contextName (required), aggregateName (required), attributes.
cml_add_domain_eventB
Add a domain event to an aggregate
Inputs: name (required), contextName (required), aggregateName (required), attributes.
cml_add_entityC
Add an entity to an aggregate
Inputs: name (required), contextName (required), aggregateName (required), attributes, +1 more.
cml_add_identifierA
Create an ID Value Object following DDD best practices. Use this instead of primitive String IDs to properly model identifiers as Value Objects.
Inputs: name (required), contextName (required), aggregateName (required).
cml_add_serviceC
Add a domain service to an aggregate
Inputs: name (required), contextName (required), aggregateName (required), operations.
cml_add_value_objectC
Add a value object to an aggregate
Inputs: name (required), contextName (required), aggregateName (required), attributes.
cml_batch_add_elementsA
Batch creation of multiple domain objects (entities, value objects, identifiers, events, commands, services) in a single call. More efficient than individual calls. Validates all elements before creating any.
Inputs: contextName (required), aggregateName (required), commands, entities, +5 more.
cml_cli_statusA
Check Context Mapper CLI and Java availability status
Inputs: no named parameters.
cml_configure_cliB
Configure CLI settings (paths, Java home, output directory, timeout)
Inputs: cliDir, timeout, version, javaHome, +1 more.
cml_create_aggregateC
Create a new aggregate in a bounded context
Inputs: name (required), contextName (required), knowledgeLevel, responsibilities.
cml_create_bounded_contextB
Create a new bounded context
Inputs: name (required), knowledgeLevel, responsibilities, domainVisionStatement, +1 more.
cml_create_context_mapC
Create a context map for the model
Inputs: name, state.
cml_create_modelC
Create a new empty CML model
Inputs: name (required).
cml_create_relationshipA
Create a relationship between bounded contexts. Types: Partnership, SharedKernel (symmetric), UpstreamDownstream (asymmetric with optional OHS/PL upstream patterns and ACL/CF downstream patterns)
Inputs: type (required), name, upstream, downstream, +5 more.
cml_delete_aggregateC
Delete an aggregate
Inputs: contextName (required), aggregateName (required).
cml_delete_bounded_contextB
Delete a bounded context and its relationships
Inputs: name (required).
cml_delete_commandB
Delete a command from an aggregate
Inputs: commandName (required), contextName (required), aggregateName (required).
cml_delete_domain_eventB
Delete a domain event from an aggregate
Inputs: eventName (required), contextName (required), aggregateName (required).
cml_delete_entityC
Delete an entity from an aggregate
Inputs: entityName (required), contextName (required), aggregateName (required).
cml_delete_relationshipC
Delete a relationship
Inputs: id (required).
cml_delete_serviceC
Delete a service from an aggregate
Inputs: contextName (required), serviceName (required), aggregateName (required).
cml_delete_value_objectC
Delete a value object from an aggregate
Inputs: contextName (required), aggregateName (required), valueObjectName (required).
cml_download_cliA
Download and install the Context Mapper CLI from Maven Central
Inputs: force, version.
cml_find_elementsA
Search for elements by name pattern (regex supported)
Inputs: pattern (required), elementType.
cml_generate_aggregate_diagramC
Generate a PlantUML class diagram for an aggregate
Inputs: contextName (required), aggregateName (required).
cml_generate_context_map_diagramB
Generate a PlantUML context map diagram
Inputs: includeAggregates.
cml_generate_context_map_imageB
Generate Context Map visualization (PNG/SVG) using Context Mapper CLI. Requires Java 17+ and CLI (auto-downloaded on first use).
Inputs: width, format, height, timeout, +3 more.
cml_generate_from_templateC
Generate output from a custom Freemarker template. Requires Java 17+ and CLI.
Inputs: templatePath (required), timeout, outputDir, outputFileName.
cml_generate_full_diagramB
Generate a PlantUML diagram of the full domain model
Inputs: no named parameters.
cml_generate_full_reportC
Generate comprehensive domain documentation (Markdown) using bundled template. Requires Java 17+ and CLI.
Inputs: timeout, outputDir.
cml_generate_glossaryB
Generate ubiquitous language glossary (Markdown) from domain model using bundled template. Requires Java 17+ and CLI.
Inputs: timeout, outputDir.
cml_generate_jhipster_jdlB
Generate JHipster JDL from domain model using bundled template. Requires Java 17+ and CLI.
Inputs: type, timeout, outputDir.
cml_generate_mdslA
Generate MDSL microservice contracts from Context Map upstream-downstream relationships. Requires Java 17+ and CLI.
Inputs: timeout, outputDir.
cml_get_aggregateB
Get detailed information about an aggregate including entities, value objects, events, and commands
Inputs: contextName (required), aggregateName (required).
cml_get_bounded_contextA
Get detailed information about a bounded context
Inputs: name (required).
cml_get_model_infoC
Get information about the current model
Inputs: no named parameters.
cml_get_relationshipB
Get details of a specific relationship
Inputs: id (required).
cml_list_aggregatesB
List all aggregates, optionally filtered by context
Inputs: contextName.
cml_list_bounded_contextsA
List all bounded contexts in the model
Inputs: no named parameters.
cml_list_generatorsA
List all available generators and their availability status
Inputs: no named parameters.
cml_list_relationshipsC
List context map relationships
Inputs: contextName.
cml_load_modelB
Load a CML model from a file
Inputs: path (required).
cml_save_modelC
Save the current model to a file
Inputs: path.
cml_update_aggregateC
Update an aggregate
Inputs: contextName (required), aggregateName (required), newName, knowledgeLevel, +1 more.
cml_update_bounded_contextC
Update a bounded context
Inputs: name (required), newName, knowledgeLevel, responsibilities, +2 more.
cml_update_relationshipD
Update a relationship
Inputs: id (required), name, upstreamPatterns, exposedAggregates, +1 more.
cml_validate_modelD
Validate the current CML model
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 47 tools
Most tools have clear purposes, but the large number (47) and some overlapping concepts (e.g., generate vs. create for context maps) may cause minor confusion. Descriptions help distinguish, but agents might misselect between aggregate-level and full-model diagram generators.
All tools use 'cml_' prefix with consistent snake_case and verb_noun pattern (e.g., cml_add_command, cml_delete_aggregate, cml_generate_diagram). No mixing of conventions.
47 tools is high, reflecting comprehensive DDD modeling capabilities. While each tool serves a specific purpose, the count exceeds typical scopes, and some could be consolidated (e.g., separate delete tools for each element type).
The tool set covers full lifecycle management for bounded contexts, aggregates, relationships, and elements (commands, events, entities, etc.), plus model validation, file I/O, batch operations, and extensive generation outputs (diagrams, reports, glossary, JDL, MDSL). No obvious gaps.
Maintenance
Related MCP Connectors
MCP server for Product Management
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Collaborative whiteboard MCP server — create objects, connectors, C4 diagrams, and manage boards
Repository knowledge graph MCP server for codebase understanding and debugging.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that provides persistent memory and contextual awareness to language models, enabling project onboarding, recall of architectural rules, and code consistency across sessions.32MIT
- FlicenseAqualityDmaintenanceMCP server for repository mapping, dependency analysis, and architecture diagram generation for JavaScript, TypeScript, and Python projects.410 npm-
- AlicenseBqualityBmaintenanceA local MCP server for managing engineering context across Components, Repos, Tasks, and Governance entities. It enables capturing reusable context and composing it per-task with typed relationships and cross-cutting guidelines.361MIT
- AlicenseNot gradedqualityCmaintenanceMCP server that manages C4 architecture models, ADRs, and flow diagrams as TOML files in a docs directory, with git versioning and an HTTP viewer.113 PyPIMIT