Skip to content

Drive MCP tool definitions and dispatch from proto messages#11368

Merged
tronical merged 3 commits intoslint-ui:masterfrom
tilladam:feature/proto-driven-mcp
Apr 14, 2026
Merged

Drive MCP tool definitions and dispatch from proto messages#11368
tronical merged 3 commits intoslint-ui:masterfrom
tilladam:feature/proto-driven-mcp

Conversation

@tilladam
Copy link
Copy Markdown
Contributor

Summary

Addresses review feedback from #11340: replace hand-written JSON schemas and manual string parsing in the MCP server with proto-driven generation.

  • Add RequestGetElementTree, RequestDispatchKeyEvent, and KeyEventType enum to slint_systest.proto so all 12 MCP tools have proto request counterparts
  • Generate JSON schemas from proto file descriptors at build time in build.rs
  • Replace ~160 lines of hand-written JSON tool definitions with a compact declarative TOOLS table mapping tool names to proto request types
  • Unify all tool handlers to use deserialize_params with proto types, eliminating manual string matching for enums and manual JSON field extraction

Breaking change for MCP clients: drag_element now takes target: { x, y } (matching the proto LogicalPosition) instead of flat targetX/targetY. dispatch_key_event enum values changed from snake_case (press_and_release) to PascalCase (PressAndRelease) to match proto conventions.

Test plan

  • cargo build -p i-slint-backend-testing --features mcp compiles
  • cargo test -p i-slint-backend-testing --features mcp -- mcp — all 19 tests pass
  • New test_all_tools_have_proto_schemas validates every tool's request_type resolves to a generated schema and all optional_fields are real proto fields

tilladam and others added 3 commits April 13, 2026 18:52
Replace hand-written JSON schemas and manual string parsing with
proto-driven generation:

- Add RequestGetElementTree, RequestDispatchKeyEvent, and KeyEventType
  to slint_systest.proto so all 12 MCP tools have proto counterparts
- Generate JSON schemas from proto descriptors at build time in build.rs
- Replace 160 lines of hand-written JSON with a declarative TOOLS table
  mapping tool names to proto request types
- Unify all tool handlers to use deserialize_params with proto types,
  eliminating manual string matching for enums and field extraction
Add match arms for RequestDispatchKeyEvent and RequestGetElementTree
in the binary system-testing transport. These are MCP-only tools, so
return an error when received over the system-testing channel.
Copy link
Copy Markdown
Member

@tronical tronical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that looks like a small overall reduction - worth it :)

@tronical tronical merged commit 364cbaa into slint-ui:master Apr 14, 2026
54 checks passed
@tilladam tilladam deleted the feature/proto-driven-mcp branch April 23, 2026 16:09
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.

2 participants