mcpField
F
Figcraft - Code-driven SVG Diagram Generator

Figcraft - Code-driven SVG Diagram Generator

本地服务
github.com/zeqinlee开发工具2838 周前更新

关于 Figcraft - Code-driven SVG Diagram Generator

Figcraft 是面向 TypeScript/Node.js 开发者的代码绘图库,可创建架构图、流程图和神经网络图。它提供布局辅助,并支持导出多种图像和文档格式。

主要功能

  1. 01十种图形元素
  2. 02可自定义箭头样式
  3. 03行、列、网格和分组布局
  4. 04支持 Markdown 标签
  5. 05导出 SVG、PNG、JPG、WebP 和 PDF

适用场景

  1. 01用代码创建架构图
  2. 02自动排列流程图元素
  3. 03将图表导出为图像或 PDF

MCP 相关

Figcraft 通过 `figcraft-mcp` 提供 MCP 集成,允许 AI Agent 根据自然语言描述生成图表。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"figcraft": {
"command": "npx",
"args": [
"-y",
"figcraft-mcp"
]
}
}
}
启动命令npx -y figcraft-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmfigcraft-mcp

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

Figcraft 徽标

Figcraft

面向 TypeScript / Node.js 的代码驱动 SVG 图表库

由 XFlow 开发 · 编写几行 TypeScript,即可生成适合出版的架构图。

npm version license node PRs Welcome

网站 · 文档 · 安装 · GitHub


Transformer 架构图
CNN 图像分类流程

亮点

功能
10 种形状rect、circle、diamond、trapezoid、text、image、cylinder、cuboid、sphere、stack2D + 3D
11 种箭头样式triangle、stealth、vee、circle、diamond、bar、dot + 开放式变体完全可自定义
智能布局row() col() grid() group()自动对齐
Markdown 标签**bold** *italic* `code` $math$适用于任何元素
多种格式SVG、PNG、JPG、WebP、PDFfit 自动裁剪
MCPAI Agent 通过自然语言生成图表Claude / Cursor
无需浏览器完全在 Node.js 中运行可用于服务端

安装

npm install figcraft        # npm
pnpm add figcraft           # pnpm
yarn add figcraft           # yarn

需要 Node.js 18+

快速开始

import { Figure } from 'figcraft'

const fig = new Figure(800, 400, { bg: '#fff' })

const a = fig.rect('Input', {
  pos: [50, 100], size: [120, 50],
  fill: '#e3f2fd', radius: 6
})

const b = fig.rect('Output', {
  pos: [250, 100], size: [120, 50],
  fill: '#c8e6c9', radius: 6
})

fig.arrow(a, b, { head: 'stealth', label: 'data' })

await fig.export('diagram.svg', { fit: true, margin: 20 })
npx tsx diagram.ts

元素

类型方法描述
矩形fig.rect()圆角矩形
圆形fig.circle()圆形
菱形fig.diamond()决策节点
梯形fig.trapezoid()池化 / 降维
文本fig.text()Markdown 文本标签
图像fig.image()嵌入式图像
圆柱体fig.cylinder()3D 圆柱体(数据库)
长方体fig.cuboid()3D 长方体(张量)
球体fig.sphere()3D 球体
堆栈fig.stack()多层堆栈

箭头

fig.arrow(a, b)                                      // default
fig.arrow(a, b, { head: 'stealth', color: '#1565c0' }) // styled

// Anchors
fig.arrow(a, b, { from: 'right', to: 'left' })
fig.arrow(a, b, {
  from: { side: 'bottom', at: 30 },
  to: { side: 'top', at: 70 }
})

// Paths
fig.arrow(a, b, { path: 'curve', curve: 40 })
fig.arrow(a, b, { path: 'polyline', cornerRadius: 8 })

// Styles
fig.arrow(a, b, { style: 'dashed', bidirectional: true })

// Fan & Fork
fig.arrows(src, [a, b, c], { head: 'stealth' })  // fan-out
fig.fork(src, [a, b, c], { head: 'stealth' })     // shared trunk

布局

fig.row([a, b, c], { gap: 40 })            // horizontal
fig.col([a, b, c], { gap: 30 })            // vertical
fig.grid([a, b, c, d, e, f], { cols: 3 })  // grid
fig.group([a, b, c], { label: 'Pipeline' }) // group box

导出

await fig.export('out.svg')                           // SVG vector
await fig.export('out.png', { fit: true, scale: 3 })  // high-res PNG
await fig.export('out.jpg', { quality: 95 })           // JPEG
await fig.export('out.webp')                           // WebP
await fig.export('out.pdf')                            // PDF

const svg = fig.render({ fit: true })                  // SVG string

MCP 集成

让 AI Agent 为你创建图表。将其添加到 Claude Code 或 Cursor 配置中:

{
  "mcpServers": {
    "figcraft": {
      "command": "npx",
      "args": ["figcraft-mcp"]
    }
  }
}

然后只需用自然语言描述你的需求。

参与贡献

欢迎贡献!你可以随时提交 issue 或发起 pull request。

链接

许可证

MIT — 由 XFlow 制作

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。