Skip to main content
Glama

Add Surface Element

add_surface_element

Add shapes, connectors, text, or groups to an AFFiNE edgeless canvas to build diagrams programmatically, including styled elements and arrows between shapes.

Instructions

Add a shape, connector, text, or group to the AFFiNE edgeless canvas surface. Shapes support rect/ellipse/diamond/triangle with fill, stroke, and text. Connectors draw arrows between shapes (by id) or between absolute points. Use for building diagrams programmatically. Style fields that don't apply to the chosen element type are reported in the response 'ignored' list (mirrors update_surface_element).

Input Schema

NameRequiredDescriptionDefault
xNoX position on canvas (shape/text; default 0).
yNoY position on canvas (shape/text; default 0).
modeNoConnector mode: 0=straight, 1=orthogonal (elbow), 2=curve (default 2). Connector only.
textNoText content (shape/text) or connector label. Replaces existing Y.Text on update.
typeYesElement type
colorNoText color. Shape default `#000000` — keep unless the fill is dark, then pass a contrasting hex. Canvas text default `--affine-text-primary-color` (theme-adaptive). Shape/text.
docIdYesDocument ID
indexNoBlockSuite fractional-index string controlling z-order. On add, defaults to a key above every existing element's index (new elements render on top). On update, replaces the stored value — pass a key less than some existing index to send-to-back, or greater to bring-to-front. Use the value returned by list_surface_elements to pick a specific position.
labelNoConnector label (stored as text on the connector). Connector only.
titleNoGroup title. Group only.
widthNoWidth (shape default 100, text default 200).
filledNoWhether shape is filled (default true). Shape only.
heightNoHeight (shape default 100, text default 30).
radiusNoCorner radius for rect (0.1 = rounded). Shape only.
strokeNoConnector stroke color (default '--affine-text-primary-color' — theme-adaptive, near-black in light / near-white in dark). Accepts any CSS color or AFFiNE palette token. Connector only.
childrenNoChild element ids. Group only.
fontSizeNoFont size (shape default 20, text default 16). Shape/text.
sourceIdNoConnector source element id. Connector only.
targetIdNoConnector target element id. Connector only.
fillColorNoFill color. Prefer the `--affine-palette-shape-<color>` family (yellow/orange/red/magenta/purple/navy/blue/green/teal/grey/white/black). These are fixed colors — AFFiNE shape colors are not theme-adaptive by design. Shape only.
shapeTypeNoShape type (default rect). Shape only.
fontWeightNoFont weight (shape default 600, text default 400). Shape/text.
strokeColorNoStroke color. Prefer the `--affine-palette-line-<color>` family (same color names as fillColor). Fixed colors, not theme-adaptive. Shape only.
strokeStyleNoStroke style. Shape/connector.
strokeWidthNoStroke width (default 2). Shape/connector.
workspaceIdNoWorkspace ID (optional if default set)
sourcePositionNoSource [x,y]: relative [0-1] if sourceId set, absolute otherwise. Connector only.
targetPositionNoTarget [x,y]: relative [0-1] if targetId set, absolute otherwise. Connector only. When both source/target are bound by id and neither position is provided, endpoints snap to the BlockSuite side-midpoint facing the other endpoint so connectors flow in a clear direction. Pass [0.5,0] top, [0.5,1] bottom, [0,0.5] left, [1,0.5] right to force a specific side.
expectedRevisionNoOptional read_doc revision of this primary document. Reject stale content before writing. Covers document content, not workspace metadata; requires all writers to share one MCP server.
rearEndpointStyleNoRear endpoint style (default Arrow). Connector only.
frontEndpointStyleNoFront endpoint style (default None). Connector only.

Output Schema

NameRequiredDescriptionDefault
okNo
codeNo
typeNo
addedNo
errorNo
detailsNo
ignoredNo
causeCodeNo
elementIdNo
retryableNo
surfaceBlockIdNo
recoveryGuidanceNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv3.10.2

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly=false, destructive=false, idempotent=false, so safety is covered; the description adds a genuinely non-obvious behavioral fact: inapplicable style fields are echoed back in a response 'ignored' list. It stops short of noting that the operation is non-idempotent (repeated calls create duplicates) or what permissions/docId scope are needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four short sentences, front-loaded with the core action, then element capabilities, use case, and the ignored-field caveat. No filler, though the parenthetical '(mirrors update_surface_element)' is slightly cryptic without direct routing language.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 31 parameters and an output schema; the description defers parameter specifics to the (fully documented) schema and to the output schema for the 'ignored' list, which is appropriate. Missing is any note that this is a non-idempotent create (duplicate calls duplicate elements) or how docId/workspaceId must line up.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3; the description earns one more by explaining connector binding semantics ('draw arrows between shapes (by id) or between absolute points') and which style families apply per element type, which reinforces how sourceId/targetId vs sourcePosition/targetPosition are chosen.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb and resource ('Add a shape, connector, text, or group to the AFFiNE edgeless canvas surface') and enumerates the element kinds, so an agent immediately knows the scope. It also implicitly separates itself from update_surface_element by noting the 'ignored' report 'mirrors update_surface_element'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'Use for building diagrams programmatically' gives a context cue, but there is no explicit when-not guidance or directive such as 'to modify an existing element use update_surface_element' / 'to inspect use list_surface_elements'. The routing to siblings is left to be inferred from the mention of the mirror behavior.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools