flow-diagram

flow-diagram

A flow diagram generator and MCP server that helps LLMs create better visuals using tools like create_diagram, add_node, add_edge, and visualize_diagram. It integrates with Cursor and outputs SVG, HTML, Mermaid, and more.

Category
访问服务器

README

Flow diagram generator and MCP

TypeScript Node.js OpenAI MCP

LLMs don't always generate the best flow diagrams. Use this MCP integration to build better visuals.

Features

  • Flow Diagram build functions
  • Server features powered by Express
  • MCP tools integration (including <list the specific MCP tools used, e.g. OpenAI, LangChain, etc.>)
  • Diagram visualization using Mermaid and other supported formats (SVG, HTML, JSON, text)
  • Testing powered by Jest

Quick Start

# Install dependencies
npm install

# Build the project
npm run build

# Run the demo
npm run demo

# Start the MCP server
npm run mcp:dev

Visual Comparison

See the difference between LLM-generated flow-chart and LLM + MCP-generated diagrams.

Built using the same prompt.

Can you make a complicated flow diagram for my adventure "choose your own adventure series". It should start at 1 place, then based on certain decisions, lead you down some paths. In the end, everything should lead you back to a single now.

Use whatever fantasy events you want to. Think "dungeons and dragons".

Generate an svg file [(WITHOUT)] using my flow-diagram mcp.

<table> <tr> <td width="50%" valign="top">

Brute-force SVG
(examples/adventure-flow.svg)

</td> <td width="50%" valign="top">

MCP-Generated SVG
(examples/dragon-slayer.svg)

</td> </tr> <tr> <td width="50%">

<img src="examples/adventure-flow.svg" alt="Adventure Flow - Manually Created" style="width: 100%; border: 1px solid #ddd; border-radius: 4px;"/>

</td> <td width="50%">

<img src="examples/dragon-slayer.svg" alt="Dragon Slayer - MCP Generated" style="width: 100%; border: 1px solid #ddd; border-radius: 4px;"/>

</td> </tr> </table>

Key Differences

Feature Brute-force SVG MCP-Generated
Dimensions Fixed at 1200x1400 Auto-calculated (2600x800)
Complexity ~140 lines of SVG Generated from ~35 nodes, 3 Tool Calls
Modification Manual SVG edits Modify via API
Scalability Manual scaling Automatic fitting
Maintenance High effort Low effort

The MCP-generated diagram automatically sizes to fit all content, while the manually created one uses fixed dimensions that may not accommodate future changes.

Basic Usage

import { createFlowDiagram, visualizeDiagram } from './src/index';

// Create a simple flow diagram
const diagram = createFlowDiagram({ title: 'My Process' });

// Add nodes
const startId = diagram.addNode({ 
  label: 'Start',
  type: 'start',
  style: { backgroundColor: '#e8f5e8' }
});

const processId = diagram.addNode({ 
  label: 'Process Data',
  type: 'process',
  style: { backgroundColor: '#e3f2fd' }
});

const endId = diagram.addNode({ 
  label: 'End',
  type: 'end',
  style: { backgroundColor: '#ffebee' }
});

// Add edges
diagram.addEdge({ sourceId: startId, targetId: processId });
diagram.addEdge({ sourceId: processId, targetId: endId });

// Auto-layout
diagram.autoLayout('hierarchical');

// Generate visualizations
const svg = visualizeDiagram(diagram, 'svg');
const mermaid = visualizeDiagram(diagram, 'mermaid');
const html = visualizeDiagram(diagram, 'html', { theme: 'dark' });

Helper Functions

import { FlowDiagramHelpers } from './src/index';

// Linear flow
const linearFlow = FlowDiagramHelpers.createLinearFlow([
  'Start', 'Process', 'Validate', 'End'
]);

// Decision tree
const decisionTree = FlowDiagramHelpers.createDecisionTree('User Login', [
  { condition: 'Valid?', next: 'Grant Access' },
  { condition: 'Invalid?', next: 'Show Error' }
]);

API Reference

Core Classes

  • FlowDiagram - Main class for managing nodes and edges
  • FlowDiagramHelpers - Utility functions for common patterns
  • FlowDiagramVisualizer - Generate visualizations in multiple formats

Key Methods

  • addNode(), addEdge() - Add elements to diagrams
  • autoLayout() - Automatic positioning
  • visualize() - Generate SVG, HTML, Mermaid, JSON, or text output
  • createLinearFlow(), createDecisionTree() - Helper functions

Development

npm install
npm run build
npm test
npm run demo

MCP Server

The library includes an MCP server for LLM integration.

Start Server

npm run mcp:dev

Server runs at http://localhost:3000 with these endpoints:

  • GET /health - Health check
  • GET /mcp/tools - List available tools
  • POST /mcp/tools/:toolName/execute - Execute tools

Available Tools

  • create_diagram, add_node, add_edge - Basic operations
  • visualize_diagram - Generate visualizations
  • create_linear_flow, create_decision_tree, create_process_flow - Helper functions
  • get_diagram_info, list_diagrams - Information queries

Cursor Integration

Add this to your Cursor MCP config:

macOS: ~/Library/Application Support/Cursor/User/globalStorage/cursor.mcp/config.json Windows: %APPDATA%\Cursor\User\globalStorage\cursor.mcp\config.json Linux: ~/.config/Cursor/User/globalStorage/cursor.mcp/config.json

{
  "mcpServers": {
    "flow-diagram": {
      "type": "http",
      "url": "http://localhost:3000",
      "headers": {
        "Content-Type": "application/json"
      }
    }
  }
}

Restart Cursor after updating the configuration.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选