JSON画布
STDIO创建和处理无限画布数据的服务器
创建和处理无限画布数据的服务器
A Model Context Protocol (MCP) server implementation that provides tools for working with JSON Canvas files according to the official specification. This server enables creating, modifying, and validating infinite canvas data structures.
The JSON Canvas MCP server provides a complete implementation of the JSON Canvas 1.0 specification, enabling:
The server exposes the following resources:
canvas://schema
: JSON Schema for validating canvas filescanvas://examples
: Example canvas files demonstrating different featurescanvas://templates
: Templates for creating new canvasescreate_node
type
(string): Node type ("text", "file", "link", "group")properties
(object): Node-specific properties
id
, x
, y
, width
, height
, color
text
, file
, url
, etc.update_node
id
(string): Node ID to updateproperties
(object): Properties to updatedelete_node
id
(string): Node ID to deletecreate_edge
id
(string): Unique edge identifierfromNode
(string): Source node IDtoNode
(string): Target node IDfromSide
(optional string): Start side ("top", "right", "bottom", "left")toSide
(optional string): End sidecolor
(optional string): Edge colorlabel
(optional string): Edge labelupdate_edge
id
(string): Edge ID to updateproperties
(object): Properties to updatedelete_edge
id
(string): Edge ID to deletevalidate_canvas
canvas
(object): Canvas data to validateexport_canvas
format
(string): Target format ("json", "svg", "png")canvas
(object): Canvas data to exportAdd this to your claude_desktop_config.json
:
{ "mcpServers": { "jsoncanvas": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "canvas-data:/data", "mcp/jsoncanvas" ], "env": { "OUTPUT_PATH": "/data/output" } } } }
{ "mcpServers": { "jsoncanvas": { "command": "uv", "args": [ "--directory", "/path/to/jsoncanvas", "run", "mcp-server-jsoncanvas" ], "env": { "OUTPUT_PATH": "./output" } } } }
The server can be configured using environment variables:
OUTPUT_PATH
: Directory where canvas files will be saved (default: "./output")FORMAT
: Default output format for canvas files (default: "json")docker build -t mcp/jsoncanvas .
# Install uv if not already installed curl -LsSf https://astral.sh/uv/install.sh | sh # Create virtual environment and install dependencies uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate uv pip install -e . # Run tests pytest
from jsoncanvas import Canvas, TextNode, Edge # Create nodes title = TextNode( id="title", x=100, y=100, width=400, height=100, text="# Hello Canvas\n\nThis is a demonstration.", color="#4285F4" ) info = TextNode( id="info", x=600, y=100, width=300, height=100, text="More information here", color="2" # Using preset color ) # Create canvas canvas = Canvas() canvas.add_node(title) canvas.add_node(info) # Connect nodes edge = Edge( id="edge1", from_node="title", to_node="info", from_side="right", to_side="left", label="Connection" ) canvas.add_edge(edge) # Save canvas canvas.save("example.canvas")
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.