Expose MCP feature through Slint platform setup#11520
Expose MCP feature through Slint platform setup#11520tilladam wants to merge 4 commits intoslint-ui:masterfrom
Conversation
|
cc @ogoffart I've been thinking along the same lines of having just a public MCP feature and otherwise no changes needed. It won't expose additional api. Implementation wise I think it would be better not to do the shadowing and instead use the same approach as the system testing hook. |
|
I’m very confused. Why is all the extra code necessary when we have slint/internal/backends/selector/lib.rs Line 175 in d536497 Right now, once has to merely enable the MCP feature in the selector and instead we could say that one need to enable it on the slint crate instead and that forwards. But clearly I’m missing something as this diff does so much more. What am I missing? |
|
The key scenario the selector's With So in summary: if the goal is only "make |
BackendSelector::select() calls set_platform() directly, bypassing with_global_context, so MCP and system-testing were not initialized when using that path. Call init() directly after set_platform succeeds. Also update the skills file: the MCP server is now enabled via the public slint crate's mcp feature, not i-slint-backend-selector.
Replace the shadowed set_platform in api/rs/slint with an add_platform_init_hook() mechanism in i_slint_core::context, analogous to set_window_shown_hook. Hooks are stored in a thread-local Vec and drained by set_platform immediately after SlintContext is installed, before update_timers_and_animations(), so introspection hooks are in place before any timer or change callbacks can create or show a window. The selector registers system-testing and mcp hooks inside the backend factory closure so hooks are only queued when backend creation succeeds, preserving the old result.is_ok() behavior. Custom platform authors can opt in via slint::mcp::register() before calling set_platform. Reverts the mcp-gated cfg guards on testing init functions, which were artifacts of the shadow approach.
2ebc2bb to
25ff187
Compare
Summary
slint/mcpfeature that wires through the selector and testing backend MCP supportslint::platform::set_platform(), matching the existing backend-selector initialization pathslint/mcpfrom compiling the public testing-backend helper APIs and suppress generated protobuf dead-code warnings in the generated proto moduleNotes
This keeps the current MCP implementation in
i-slint-backend-testingbecause it reuses the existing introspection/search infrastructure. A possible future cleanup is to split that shared introspection layer into its own internal crate/module, with clearer boundaries:That split is orthogonal to this PR, but would avoid making MCP look conceptually tied to the testing backend long term.
Verification
cargo build -p slint --release --no-default-features --features std,compat-1-2,mcpcargo check -p i-slint-backend-testing --features internal