BricsCAD

v0.2.0
io.github.alesdev88/bricscad-mcp Checked 17 hours ago Published 15 days ago

Read, audit, edit, plot and batch-process BricsCAD drawings.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

bricscad_audit_report

Report empty layers, unused blocks, missing xrefs, entities not at zero elevation, and off-standard layer names. Each section has a total `count` and up to `sample_limit` `items`. Blocks and layers used only inside other blocks count as used, and a dynamic block counts as used through its anonymous states. Layers 0 and Defpoints are never reported. allowed_layers: name patterns such as ["A-*", "S-*"], ignoring case. Leave it out to skip this check.

ParameterTypeDescription
allowed_layers
sample_limitinteger
timeoutnumber

bricscad_open_drawing

Open a DWG or DXF and make it the current drawing. Returns the same details as bricscad_drawing_info. path: full path to the file. read_only: true by default, so the file cannot be overwritten by accident. timeout: seconds to wait. Large drawings can take a while to open.

ParameterTypeDescription
path *string
read_onlyboolean
timeoutnumber

bricscad_close_drawing

Close the current drawing. Refuses if it has unsaved changes. discard: true closes it anyway and loses the unsaved changes.

ParameterTypeDescription
discardboolean

bricscad_drawing_info

Describe the current drawing: name, path, read-only and modified state, units, limits, entity count and layouts. extents and limits describe current_layout only, which may be a sheet rather than the model.

bricscad_list_layers

List layers with their on, frozen and locked state, color, linetype and entity count. Up to 2000 per call.

ParameterTypeDescription
limitinteger
offsetinteger
timeoutnumber

bricscad_list_blocks

List block definitions with insert counts, including nested inserts and inserts of dynamic blocks. Up to 2000 per call. include_anonymous: also list the anonymous blocks, such as *U12, that hold a dynamic block's states.

ParameterTypeDescription
include_anonymousboolean
limitinteger
offsetinteger
timeoutnumber

bricscad_list_xrefs

List external references with their stored path and whether the file was found. Up to 2000 per call.

ParameterTypeDescription
limitinteger
offsetinteger
timeoutnumber

bricscad_list_layouts

List Model and the paper space layouts with their entity counts. Up to 2000 per call.

ParameterTypeDescription
limitinteger
offsetinteger
timeoutnumber

bricscad_query_entities

Find entities in the current drawing. Returns handle, type, layer, layout and bounding box. Up to 2000 per call. types: DXF names such as ["LINE", "CIRCLE"]. layer, block: names, which may use the wildcards * and ?. A dynamic block goes by its own name. bbox: [min_x, min_y, max_x, max_y]; entities overlapping it match. layout: "Model" or a layout name. An entity with no extent, such as an insert of an empty block, returns a null bounding box.

ParameterTypeDescription
bbox
block
layer
layout
limitinteger
offsetinteger
timeoutnumber
types

bricscad_get_entity

Return one entity's type, layer and all its DXF group codes, as [code, value] pairs.

ParameterTypeDescription
handle *string

bricscad_read_attributes

Read attribute values from block inserts, for example title block contents. Up to 2000 per call. block: a block name, which may use the wildcards * and ?. A dynamic block goes by its own name. layout: "Model" or a layout name.

ParameterTypeDescription
block
layout
limitinteger
offsetinteger
timeoutnumber

bricscad_find_text

Search TEXT, MTEXT, MULTILEADER, table cell and block attribute text for literal text. A table cell comes back with its table's handle and position, plus its row and column. Up to 2000 per call.

ParameterTypeDescription
query *string
case_sensitiveboolean
limitinteger
offsetinteger
timeoutnumber

bricscad_undo

Undo the last edits to the current drawing. Returns how many steps were undone. One step is one successful edit tool call. Edits made through bricscad_run_lisp have no step of their own, so they go back with the step before them. steps: how many steps to undo, from 1 to 100. It stops at the oldest step.

ParameterTypeDescription
stepsinteger
timeoutnumber

bricscad_erase_entities

Erase entities by handle. Erases all of them or none. bricscad_undo restores them. Refuses entities on locked layers and attributes, which belong to their block insert.

ParameterTypeDescription
handles *array
timeoutnumber

bricscad_set_layer

Create a layer, or change one that exists. Only the values you give are changed. new_name: rename the layer. Layers 0 and Defpoints cannot be renamed. color: a color number from 1 to 255. linetype: loaded from iso.lin if the drawing does not have it yet. on, frozen, locked: true or false. The current layer cannot be frozen.

ParameterTypeDescription
name *string
color
frozen
linetype
locked
new_name
on
timeoutnumber

bricscad_modify_entities

Change entities by handle. Changes all of them or none, and refuses locked layers. move: a displacement, [dx, dy] or [dx, dy, dz]. rotate: {"angle": degrees, "base": point}. scale: {"factor": number above 0, "base": point}. layer: an existing layer. color: 0 by block, 1 to 255, or 256 by layer. linetype: loaded from iso.lin if the drawing does not have it yet. text: new text for TEXT, MTEXT or MULTILEADER. Change attributes with bricscad_set_attributes. MTEXT and MULTILEADER text takes format codes, where \P is a line break. Write a literal backslash or brace a…

ParameterTypeDescription
handles *array
color
layer
linetype
move
rotate
scale
text
timeoutnumber

bricscad_set_attributes

Set attribute values on block inserts, such as a title block. Changes all of them or none. updates: [{"handle": insert handle, "values": {tag: text}}]. Get handles and tags from bricscad_read_attributes. Tags match whatever their case.

ParameterTypeDescription
updates *array
timeoutnumber

bricscad_create_entities

Draw entities and return their handles. Draws all of them or none, as one undo step. entities: up to 2000 items, each with a type and an optional layer, which must exist. Points are [x, y] or [x, y, z]. Angles are degrees. layout: a sheet name. The default is the model, whichever tab is current. MTEXT takes format codes, where \P is a line break. Write a literal backslash or brace as \\, \{ or \}.

ParameterTypeDescription
entities *array
layout
timeoutnumber

bricscad_save_drawing

Save the current drawing. Returns the same details as bricscad_drawing_info. path: a new .dwg path. The drawing then continues under that name, and is no longer read-only. Leave it out to save over the open file, which needs overwrite=true. overwrite: true allows replacing an existing file. BricsCAD leaves a .bak beside it. A read-only drawing cannot be saved over its own file, and a file open as another drawing cannot be replaced.

ParameterTypeDescription
overwriteboolean
path
timeoutnumber

bricscad_export_dxf

Write the current drawing as a DXF file. The drawing keeps its name and state. path: a .dxf file in an existing folder. It cannot be an open drawing. version: DXF version, R12 or 2000 to 2018. overwrite: true allows replacing an existing file. It is replaced only once the new one is complete.

ParameterTypeDescription
path *string
overwriteboolean
timeoutnumber
versionstring

bricscad_plot_pdf

Plot one layout of the current drawing to a PDF file, with Print As PDF.pc3. The drawing is not changed. path: a .pdf file in an existing folder. layout: "Model" or a sheet name. Defaults to the current layout. paper: BricsCAD's paper name, such as "ISO A3 (297.00 x 420.00 MM)". Defaults to the layout's current size. landscape: true or false. Defaults to the layout's current orientation. area: "extents", "layout" (sheets only) or "window". Defaults to extents for the model and layout for sheets. window: [x1, y1, x2, y2] in drawing units, with area="window". scale:…

ParameterTypeDescription
path *string
area
landscape
layout
overwriteboolean
paper
scale
style_table
timeoutnumber
window

bricscad_preview_image

Return a PNG of the current drawing, to check work by eye. The drawing is not changed. layout: "Model" or a sheet name. Defaults to the current layout. The whole layout is shown. window: [x1, y1, x2, y2] in drawing units, to show only that area. The image is the size of the BricsCAD window. The model shows on black, as on screen.

ParameterTypeDescription
layout
timeoutnumber
window

bricscad_batch_run

Run one job on many drawings, one at a time, and report a result per file. Try dry_run first. job: {"type": ...} with its options. audit and find_text write nothing. export_dxf, plot_pdf (layout "*" plots every sheet to <name>-<sheet>.pdf), save_as and lisp with save=true write <name>.dxf, .pdf or .dwg into output_folder. lisp runs code in each drawing and returns its value. files or folder: the drawings, up to 500. folder takes a glob pattern, and recursive for subfolders. Sources open read-only. A source is replaced only when output_folder is its own folder and overw…

ParameterTypeDescription
job *
dry_runboolean
files
folder
output_folder
overwriteboolean
patternstring
recursiveboolean
timeoutnumber

bricscad_list_versions

List the BricsCAD versions installed on this computer, newest first.

bricscad_start

Start BricsCAD in its own window and connect to it. Refuses if that version is already running. version: for example "26". Defaults to BRICSCAD_VERSION, then the newest installed.

ParameterTypeDescription
version

bricscad_stop

Close the BricsCAD this server started. Refuses if drawings have unsaved changes. discard: true closes it anyway and loses the unsaved changes.

ParameterTypeDescription
discardboolean

bricscad_status

Report whether BricsCAD is running, how recently its listener reported, and the current drawing.

bricscad_run_lisp

Run LISP in BricsCAD and return the value of its last expression. LISP can change or delete files and start programs, so use a dedicated tool where one exists. Do not use vla-save or vla-saveas: they open a dialog or fail. Use _.QSAVE or _.SAVEAS. Do not close the only open drawing: the listener stops. code: one or more LISP expressions. timeout: seconds to wait for an answer.

ParameterTypeDescription
code *string
timeoutnumber