Skip to content
Conduit

mcp server

contextmapper-mcp

An MCP server for https://contextmapper.org

thijs-hakkenberg/contextmapper_mcpcommunitylistedunreviewed

Set up

Runs on your computer. Pick your agent and operating system.

Before you start

  • Node.js 20 or newer
~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "contextmapper-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "context-mapper-mcp"
      ]
    }
  }
}

same format Cursor, GitHub Copilot CLI, Junie, JetBrains AI Assistant, Augment (Auggie CLI), Factory Droid, Kiro, Devin CLI +12

Values in angle brackets are placeholders. Restart Claude Desktop after editing its config.Claude Desktop docs

README

synced Oct 25, 2026

Context Mapper MCP Server

npm version License: MIT

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

Validation Features

The server validates models in real-time to prevent common CML errors:

ValidationWhenExample Error
Duplicate namesOn create'AgentId' already exists in ContextA...
Invalid typesOn createMap<K,V> is not supported in CML...
Reserved namesOn create'Resource' is a reserved keyword...
Reserved attributesOn saveAuto-escaped with ^ prefix

Valid Attribute Types

  • Primitives: String, int, long, boolean, DateTime, BigDecimal, UUID
  • Collections: 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@latest

Claude 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

ToolDescription
cml_create_modelCreate a new empty CML model
cml_load_modelLoad a CML file
cml_save_modelSave model to disk
cml_validate_modelValidate CML syntax and semantics
cml_get_model_infoGet model statistics

Query Tools

ToolDescription
cml_list_bounded_contextsList all bounded contexts
cml_get_bounded_contextGet context details
cml_list_aggregatesList aggregates (optionally filtered by context)
cml_get_aggregateGet aggregate with all its elements
cml_find_elementsSearch by name pattern (regex)
cml_list_relationshipsList context map relationships

Context Tools

ToolDescription
cml_create_context_mapCreate a context map
cml_create_bounded_contextCreate a bounded context
cml_update_bounded_contextUpdate a bounded context
cml_delete_bounded_contextDelete a bounded context

Aggregate Tools

ToolDescription
cml_create_aggregateCreate an aggregate
cml_update_aggregateUpdate an aggregate
cml_delete_aggregateDelete an aggregate
cml_add_entityAdd entity to aggregate
cml_add_value_objectAdd value object
cml_add_identifierAdd ID value object (DDD best practice)
cml_add_domain_eventAdd domain event
cml_add_commandAdd command
cml_add_serviceAdd domain service
cml_batch_add_elementsBatch create multiple domain objects in one call
cml_delete_entityDelete entity
cml_delete_value_objectDelete value object
cml_delete_domain_eventDelete domain event
cml_delete_commandDelete command
cml_delete_serviceDelete 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: false to collect all errors at once

Relationship Tools

ToolDescription
cml_create_relationshipCreate context map relationship
cml_update_relationshipUpdate relationship
cml_delete_relationshipDelete relationship
cml_get_relationshipGet 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

ToolDescription
cml_generate_context_map_diagramGenerate PlantUML context map
cml_generate_aggregate_diagramGenerate aggregate class diagram
cml_generate_full_diagramGenerate full model diagram
cml_generate_context_map_htmlGenerate an interactive HTML context map plus a linked canvas page per context

Bounded Context Canvas Tools

ToolDescription
cml_set_bounded_context_canvasSet canvas sections CML cannot express (strategic classification, domain roles, business decisions, assumptions, verification metrics, open questions, extra collaborators and terms)
cml_get_bounded_context_canvasGet a context's canvas in the DDD Crew canonical format (JSON or YAML)
cml_generate_bounded_context_canvasWrite canvases as HTML pages or as DDD Crew YAML for one or all contexts

Canvas sections are filled from the model where possible:

Canvas sectionDerived from
PurposedomainVisionStatement
Inbound / outbound communicationContext 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 languageAggregates, 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 test

Architecture

  • 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

↑↓ navigate openesc close