chartici-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # chartici-mcp
2
+
3
+ MCP server for [Chartici](https://chartici.com) — professional diagrams from a single AI prompt.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npx -y chartici-mcp@latest
9
+ ```
10
+
11
+ ## Connect to Claude Desktop
12
+
13
+ Settings → Developer → Edit Config:
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "chartici": {
19
+ "command": "npx",
20
+ "args": ["-y", "chartici-mcp@latest"]
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Restart Claude. Then just say:
27
+
28
+ > "Draw an org chart for my company"
29
+
30
+ ## Works With
31
+
32
+ - **Claude Desktop**
33
+ - **ChatGPT** (via MCP bridge)
34
+ - **Gemini / Google AI Studio**
35
+ - **DeepSeek**
36
+ - **Cursor, Windsurf, Cline**, and any MCP-compatible client
37
+
38
+ ## What It Does
39
+
40
+ Your AI reads the Chartici format spec automatically and generates `.cci` diagram files. Supports: flowcharts, org charts, ERDs, sequence diagrams, mind maps, timelines, matrices.
41
+
42
+ ## Author
43
+
44
+ [Sergey Zorin](https://www.linkedin.com/in/sfzorin/)
45
+
46
+ ## License
47
+
48
+ MIT
package/docs_guide.md ADDED
@@ -0,0 +1,144 @@
1
+ # AI Agent Implementation Guide
2
+
3
+ > **Author:** [Sergey Zorin](https://www.linkedin.com/in/sfzorin/)
4
+
5
+ **CHARTICI** is a **Declarative Diagramming Engine** driven by algorithms. The user (or AI) provides unstructured or semi-structured data (Nodes and Connections), and Chartici's engine automatically computes their optimal grid coordinates, aligning them into beautiful, deterministic, non-intersecting layouts.
6
+
7
+ ### Core Philosophy
8
+ - **Deterministic Math**: There is no manual dragging of connection lines. Every route between nodes is calculated using a specialized Orthogonal A* Pathfinding algorithm to guarantee perfect 20px grid alignment, shared trunks, and rounded corners.
9
+ - **Auto-Formatting**: The engine supports various structural aspect ratios (e.g., `16:9 Landscape`, `9:16 Vertical`). Flow direction adjusts automatically based on the chosen format or cluster complexity.
10
+ - **Design Tokens**: Node colors, borders, and styles are controlled by centralized numerical color palettes. You simply assign an integer `color` token (`1` through `9` for solid fill colors) and the engine gracefully translates them into accessible, curated CSS palettes like `vibrant-rainbow` or `blue-teal-slate`.
11
+
12
+ ---
13
+
14
+ ## File Format (`.cci`)
15
+
16
+ The system operates exclusively on the `.cci` file format. This is a strict **JSON** schema containing all data necessary for rendering.
17
+
18
+ ### Global Structure
19
+
20
+ ```json
21
+ {
22
+ "type": "cci_project",
23
+ "title": "My Architecture Diagram",
24
+ "aspect": "16:9",
25
+ "diagramType": "flowchart",
26
+ "theme": "blue-teal-slate",
27
+ "data": {
28
+ "groups": [ ... ],
29
+ "edges": [ ... ]
30
+ }
31
+ }
32
+ ```
33
+
34
+ - **`title`**: The main title of the diagram that will be automatically centered at the top.
35
+ - **`aspect`**: Defines the bounding box of the graphic. Valid options: `"16:9"`, `"4:3"`, `"1:1"`, `"3:4"`, `"9:16"`.
36
+ - **`theme`**: Defines the overall visual color palette. Valid options: `"muted-rainbow"`, `"vibrant-rainbow"`, `"grey"`, `"red"`, `"green"`, `"blue"`, `"brown"`, `"purple"`, `"blue-orange"`, `"green-purple"`, `"slate-rose"`, `"blue-teal-slate"`, `"indigo-green-red"`, `"brown-amber-grey"`.
37
+ - **`diagramType`**: **CRITICAL PARAMETER.** Defines the logical behavior and heuristic rules of the auto-layouter. Must be one of the following exact strings:
38
+ - `"flowchart"`: Maps step-by-step processes or algorithms. Uses Diamonds (decisions) and Rectangles (tasks). Arrows show paths based on outcomes. The engine uses Happy Path optimization to align the primary process flow into a straight axis.
39
+ - `"tree"`: General core type for ALL hierarchical layouts, including Org Charts, Decision Trees, Concept Maps, and File Systems. The layout engine will mathematically branch them out from the root efficiently without process-flow logic. **Dense fan-outs** (>4 leaf children) are automatically stacked vertically with a shared bus trunk for compact layouts.
40
+ - `"sequence"`: Forces strict vertical alignment. Shows interactions over time (vertical lifelines).
41
+ - `"erd"`: **Entity-Relationship Diagram (ERD)**. Used heavily in software engineering to map out static data architecture explicitly without any implied chronological flow. Maps structured relationships (e.g., "1 User has N Orders").
42
+ - `"radial"`: **Radial / Mind Map.** A central hub node with spokes radiating outward. The engine uses straight diagonal lines (not orthogonal routing) with arrowheads. It automatically identifies the most-connected node as the root and arranges all neighbors in concentric rings. Ideal for brainstorming, concept exploration, stakeholder maps, and single-level mind maps. Supports 2+ levels of nesting (inner ring → outer ring). Edge labels are always oriented for readability (never upside-down).
43
+ - `"timeline"`: **Timeline / Roadmap.** Nodes are arranged along a linear axis in topological order (based on edge connections). Even/odd nodes alternate above and below the baseline for readability. Best for project roadmaps, historical timelines, release planning, and any sequential-but-not-branching data. Flow direction adapts to aspect ratio (horizontal for 16:9, vertical for 9:16).
44
+ - `"matrix"`: **Matrix / Grid.** Nodes are organized into a spatial grid based on their groups. Each group occupies one cell of the grid (2 groups → 2×1, 4 groups → 2×2, 9 groups → 3×3). Perfect for SWOT analysis, priority matrices (urgent/important), product positioning maps, and any 2D categorical classification. If no groups exist, all nodes are laid out in a flat grid.
45
+
46
+ ### Groups Array (Contains Nodes)
47
+
48
+ Chartici is fundamentally built around grouping. Instead of a flat list of nodes, nodes are nested inside Groups. A Group represents a boundary, system, or cluster.
49
+
50
+ ```json
51
+ {
52
+ "id": "Backend Services",
53
+ "color": 3,
54
+ "type": "rect",
55
+ "size": "L",
56
+ "nodes": [
57
+ {
58
+ "id": "api_gw",
59
+ "text": "API Gateway"
60
+ },
61
+ {
62
+ "id": "db_main",
63
+ "text": "PostgreSQL"
64
+ }
65
+ ]
66
+ }
67
+ ```
68
+
69
+ - **`id`**: Unique string identifier for the group.
70
+ - **`type`**: The graphical shape of the item. Valid options: `"rect"` (default rectangle), `"circle"`, `"decision"` (diamond), `"oval"` (pill shape).
71
+ - **`color`**: Styling for the group itself. These styles **cascade** down and bind the `nodes` inside it. A node inside a group cannot have a uniquely different color or type than the group!
72
+ - **`outlined`**: (Optional, boolean) When `true`, nodes in this group render as outlined (border only, transparent fill) instead of solid fill. Useful for secondary/supporting elements.
73
+ - **`size`**: Defines the physical geometric scale of nodes (based on strict grid heights). Valid options: `"S"` (Base Height: 40px), `"M"` (Base Height: 80px), `"L"` (Base Height: 120px), `"XL"` (Base Height: 160px). True widths are dynamic based on the node `type` (e.g. Circles are symmetrical, Text nodes auto-wrap).
74
+ - **`nodes`**: Array of individual entities inside this group.
75
+ - **`id`**: (Required) Unique identifier across the entire diagram.
76
+ - **`text`**: (Optional) The display label inside the node. (Alias: `label`).
77
+
78
+ **Note on Positioning:** The Heuristic Layout Engine completely calculates `x` and `y` coordinates to ensure pixel-perfect grids. Do not attempt to calculate coordinates mathematically yourself.
79
+
80
+ ### Edges Array
81
+
82
+ Edges define the connections (arrows) between nodes.
83
+
84
+ ```json
85
+ {
86
+ "id": "e1",
87
+ "sourceId": "api_gw",
88
+ "targetId": "db_main",
89
+ "label": "Fetch User Data",
90
+ "lineStyle": "solid",
91
+ "arrowType": "target"
92
+ }
93
+ ```
94
+
95
+ - **`id`**: Unique string for the edge.
96
+ - **`sourceId`**: The `id` of the originating Node. (Alias: `from`).
97
+ - **`targetId`**: The `id` of the destination Node. (Alias: `to`).
98
+ - **`label`**: (Optional) Text that floats along the path. **CRITICAL:** Keep labels EXTREMELY short (1-3 words max). Long edge labels will cause layout bugs, overlap issues, and will be aggressively truncated. Use short verbs like "Fetches", "Syncs", "Validates".
99
+ - **`lineStyle`**: `"solid"` (default), `"dashed"`, `"dotted"`, `"bold"`, `"bold-dashed"`.
100
+ - **`connectionType`**: `"target"` (default, →), `"both"` (↔), `"none"` (—), or ERD crow's foot: `"1:1"`, `"1:N"`, `"N:1"`, `"N:M"`.
101
+
102
+ ---
103
+
104
+ ## Agentic Operations & Rules
105
+
106
+ When an AI Agent is tasked with creating or modifying a Chartici diagram, it **MUST** follow these critical rules:
107
+
108
+ 1. **Prioritize Structural Grouping**: Do not attempt to calculate coordinates mathematically yourself. Instead, use nested `nodes` arrays inside `groups`! If you want a row of icons underneath the CEO, place them all inside a single group `{ "id": "ExecTeam", "nodes": [...] }`. When rendered, the engine will permanently lock them into a stunning grid array.
109
+
110
+ 2. **Assign Logical Semantic Colors by Index**: In enterprise architecture, color is information. Use color index `1-9` for distinct core systems. **Do not use words like "blue" or "red". ONLY use integers (1-9). Do not use index 10.**
111
+
112
+ 3. **Aspect Ratios Dictate Flow**:
113
+ - If an agent generates a long list of sequentially connected nodes, tell the user to use the `"9:16"` aspect ratio (Top-Down Flow).
114
+ - If the architecture is broad (one API gateway pointing to 15 microservices), suggest `"16:9"` (Left-to-Right Flow).
115
+
116
+ 4. **JSON Purity**: ALWAYS ensure the output `.cci` file is mathematically valid JSON. Removing a trailing comma or using unescaped quotes in the `label` parameter will crash the drawing engine. Ensure `source` and `target` in the Edges always match an existing Node `id`.
117
+
118
+ 5. **ERD Cardinality**: Always use `connectionType` with crow's foot notation (`"1:N"`, `"N:M"`, etc.) for ERD diagrams instead of arrows. This communicates relationship semantics precisely.
119
+
120
+ 6. **Tree Dense Fan-Outs**: The engine automatically stacks >4 leaf children vertically (max 6 per column). This means you can safely connect 10+ children to a single parent — the layout will remain compact.
121
+
122
+ ---
123
+
124
+ ## MCP Integration
125
+
126
+ Chartici includes a **Model Context Protocol (MCP)** server that allows AI assistants (Claude, etc.) to render diagrams directly.
127
+
128
+ ### Available Tools
129
+ - **`render_diagram`** — Takes `.cci` JSON, runs the full layout + routing engine, and returns a complete SVG image.
130
+ - **`save_diagram`** — Saves a `.cci` file to disk.
131
+ - **`list_samples`** / **`read_sample`** — Browse and read example diagrams for reference.
132
+
133
+ ### Setup (Claude Desktop)
134
+ Add to `claude_desktop_config.json`:
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "chartici": {
139
+ "command": "npx",
140
+ "args": ["tsx", "/path/to/chartici/mcp-server.mjs"]
141
+ }
142
+ }
143
+ }
144
+ ```
package/index.mjs ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Chartici MCP Server
4
+ *
5
+ * AI-powered diagram rendering via Model Context Protocol.
6
+ * Exposes the Chartici .cci format spec and save tool to AI assistants.
7
+ *
8
+ * Usage: npx chartici-mcp
9
+ */
10
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
11
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
12
+ import { z } from "zod";
13
+ import fs from "fs";
14
+ import path from "path";
15
+ import { fileURLToPath } from "url";
16
+
17
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
18
+ const docsPath = path.join(__dirname, "docs_guide.md");
19
+
20
+ const server = new McpServer({
21
+ name: "chartici",
22
+ version: "1.0.0",
23
+ });
24
+
25
+ // ─── Resource: Docs ──────────────────────────────────────────
26
+ server.resource(
27
+ "docs",
28
+ "chartici://docs",
29
+ {
30
+ description: "Chartici .cci format specification — diagram types, design tokens, node/edge schema. Read this before generating any diagram.",
31
+ mimeType: "text/markdown"
32
+ },
33
+ async () => ({
34
+ contents: [{
35
+ uri: "chartici://docs",
36
+ mimeType: "text/markdown",
37
+ text: fs.readFileSync(docsPath, "utf-8")
38
+ }]
39
+ })
40
+ );
41
+
42
+ // ─── Tool: Save Diagram ──────────────────────────────────────
43
+ server.tool(
44
+ "save_diagram",
45
+ "Save a Chartici .cci diagram to a file. Generate the .cci JSON following the format from the chartici://docs resource, then save it with this tool. The user can open the file in Chartici (chartici.com) to render it.",
46
+ {
47
+ filename: z.string().describe("Filename without extension, e.g. 'my_org_chart'"),
48
+ content: z.string().describe("Complete .cci JSON content as a string"),
49
+ directory: z.string().optional().describe("Save directory path. Defaults to current directory.")
50
+ },
51
+ async ({ filename, content, directory }) => {
52
+ try {
53
+ const parsed = JSON.parse(content);
54
+ const pretty = JSON.stringify(parsed, null, 2);
55
+ const dir = directory || process.cwd();
56
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
57
+ const safeName = filename.replace(/[^a-zA-Z0-9_\-]/g, '_');
58
+ const filePath = path.join(dir, `${safeName}.cci`);
59
+ fs.writeFileSync(filePath, pretty, 'utf-8');
60
+ return {
61
+ content: [{ type: "text", text: `✅ Saved: ${filePath}\n\nOpen chartici.com and paste this file's contents to render.` }]
62
+ };
63
+ } catch (e) {
64
+ return { content: [{ type: "text", text: `❌ Error: ${e.message}` }] };
65
+ }
66
+ }
67
+ );
68
+
69
+ // ─── Start ───────────────────────────────────────────────────
70
+ async function main() {
71
+ const transport = new StdioServerTransport();
72
+ await server.connect(transport);
73
+ console.error("🎨 Chartici MCP Server running");
74
+ }
75
+
76
+ main().catch(console.error);
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "chartici-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for Chartici — AI-powered diagram rendering. One prompt, professional diagrams.",
5
+ "keywords": ["mcp", "diagram", "ai", "svg", "chartici", "flowchart", "erd", "org-chart", "claude", "chatgpt", "gemini"],
6
+ "author": "Sergey Zorin",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "bin": {
10
+ "chartici-mcp": "./index.mjs"
11
+ },
12
+ "files": [
13
+ "index.mjs",
14
+ "docs_guide.md",
15
+ "README.md"
16
+ ],
17
+ "dependencies": {
18
+ "@modelcontextprotocol/sdk": "^1.29.0",
19
+ "zod": "^3.24.4"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/sfzorin/chartici"
24
+ },
25
+ "homepage": "https://chartici.com"
26
+ }