Skip to content

feat: add MCP server for AI assistant integration - #1

Draft
donrami wants to merge 5 commits into
mainfrom
feat/mcp-server
Draft

feat: add MCP server for AI assistant integration#1
donrami wants to merge 5 commits into
mainfrom
feat/mcp-server

Conversation

@donrami

@donrami donrami commented May 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a headless MCP server binary (penopt-mcp) that lets AI assistants like Claude Desktop and Claude Code load 3D meshes and run CT orientation optimization directly. Mesh data stays local — only file paths and JSON results cross the protocol boundary.

What's included

MCP Server (cmd/penopt-mcp)

Tool Description
ping Health check
load_mesh Load STL/OBJ from disk, parse, center, build BVH
get_mesh_info Mesh metadata (triangles, watertight, bounds)
evaluate_orientation Score a single (θ, φ) orientation
run_optimization Full coarse→fine grid search with progress notifications

Technical highlights

  • Zero refactoring of existing code — purely additive cmd/penopt-mcp/ directory
  • Imports internal/* directly — same Go packages as the GUI, no Wails dependency
  • Context cancellation — search stops cleanly if the client disconnects
  • 8.5 MB binary — pure Go, no GUI runtime, no webview
  • Official go-sdk v1.6.0 — maintained by Google + Anthropic
  • 22 tests — integration tests over real MCP protocol, all passing

CI/CD

  • ci.yml — builds + tests + vets MCP server on every push and PR (separate from release workflow)
  • release.yml — new build-mcp job cross-compiles for all 4 platforms from a single ubuntu runner; 8 binaries per release (4 GUI + 4 MCP)

Docs

  • cmd/penopt-mcp/README.md — full setup guide with Claude Desktop/Code config, tool reference, example conversation, troubleshooting
  • Root README.md — new "AI Integration (MCP)" section
  • CHANGELOG.md — v0.3.0 entry

Testing

go test -v -timeout 120s ./cmd/penopt-mcp/  →  12/12 PASS
go test ./internal/search/                    →  10/10 PASS
go vet ./cmd/penopt-mcp/                      →  clean
go build ./cmd/penopt-mcp/                    →  8.5 MB

How to use

  1. Download penopt-mcp-{platform} from the next release
  2. Add to Claude Desktop config or run claude mcp add penopt -- ./penopt-mcp
  3. Ask: "Load /path/to/part.stl and find the optimal CT scan orientation"

donrami added 5 commits May 15, 2026 01:39
Add headless MCP server binary at cmd/penopt-mcp/ that runs on stdio
transport. Uses the official go-sdk v1.6.0.

- cmd/penopt-mcp/main.go — server entry point with ping tool
- cmd/penopt-mcp/smoke_test.go — MCP protocol integration test
- go.mod/go.sum — add modelcontextprotocol/go-sdk dependency
- .gitignore — ignore root-level penopt-mcp binaries
Add 4 headless tools that delegate to the existing internal/* packages:

- load_mesh: reads STL/OBL from disk, parses, centers, builds BVH
- get_mesh_info: returns metadata for the currently loaded mesh
- evaluate_orientation: scores a single (theta, phi) orientation
- run_optimization: runs coarse->fine grid search with progress notifications

Includes:
- tools.go: shared state, typed handlers, input validation
- tools_test.go: 10 integration tests covering all happy/error paths
- testdata/cube20.stl: 20mm test cube (ASCII STL)

All 12 tests pass, go vet clean, binary builds at 8.5 MB.
…ardening

- search.Run() now accepts context.Context for cancellation support
  (passes context.Background() from GUI, handler context from MCP)
- Cancellation checked before starting and between coarse/fine phases
- MCP progress notifications now also log to stderr for clients that
  don't display MCP notification messages
- All 22 tests pass, go vet clean
- cmd/penopt-mcp/README.md: full user guide with quick start,
  Claude Desktop/Code setup, tool reference, example conversation,
  troubleshooting, and build instructions
- README.md: add AI Integration (MCP) section to the project root
- CHANGELOG.md: add v0.3.0 entry for MCP server features
@donrami donrami self-assigned this May 27, 2026
@donrami
donrami marked this pull request as draft May 27, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant