DCI架构代码生成与重构工具

一个提供规范规则以生成或重构基于DCI架构代码的服务器,支持多种编程语言。

  • by ciscoheat
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 ciscoheat/dci-mcp

使用说明

dci-mcp

An MCP server that provides the normative rules needed to generate or refactor code using the DCI architecture. Refactoring tools return compact, machine-oriented rules by default; explanatory examples and the complete guide are opt-in.

Tools

Tool When to use
prepare_dci_refactor User wants to refactor existing code into DCI
scaffold_dci_from_mental_model User describes a mental model / user story and wants DCI code from scratch
get_dci_example A specific DCI implementation rule needs an example
get_dci_guide A human needs the complete DCI methodology

prepare_dci_refactor and scaffold_dci_from_mental_model accept a language argument (for example, "typescript") and an optional detail argument:

  • rules (default): concise JSON containing required rules, anti-patterns, and validation checks.
  • examples: targeted examples only; provide topics, such as ["role-contracts"].
  • full: the complete documentation, including explanations and examples.

Use rules before implementation. Request examples only when a concrete rule is ambiguous. get_dci_example requires language and one or more topics; get_dci_guide requires only language.

Supported languages

Each language has an explicit machine-readable ruleset. To add a language, add a folder under docs/ containing all three files:

docs/
  core.md              # DCI rules shared across all languages
  core-rules.json      # Machine-readable rules shared across all languages
  typescript/
    rules.json          # Language-specific rules and validation checks
    instructions.md
    examples.md
  javascript/
    rules.json
    instructions.md
    examples.md

core-rules.json and each language's rules.json must contain required and avoid string arrays, plus a validation array of { "id": string, "check": string } objects. The server merges the shared and language-specific rules for the requested language, and never falls back to another language. A tool call must provide a non-empty language value.

Usage in mcp.json (stdio)

"dci": {
  "command": "pnpx",
  "args": ["dci-mcp"]
}

Or with npx:

"dci": {
  "command": "npx",
  "args": ["-y", "dci-mcp"]
}

Development

pnpm version 11+ is required for development.

pnpm install
pnpm dev          # build + pnpm link (makes dci-mcp available globally)
pnpm inspector    # open MCP Inspector connected to the local server

After pnpm dev, the server is available as dci-mcp in your PATH and can be used in mcp.json outside this project while you iterate:

"dci": {
  "command": "dci-mcp"
}