picogk

MoonBit SDK for the PicoGK MCP geometry kernel server

moon add gmlewis/picogk@0.2.0
Download zip
Author
Version
0.2.0
License
Apache-2.0
Last updated
last month
Downloads
12

Dependencies

README

#picogk — MoonBit SDK for the PicoGK MCP Server

picogk is an auto-generated MoonBit SDK for the PicoGK geometry kernel's MCP (Model Context Protocol) server. It provides a fully typed, idiomatic MoonBit interface to all 62 PicoGK tools — from creating primitives to boolean operations, lattice design, mesh manipulation, rendering, and 3D-printing export.

All tool methods are async and use moonbitlang/async for subprocess management. They must be called within an async fn main block.

#Quick Start

moon add gmlewis/picogk

///|
async fn main {
// Launch the PicoGK MCP server (default: $HOME/.local/bin/picogk-mcp/PicoGK.Mcp)
let client = @picogk.new_client("")

// Initialize the geometry kernel (0.5mm voxels)
let _ = client.picogk_init(Some(0.5))

// Create a sphere
let res = client.create_sphere(0.0, 0.0, 0.0, 30.0, Some("body"))
println(res)

// Create a box cutout
let _ = client.create_box(-10.0, -10.0, -40.0, 10.0, 10.0, 40.0, Some("cutout"))

// Subtract box from sphere
let _ = client.boolean_subtract("body", "cutout", Some("result"))

// Smooth the result
let _ = client.smooth("result", 2.0, Some("smoothed"))

// Convert to mesh and export STL
let _ = client.voxels_to_mesh("smoothed", Some("mesh"))
let _ = client.save_stl("mesh", "/tmp/part.stl", None)

// Render a preview
let _ = client.render_to_image("smoothed", "/tmp/preview.png", None, None, None, None)

// Clean up
client.close()

println("Done! Part exported to /tmp/part.stl")
}

#API Overview

The SDK exposes all 62 PicoGK MCP tools via typed methods:

CategoryTools
Booleansboolean_add, boolean_subtract, boolean_intersect, boolean_add_all, boolean_subtract_all
IOsave_stl, save_vdb, load_vdb, list_vdb_fields, save_svg, save_cli
Latticecreate_lattice, lattice_add_beam, lattice_add_sphere, lattice_to_voxels
Meshcreate_mesh, mesh_add_vertex, mesh_add_triangle, mesh_add_triangle_vertices, mesh_add_quad, voxels_to_mesh, mesh_to_voxels, mesh_from_stl, mesh_transform, mesh_mirror, mesh_append
Primitivescreate_sphere, create_box, create_cylinder, create_capsule, create_torus
Queryget_bounding_box, get_volume, get_mesh_info, point_inside, surface_normal, closest_point, list_objects, delete_object, get_voxel_dimensions, voxels_is_empty, voxels_mem_usage, voxels_is_equal, ray_cast, measure_thickness, duplicate_object, delete_objects
Renderrender_to_image, render_slice
Sessionpicogk_init, picogk_info, picogk_shutdown
Transformsoffset, double_offset, over_offset, smooth, trim, shell, fillet, project_z_slice, transform_voxels, circular_pattern

Each tool has:
  • A Client::method_name(...) method with typed parameters (snake_case)
  • Optional parameters are Option[T] (use Some(value) or None)
  • Returns String (the tool's text response) or raises Failure on error
  • Full doc comments

#Architecture

The SDK launches the PicoGK MCP server as a subprocess and communicates via JSON-RPC over stdio. No network connection is needed. The server binary must be installed separately (see the main PicoGK README for build instructions).

#Auto-Generation

This SDK is auto-generated from the PicoGK C# MCP tool definitions by scripts/generate-mbt-picogk-sdk.py. To regenerate:

./scripts/generate-mbt-picogk-sdk.py --verbose

DO NOT EDIT the generated files — changes will be overwritten. Edit the C# tool definitions in PicoGK.Mcp/Tools/*.cs instead, then regenerate.

#
Client

Client manages a connection to the PicoGK MCP server. It launches the server as a subprocess and communicates via JSON-RPC over stdio. All tool methods are async and must be called within an async fn main block.

Usage: async fn main { // Uses default server at $HOME/.local/bin/picogk-mcp/PicoGK.Mcp let client = @picogk.new_client("") // Or specify a custom path: // let client = @picogk.new_client("/custom/path/to/PicoGK.Mcp") client.picogk_init(Some(0.5)) client.create_sphere(0.0, 0.0, 0.0, 30.0, Some("body")) client.close() }

#
Client::boolean_add

async fn Client::boolean_add(self : Client, a : String, b : String, id : String?) -> String

boolean_add — boolean_add Boolean UNION: combine two voxel objects. Both volumes are kept, overlapping regions are merged. Returns a new object ID.

Parameters:
  • a : String (required) — ID of first object
  • b : String (required) — ID of second object
  • id : String? (optional) — Optional ID for the result

#
Client::boolean_add_all

async fn Client::boolean_add_all(self : Client, objectIds : Array[String], id : String?) -> String

boolean_add_all — boolean_add_all Combine multiple voxel objects into one. All volumes are merged. Returns a new object ID.

Parameters:
  • objectIds : Array[String] (required) — List of object IDs to combine
  • id : String? (optional) — Optional ID for the result

#
Client::boolean_intersect

async fn Client::boolean_intersect(self : Client, a : String, b : String, id : String?) -> String

boolean_intersect — boolean_intersect Boolean INTERSECTION: keep only the overlapping volume of two voxel objects. Returns a new object ID.

Parameters:
  • a : String (required) — ID of first object
  • b : String (required) — ID of second object
  • id : String? (optional) — Optional ID for the result

#
Client::boolean_subtract

async fn Client::boolean_subtract(self : Client, a : String, b : String, id : String?) -> String

boolean_subtract — boolean_subtract Boolean SUBTRACTION: subtract voxels of B from A. Removes the volume of B from A. Returns a new object ID.

Parameters:
  • a : String (required) — ID of the object to subtract FROM
  • b : String (required) — ID of the object to subtract
  • id : String? (optional) — Optional ID for the result

#
Client::boolean_subtract_all

async fn Client::boolean_subtract_all(self : Client, a : String, subtractIds : Array[String], id : String?) -> String

boolean_subtract_all — boolean_subtract_all Subtract multiple voxel objects from a single object in one call. Equivalent to calling boolean_subtract repeatedly, but more efficient for multi-hole drilling or multi-cutout operations. Returns a new object ID.

Parameters:
  • a : String (required) — ID of the object to subtract FROM
  • subtractIds : Array[String] (required) — List of object IDs to subtract from A
  • id : String? (optional) — Optional ID for the result

#
Client::call_tool

async fn Client::call_tool(self : Client, tool_name : String, args : Map[String, Json]) -> String

call_tool invokes an MCP tool by name and returns the text response.

#
Client::circular_pattern

async fn Client::circular_pattern(self : Client, objectId : String, count : Int, totalAngle : Double?, centerX : Double?, centerY : Double?, centerZ : Double?, axisX : Double?, axisY : Double?, axisZ : Double?, id : String?) -> String

circular_pattern — circular_pattern Create a circular (polar) pattern of a voxel object: rotate copies around an axis through a center point and union them into a single result. Uses SDF re-rasterization (no mesh round-trips) for each copy. Returns a new object ID containing all copies combined. Example: 4 bolt holes around a flange center at 90° intervals.

Parameters:
  • objectId : String (required) — ID of the source voxel object to pattern
  • count : Int (required) — Number of copies (including the original at angle 0)
  • totalAngle : Double? (optional) — Total angular span in degrees (default 360 = full circle)
  • centerX : Double? (optional) — Center point X of the rotation axis
  • centerY : Double? (optional) — Center point Y of the rotation axis
  • centerZ : Double? (optional) — Center point Z of the rotation axis
  • axisX : Double? (optional) — Rotation axis direction X (default 0 = +Z axis)
  • axisY : Double? (optional) — Rotation axis direction Y (default 0 = +Z axis)
  • axisZ : Double? (optional) — Rotation axis direction Z (default 1 = +Z axis)
  • id : String? (optional) — Optional ID for the result

#
Client::close

fn Client::close(self : Client) -> Unit

close shuts down the MCP server process.

#
Client::closest_point

async fn Client::closest_point(self : Client, objectId : String, x : Double, y : Double, z : Double) -> String

closest_point — closest_point Find the closest point on a voxel object's surface to a given point.

Parameters:
  • objectId : String (required) — ID of the voxel object
  • x : Double (required) — X coordinate of query point
  • y : Double (required) — Y coordinate of query point
  • z : Double (required) — Z coordinate of query point

#
Client::create_box

async fn Client::create_box(self : Client, minX : Double, minY : Double, minZ : Double, maxX : Double, maxY : Double, maxZ : Double, id : String?) -> String

create_box — create_box Create a box (axis-aligned cuboid) from minimum and maximum corner coordinates. Returns the object ID.

Parameters:
  • minX : Double (required) — Minimum X
  • minY : Double (required) — Minimum Y
  • minZ : Double (required) — Minimum Z
  • maxX : Double (required) — Maximum X
  • maxY : Double (required) — Maximum Y
  • maxZ : Double (required) — Maximum Z
  • id : String? (optional) — Optional ID to assign to this object

#
Client::create_capsule

async fn Client::create_capsule(self : Client, x1 : Double, y1 : Double, z1 : Double, x2 : Double, y2 : Double, z2 : Double, radius : Double, id : String?) -> String

create_capsule — create_capsule Create a capsule (a sphere-swept line segment). Returns the object ID.

Parameters:
  • x1 : Double (required) — Start point X
  • y1 : Double (required) — Start point Y
  • z1 : Double (required) — Start point Z
  • x2 : Double (required) — End point X
  • y2 : Double (required) — End point Y
  • z2 : Double (required) — End point Z
  • radius : Double (required) — Radius in mm
  • id : String? (optional) — Optional ID to assign

#
Client::create_cylinder

async fn Client::create_cylinder(self : Client, x : Double, y : Double, z : Double, radius : Double, height : Double, dirX : Double?, dirY : Double?, dirZ : Double?, id : String?) -> String

create_cylinder — create_cylinder Create a cylinder. By default it runs along the +Z axis from (x,y,z) to (x,y,z+height). Pass dirX/dirY/dirZ to orient the axis differently (the vector is normalized automatically). The cylinder has flat end caps. Returns the object ID.

Parameters:
  • x : Double (required) — X coordinate of the bottom center
  • y : Double (required) — Y coordinate of the bottom center
  • z : Double (required) — Z coordinate of the bottom center
  • radius : Double (required) — Radius in mm
  • height : Double (required) — Height in mm (along the axis)
  • dirX : Double? (optional) — Axis direction X (default 0 = +Z)
  • dirY : Double? (optional) — Axis direction Y (default 0 = +Z)
  • dirZ : Double? (optional) — Axis direction Z (default 1 = +Z). If all three are 0, +Z is used.
  • id : String? (optional) — Optional ID to assign

#
Client::create_lattice

async fn Client::create_lattice(self : Client, id : String?) -> String

create_lattice — create_lattice Create an empty lattice structure. Add beams and sphere nodes to build it, then convert to voxels. Returns the object ID.

Parameters:
  • id : String? (optional) — Optional ID to assign

#
Client::create_mesh

async fn Client::create_mesh(self : Client, id : String?) -> String

create_mesh — create_mesh Create an empty mesh. Add vertices and triangles to build geometry. Returns the object ID.

Parameters:
  • id : String? (optional) — Optional ID to assign

#
Client::create_sphere

async fn Client::create_sphere(self : Client, x : Double, y : Double, z : Double, radius : Double, id : String?) -> String

create_sphere — create_sphere Create a sphere voxel object. Returns the object ID.

Parameters:
  • x : Double (required) — X coordinate of center in mm
  • y : Double (required) — Y coordinate of center in mm
  • z : Double (required) — Z coordinate of center in mm
  • radius : Double (required) — Radius in mm
  • id : String? (optional) — Optional ID to assign to this object

#
Client::create_torus

async fn Client::create_torus(self : Client, majorRadius : Double, minorRadius : Double, x : Double?, y : Double?, z : Double?, id : String?) -> String

create_torus — create_torus Create a torus (donut shape) by revolving a circle around the Z axis. Returns the object ID.

Parameters:
  • majorRadius : Double (required) — Major radius (distance from center to tube center) in mm
  • minorRadius : Double (required) — Minor radius (tube radius) in mm
  • x : Double? (optional) — X offset of center
  • y : Double? (optional) — Y offset of center
  • z : Double? (optional) — Z offset of center
  • id : String? (optional) — Optional ID to assign

#
Client::delete_object

async fn Client::delete_object(self : Client, objectId : String) -> String

delete_object — delete_object Delete an object from the session. Frees memory and removes the object from the registry.

Parameters:
  • objectId : String (required) — ID of the object to delete

#
Client::delete_objects

async fn Client::delete_objects(self : Client, objectIds : Array[String], keepOnly : Bool?) -> String

delete_objects — delete_objects Delete multiple objects from the session in one call. Useful for cleaning up intermediate objects after a complex build. Returns the count of objects actually deleted.

Parameters:
  • objectIds : Array[String] (required) — List of object IDs to delete
  • keepOnly : Bool? (optional) — If true, delete ALL objects EXCEPT those in objectIds (keep-only mode). Default false = delete the listed objects.

#
Client::double_offset

async fn Client::double_offset(self : Client, objectId : String, offset1 : Double, offset2 : Double, id : String?) -> String

double_offset — double_offset Offset a voxel surface twice: first by offset1, then by offset2. Enables precise morphological operations not possible with a single offset — e.g. offset out by 2mm then back by 1.5mm to remove thin features while preserving wall thickness. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • offset1 : Double (required) — First offset distance in mm (positive = expand, negative = shrink)
  • offset2 : Double (required) — Second offset distance in mm (applied after the first offset)
  • id : String? (optional) — Optional ID for the result

#
Client::duplicate_object

async fn Client::duplicate_object(self : Client, objectId : String, id : String?) -> String

duplicate_object — duplicate_object Create a duplicate (deep copy) of an existing object. Works with voxel and mesh objects. Returns the new object ID.

Parameters:
  • objectId : String (required) — ID of the object to duplicate
  • id : String? (optional) — Optional ID for the copy

#
Client::fillet

async fn Client::fillet(self : Client, objectId : String, radius : Double, id : String?) -> String

fillet — fillet Fillets (rounds) the surface of a voxel object. Same as smooth but semantically for rounding edges. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • radius : Double (required) — Fillet radius in mm
  • id : String? (optional) — Optional ID for the result

#
Client::get_bounding_box

async fn Client::get_bounding_box(self : Client, objectId : String) -> String

get_bounding_box — get_bounding_box Get the axis-aligned bounding box of any object. Returns min/max corners in mm. Retries internally with exponential backoff if the object was just created/transformed and the internal mesh conversion is not yet settled.

Parameters:
  • objectId : String (required) — ID of the object to query

#
Client::get_mesh_info

async fn Client::get_mesh_info(self : Client, objectId : String) -> String

get_mesh_info — get_mesh_info Get information about a mesh: vertex count, triangle count, bounding box.

Parameters:
  • objectId : String (required) — ID of the mesh object

#
Client::get_volume

async fn Client::get_volume(self : Client, objectId : String) -> String

get_volume — get_volume Calculate the volume and bounding box of a voxel object. Retries internally with exponential backoff if the object was just created/transformed.

Parameters:
  • objectId : String (required) — ID of the voxel object

#
Client::get_voxel_dimensions

async fn Client::get_voxel_dimensions(self : Client, objectId : String) -> String

get_voxel_dimensions — get_voxel_dimensions Get the voxel dimensions (grid size) of a voxel object.

Parameters:
  • objectId : String (required) — ID of the voxel object

#
Client::lattice_add_beam

async fn Client::lattice_add_beam(self : Client, latticeId : String, x1 : Double, y1 : Double, z1 : Double, radius1 : Double, x2 : Double, y2 : Double, z2 : Double, radius2 : Double, roundCap : Bool?) -> String

lattice_add_beam — lattice_add_beam Add a tapered beam (strut) between two points in a lattice. Each end has its own radius. Returns a confirmation.

Parameters:
  • latticeId : String (required) — ID of the lattice object
  • x1 : Double (required) — Start point X
  • y1 : Double (required) — Start point Y
  • z1 : Double (required) — Start point Z
  • radius1 : Double (required) — Start radius in mm
  • x2 : Double (required) — End point X
  • y2 : Double (required) — End point Y
  • z2 : Double (required) — End point Z
  • radius2 : Double (required) — End radius in mm
  • roundCap : Bool? (optional) — Use round caps (default true)

#
Client::lattice_add_sphere

async fn Client::lattice_add_sphere(self : Client, latticeId : String, x : Double, y : Double, z : Double, radius : Double) -> String

lattice_add_sphere — lattice_add_sphere Add a sphere node at a point in a lattice. Returns a confirmation.

Parameters:
  • latticeId : String (required) — ID of the lattice object
  • x : Double (required) — Center X
  • y : Double (required) — Center Y
  • z : Double (required) — Center Z
  • radius : Double (required) — Radius in mm

#
Client::lattice_to_voxels

async fn Client::lattice_to_voxels(self : Client, latticeId : String, id : String?) -> String

lattice_to_voxels — lattice_to_voxels Convert a lattice to voxels. Renders the lattice beams and nodes into a voxel field. Returns a new voxel object ID.

Parameters:
  • latticeId : String (required) — ID of the lattice object
  • id : String? (optional) — Optional ID for the result

#
Client::list_objects

async fn Client::list_objects(self : Client) -> String

list_objects — list_objects List all objects in the current session with their IDs, types, and descriptions.

#
Client::list_vdb_fields

async fn Client::list_vdb_fields(self : Client, path : String) -> String

list_vdb_fields — list_vdb_fields List all fields in a VDB file with their names, types, and indices. Useful for inspecting multi-field VDB files before loading a specific field with load_vdb. Returns field count and a table of index, name, type, and PicoGK compatibility.

Parameters:
  • path : String (required) — Full path to the VDB file

#
Client::load_vdb

async fn Client::load_vdb(self : Client, path : String, fieldName : String?, id : String?) -> String

load_vdb — load_vdb Load voxels from an OpenVDB file. Returns the object ID.

Parameters:
  • path : String (required) — Full path to the VDB file
  • fieldName : String? (optional) — Optional field name to load (loads first field if not specified)
  • id : String? (optional) — Optional ID to assign

#
Client::measure_thickness

async fn Client::measure_thickness(self : Client, objectId : String, x : Double, y : Double, z : Double, dirX : Double, dirY : Double, dirZ : Double) -> String

measure_thickness — measure_thickness Cast a ray from a point in both +direction and -direction and report both hit points and the total span between them. Measures the through-thickness of the object along the ray axis (surface to surface through the interior, which may cross internal cavities). For local wall thickness of a shell, place the origin inside the wall material and note that the total span includes all internal voids.

Parameters:
  • objectId : String (required) — ID of the voxel object
  • x : Double (required) — Origin X (ideally inside the wall/material)
  • y : Double (required) — Origin Y
  • z : Double (required) — Origin Z
  • dirX : Double (required) — Measurement direction X (need not be normalized)
  • dirY : Double (required) — Measurement direction Y
  • dirZ : Double (required) — Measurement direction Z

#
Client::mesh_add_quad

async fn Client::mesh_add_quad(self : Client, meshId : String, x0 : Double, y0 : Double, z0 : Double, x1 : Double, y1 : Double, z1 : Double, x2 : Double, y2 : Double, z2 : Double, x3 : Double, y3 : Double, z3 : Double, flipped : Bool?) -> String

mesh_add_quad — mesh_add_quad Add a quad to a mesh by specifying four vertex positions directly. The vertices are added automatically and two triangles are created. Use bFlipped=true to reverse the winding order. Returns the starting triangle index.

Parameters:
  • meshId : String (required) — ID of the mesh
  • x0 : Double (required) — Vertex 0 X
  • y0 : Double (required) — Vertex 0 Y
  • z0 : Double (required) — Vertex 0 Z
  • x1 : Double (required) — Vertex 1 X
  • y1 : Double (required) — Vertex 1 Y
  • z1 : Double (required) — Vertex 1 Z
  • x2 : Double (required) — Vertex 2 X
  • y2 : Double (required) — Vertex 2 Y
  • z2 : Double (required) — Vertex 2 Z
  • x3 : Double (required) — Vertex 3 X
  • y3 : Double (required) — Vertex 3 Y
  • z3 : Double (required) — Vertex 3 Z
  • flipped : Bool? (optional) — If true, reverse the winding order of the two triangles

#
Client::mesh_add_triangle

async fn Client::mesh_add_triangle(self : Client, meshId : String, a : Int, b : Int, c : Int) -> String

mesh_add_triangle — mesh_add_triangle Add a triangle to a mesh using vertex indices. Returns the triangle index.

Parameters:
  • meshId : String (required) — ID of the mesh
  • a : Int (required) — Index of first vertex
  • b : Int (required) — Index of second vertex
  • c : Int (required) — Index of third vertex

#
Client::mesh_add_triangle_vertices

async fn Client::mesh_add_triangle_vertices(self : Client, meshId : String, x1 : Double, y1 : Double, z1 : Double, x2 : Double, y2 : Double, z2 : Double, x3 : Double, y3 : Double, z3 : Double) -> String

mesh_add_triangle_vertices — mesh_add_triangle_vertices Add a triangle to a mesh by specifying three vertex positions directly. The vertices are added automatically. Returns the triangle index.

Parameters:
  • meshId : String (required) — ID of the mesh
  • x1 : Double (required) — Vertex 1 X
  • y1 : Double (required) — Vertex 1 Y
  • z1 : Double (required) — Vertex 1 Z
  • x2 : Double (required) — Vertex 2 X
  • y2 : Double (required) — Vertex 2 Y
  • z2 : Double (required) — Vertex 2 Z
  • x3 : Double (required) — Vertex 3 X
  • y3 : Double (required) — Vertex 3 Y
  • z3 : Double (required) — Vertex 3 Z

#
Client::mesh_add_vertex

async fn Client::mesh_add_vertex(self : Client, meshId : String, x : Double, y : Double, z : Double) -> String

mesh_add_vertex — mesh_add_vertex Add a vertex to a mesh. Returns the vertex index (0-based) for use in triangle creation.

Parameters:
  • meshId : String (required) — ID of the mesh
  • x : Double (required) — X coordinate
  • y : Double (required) — Y coordinate
  • z : Double (required) — Z coordinate

#
Client::mesh_append

async fn Client::mesh_append(self : Client, targetId : String, sourceId : String) -> String

mesh_append — mesh_append Append one mesh into another (modifies the target). Returns the target mesh ID.

Parameters:
  • targetId : String (required) — ID of the target mesh (will be modified)
  • sourceId : String (required) — ID of the source mesh (will be appended)

#
Client::mesh_from_stl

async fn Client::mesh_from_stl(self : Client, path : String, id : String?) -> String

mesh_from_stl — mesh_from_stl Load a mesh from an STL file on disk. Returns the object ID.

Parameters:
  • path : String (required) — Full path to the STL file
  • id : String? (optional) — Optional ID to assign

#
Client::mesh_mirror

async fn Client::mesh_mirror(self : Client, meshId : String, ptX : Double, ptY : Double, ptZ : Double, nX : Double, nY : Double, nZ : Double, id : String?) -> String

mesh_mirror — mesh_mirror Mirror a mesh across a plane defined by a point and normal. Returns a new mesh object ID.

Parameters:
  • meshId : String (required) — ID of the source mesh
  • ptX : Double (required) — A point on the mirror plane X
  • ptY : Double (required) — A point on the mirror plane Y
  • ptZ : Double (required) — A point on the mirror plane Z
  • nX : Double (required) — Mirror plane normal X
  • nY : Double (required) — Mirror plane normal Y
  • nZ : Double (required) — Mirror plane normal Z
  • id : String? (optional) — Optional ID for the result

#
Client::mesh_to_voxels

async fn Client::mesh_to_voxels(self : Client, meshId : String, id : String?) -> String

mesh_to_voxels — mesh_to_voxels Convert a mesh to voxels. Returns a new voxel object ID.

Parameters:
  • meshId : String (required) — ID of the mesh object
  • id : String? (optional) — Optional ID for the result

#
Client::mesh_transform

async fn Client::mesh_transform(self : Client, meshId : String, scale : Double?, translateX : Double?, translateY : Double?, translateZ : Double?, id : String?) -> String

mesh_transform — mesh_transform Transform a mesh: apply uniform scale and/or translation. Returns a new mesh object ID.

Parameters:
  • meshId : String (required) — ID of the source mesh
  • scale : Double? (optional) — Scale factor (1.0 = no scale)
  • translateX : Double? (optional) — Translation X
  • translateY : Double? (optional) — Translation Y
  • translateZ : Double? (optional) — Translation Z
  • id : String? (optional) — Optional ID for the result

#
Client::offset

async fn Client::offset(self : Client, objectId : String, distance : Double, id : String?) -> String

offset — offset Offset a voxel surface outward (positive) or inward (negative) by a distance. Use for thickening, thinning, or creating clearance. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • distance : Double (required) — Offset distance in mm. Positive = expand, negative = shrink.
  • id : String? (optional) — Optional ID for the result

#
Client::over_offset

async fn Client::over_offset(self : Client, objectId : String, firstOffset : Double, finalSurfaceDist : Double?, id : String?) -> String

over_offset — over_offset Offset a voxel surface by a first distance, then settle the surface at a specified final distance from the original. More precise than fillet: lets you say 'offset by 3mm, then move the surface to exactly 0.5mm from where it started.' Useful for controlled material removal. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • firstOffset : Double (required) — First offset distance in mm (positive = expand)
  • finalSurfaceDist : Double? (optional) — Final surface distance from the original surface in mm (default 0 = settle back to original)
  • id : String? (optional) — Optional ID for the result

#
Client::picogk_info

async fn Client::picogk_info(self : Client) -> String

picogk_info — picogk_info Get information about the PicoGK library and current session state. Returns version, memory usage, and counts of allocated objects.

#
Client::picogk_init

async fn Client::picogk_init(self : Client, voxelSizeMM : Double?) -> String

picogk_init — picogk_init Initialize the PicoGK geometry kernel. Must be called before any other tool. Sets the voxel resolution in millimeters. Smaller values = higher resolution but more memory. Typical range: 0.1mm (fine) to 5.0mm (coarse).

Parameters:
  • voxelSizeMM : Double? (optional) — Voxel size in millimeters. Controls resolution. Use 0.5 for general purpose, 0.1 for fine detail, 2.0+ for large parts.

#
Client::picogk_shutdown

async fn Client::picogk_shutdown(self : Client) -> String

picogk_shutdown — picogk_shutdown Shut down the PicoGK session and release all resources. All object references become invalid after this call.

#
Client::point_inside

async fn Client::point_inside(self : Client, objectId : String, x : Double, y : Double, z : Double) -> String

point_inside — point_inside Check if a 3D point is inside a voxel object.

Parameters:
  • objectId : String (required) — ID of the voxel object
  • x : Double (required) — X coordinate
  • y : Double (required) — Y coordinate
  • z : Double (required) — Z coordinate

#
Client::project_z_slice

async fn Client::project_z_slice(self : Client, objectId : String, startZ : Double, endZ : Double, id : String?) -> String

project_z_slice — project_z_slice Project voxels onto a Z-plane (top-down silhouette). Useful for creating 2D cross-sections. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • startZ : Double (required) — Start Z position in mm
  • endZ : Double (required) — End Z position in mm
  • id : String? (optional) — Optional ID for the result

#
Client::ray_cast

async fn Client::ray_cast(self : Client, objectId : String, x : Double, y : Double, z : Double, dirX : Double, dirY : Double, dirZ : Double) -> String

ray_cast — ray_cast Cast a ray from a point in a given direction and find where it hits the surface of a voxel object. Useful for measuring wall thickness, checking bore clearance, and probing internal geometry. Returns the hit point and the distance from the origin, or an error if no intersection is found.

Parameters:
  • objectId : String (required) — ID of the voxel object
  • x : Double (required) — Origin X of the ray
  • y : Double (required) — Origin Y of the ray
  • z : Double (required) — Origin Z of the ray
  • dirX : Double (required) — Ray direction X (need not be normalized)
  • dirY : Double (required) — Ray direction Y
  • dirZ : Double (required) — Ray direction Z

#
Client::render_slice

async fn Client::render_slice(self : Client, voxelsId : String, zPosition : Double, path : String, mode : String?) -> String

render_slice — render_slice Render a Z-slice of a voxel object to a PNG image. Shows the cross-section at a specific height. Returns the file path.

Parameters:
  • voxelsId : String (required) — ID of the voxel object
  • zPosition : Double (required) — Z position in mm
  • path : String (required) — Full path for the output PNG file
  • mode : String? (optional) — Slice mode: Sdf, Bw, or Antialiased (default: Antialiased)

#
Client::render_to_image

async fn Client::render_to_image(self : Client, objectId : String, path : String, width : Int?, height : Int?, backgroundColor : String?, objectColor : String?) -> String

render_to_image — render_to_image Render an object to a PNG image using an isometric projection with Lambertian shading. The agent can use this to visually inspect geometry. Returns the file path of the rendered image.

Parameters:
  • objectId : String (required) — ID of the object to render (voxels or mesh)
  • path : String (required) — Full path for the output PNG file
  • width : Int? (optional) — Image width in pixels
  • height : Int? (optional) — Image height in pixels
  • backgroundColor : String? (optional) — Background color as hex (default: white)
  • objectColor : String? (optional) — Object color as hex (default: steel blue)

#
Client::save_cli

async fn Client::save_cli(self : Client, voxelsId : String, path : String, layerHeight : Double?, format : String?, useAbsXYOrigin : Bool?) -> String

save_cli — save_cli Save voxels to a CLI (Common Layer Interface) file for 3D printing. Vectorizes the voxel field into 2D layers and writes the CLI format. Returns the file path and slice count.

Parameters:
  • voxelsId : String (required) — ID of the voxel object
  • path : String (required) — Full path for the output CLI file
  • layerHeight : Double? (optional) — Layer height in mm for slicing (0 = use voxel size)
  • format : String? (optional) — Format: 'FirstLayerWithContent' (default) or 'UseEmptyFirstLayer' (adds an empty zero-height layer so readers can infer layer height)
  • useAbsXYOrigin : Bool? (optional) — If true, use absolute X/Y origin; if false (default), slices are relative to the voxel field boundaries

#
Client::save_stl

async fn Client::save_stl(self : Client, meshId : String, path : String, units : String?) -> String

save_stl — save_stl Save a mesh to an STL file. The mesh is typically obtained from voxels_to_mesh. Units are millimeters by default.

Parameters:
  • meshId : String (required) — ID of the mesh object
  • path : String (required) — Full path for the output STL file
  • units : String? (optional) — Units: MM, CM, M, FT, IN (default: MM)

#
Client::save_svg

async fn Client::save_svg(self : Client, voxelsId : String, path : String, layerHeight : Double?) -> String

save_svg — save_svg Vectorize voxels into 2D slice contours and save as SVG. Each slice is written to its own file: .NNNN.svg (zero-padded 4 digits). Useful for 2D manufacturing or visualization. Returns the count of files written.

Parameters:
  • voxelsId : String (required) — ID of the voxel object
  • path : String (required) — Output path. The slice index is inserted before the extension: 'out.svg' -> 'out.0001.svg'; if no extension, '.NNNN.svg' is appended
  • layerHeight : Double? (optional) — Layer height in mm for slicing

#
Client::save_vdb

async fn Client::save_vdb(self : Client, voxelsId : String, path : String, fieldName : String?) -> String

save_vdb — save_vdb Save voxels to an OpenVDB file. VDB files preserve the full voxel field data.

Parameters:
  • voxelsId : String (required) — ID of the voxel object
  • path : String (required) — Full path for the output VDB file
  • fieldName : String? (optional) — Optional name for the field inside the VDB file

#
Client::shell

async fn Client::shell(self : Client, objectId : String, innerOffset : Double, outerOffset : Double, smooth : Double?, id : String?) -> String

shell — shell Create a hollow shell from a voxel object. Both positive and negative offsets are applied. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • innerOffset : Double (required) — Inner wall offset in mm (positive = thinner walls)
  • outerOffset : Double (required) — Outer wall offset in mm (positive = thicker walls)
  • smooth : Double? (optional) — Smoothing for the shell walls in mm (0 = no smoothing)
  • id : String? (optional) — Optional ID for the result

#
Client::smooth

async fn Client::smooth(self : Client, objectId : String, distance : Double, id : String?) -> String

smooth — smooth Smooth/round a voxel surface by applying triple offset. Good for removing sharp edges. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • distance : Double (required) — Smoothing distance in mm. Larger = smoother.
  • id : String? (optional) — Optional ID for the result

#
Client::surface_normal

async fn Client::surface_normal(self : Client, objectId : String, x : Double, y : Double, z : Double) -> String

surface_normal — surface_normal Get the surface normal vector at a point on a voxel object's surface.

Parameters:
  • objectId : String (required) — ID of the voxel object
  • x : Double (required) — X coordinate
  • y : Double (required) — Y coordinate
  • z : Double (required) — Z coordinate

#
Client::transform_voxels

async fn Client::transform_voxels(self : Client, objectId : String, translateX : Double?, translateY : Double?, translateZ : Double?, rotateX : Double?, rotateY : Double?, rotateZ : Double?, scale : Double?, id : String?) -> String

transform_voxels — transform_voxels Transform a voxel object by translating, rotating, and/or scaling it. Rotations are applied first (around the world origin 0,0,0 — not the object's center), then translation. To rotate an object in place, first translate it to the origin, rotate, then translate back. Uses native PicoGK signed-distance-field re-rasterization (no expensive mesh round-trip), so it is efficient for large voxel fields. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source voxel object
  • translateX : Double? (optional) — Translation X in mm
  • translateY : Double? (optional) — Translation Y in mm
  • translateZ : Double? (optional) — Translation Z in mm
  • rotateX : Double? (optional) — Rotation around X axis in degrees (pitch)
  • rotateY : Double? (optional) — Rotation around Y axis in degrees (yaw)
  • rotateZ : Double? (optional) — Rotation around Z axis in degrees (roll)
  • scale : Double? (optional) — Uniform scale factor (1.0 = no change). Applied before rotation/translation.
  • id : String? (optional) — Optional ID for the result

#
Client::trim

async fn Client::trim(self : Client, objectId : String, minX : Double, minY : Double, minZ : Double, maxX : Double, maxY : Double, maxZ : Double, id : String?) -> String

trim — trim Trim a voxel object to fit within a bounding box. Everything outside the box is removed. Returns a new object ID.

Parameters:
  • objectId : String (required) — ID of the source object
  • minX : Double (required) — Minimum X of trim box
  • minY : Double (required) — Minimum Y of trim box
  • minZ : Double (required) — Minimum Z of trim box
  • maxX : Double (required) — Maximum X of trim box
  • maxY : Double (required) — Maximum Y of trim box
  • maxZ : Double (required) — Maximum Z of trim box
  • id : String? (optional) — Optional ID for the result

#
Client::voxels_is_empty

async fn Client::voxels_is_empty(self : Client, objectId : String) -> String

voxels_is_empty — voxels_is_empty Check if a voxel object is empty (contains no volume). Useful for detecting failed operations — e.g. an intersection that produced no overlap, or a subtraction that removed all material.

Parameters:
  • objectId : String (required) — ID of the voxel object

#
Client::voxels_is_equal

async fn Client::voxels_is_equal(self : Client, objectIdA : String, objectIdB : String) -> String

voxels_is_equal — voxels_is_equal Compare two voxel objects for equality. Returns true if they contain the same voxel data. Useful for verifying that a transform or round-trip preserved the shape.

Parameters:
  • objectIdA : String (required) — ID of the first voxel object
  • objectIdB : String (required) — ID of the second voxel object

#
Client::voxels_mem_usage

async fn Client::voxels_mem_usage(self : Client, objectId : String) -> String

voxels_mem_usage — voxels_mem_usage Get the memory usage of a voxel object in bytes. Useful for monitoring memory consumption when building complex models.

Parameters:
  • objectId : String (required) — ID of the voxel object

#
Client::voxels_to_mesh

async fn Client::voxels_to_mesh(self : Client, voxelsId : String, id : String?) -> String

voxels_to_mesh — voxels_to_mesh Convert a voxel object to a mesh using marching cubes. Returns a new mesh object ID.

Parameters:
  • voxelsId : String (required) — ID of the voxel object
  • id : String? (optional) — Optional ID for the result

#
new_client

async fn new_client(server_bin : String) -> Client

new_client launches the PicoGK MCP server binary and returns a Client. If server_bin is empty, uses default_server_bin. Must be called within an async function.