Feature/mcp#125
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds MCP server support to the ScriptRunner GUI, exposing configured actions as MCP tools over a local ASP.NET Core/Kestrel endpoint and adding UI to configure exposure, safety, output, and parameter-set behavior.
Changes:
- Adds MCP host/tool/resource infrastructure and app startup/shutdown integration.
- Adds MCP configuration UI, safe-mode approval controls, and per-action MCP settings persistence.
- Extends parameter controls/schema/docs to support MCP value injection and parameter
detailstooltips.
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/ScriptRunner/ScriptRunner.GUI/Mcp/ScriptRunnerMcpHost.cs |
Hosts the local MCP HTTP server and maps actions/docs. |
src/ScriptRunner/ScriptRunner.GUI/Mcp/McpUiBridge.cs |
Bridges MCP calls to Avalonia UI execution. |
src/ScriptRunner/ScriptRunner.GUI/Mcp/McpToolBuilder.cs |
Builds MCP tool names, schemas, and invocation handlers. |
src/ScriptRunner/ScriptRunner.GUI/Mcp/ActionDocsResources.cs |
Exposes action documentation as MCP/HTTP resources. |
src/ScriptRunner/ScriptRunner.GUI/ViewModels/McpConfigWindowViewModel.cs |
Adds MCP configuration state and save/apply logic. |
src/ScriptRunner/ScriptRunner.GUI/ViewModels/McpActionToggleViewModel.cs |
Adds per-action MCP toggle row model. |
src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs |
Adds MCP status, safe-mode approval, highlighting, and action reload event. |
src/ScriptRunner/ScriptRunner.GUI/ViewModels/RunningJobViewModel.cs |
Tracks exit code and elapsed time for MCP results. |
src/ScriptRunner/ScriptRunner.GUI/Views/McpConfigWindow.axaml |
Adds MCP configuration window UI. |
src/ScriptRunner/ScriptRunner.GUI/Views/McpConfigWindow.axaml.cs |
Wires MCP configuration window save behavior. |
src/ScriptRunner/ScriptRunner.GUI/Views/SideMenu.axaml |
Adds MCP configuration button and running indicator. |
src/ScriptRunner/ScriptRunner.GUI/Views/ActionDetailsSection.axaml |
Adds safe-mode Accept/Reject UI. |
src/ScriptRunner/ScriptRunner.GUI/Themes/StyleClasses.axaml |
Adds MCP button, highlight, and tooltip styles. |
src/ScriptRunner/ScriptRunner.GUI/Settings/McpServerSettings.cs |
Defines persisted MCP server settings. |
src/ScriptRunner/ScriptRunner.GUI/Settings/ScriptRunnerAppSettings.cs |
Adds MCP settings to app settings. |
src/ScriptRunner/ScriptRunner.GUI/Settings/AppSettingsService.cs |
Adds MCP settings update helper. |
src/ScriptRunner/ScriptRunner.GUI/App.axaml.cs |
Auto-starts/stops MCP host with app lifecycle. |
src/ScriptRunner/ScriptRunner.GUI/Program.cs |
Registers MCP services and singleton main view model. |
src/ScriptRunner/ScriptRunner.GUI/ScriptRunner.GUI.csproj |
Adds ASP.NET Core/MCP dependencies. |
src/ScriptRunner/ScriptRunner.GUI/ScriptReader/ScriptConfigReader.cs |
Stores absolute docs path on loaded configs. |
src/ScriptRunner/ScriptRunner.GUI/ScriptConfigs/ScriptConfig.cs |
Adds docs path and parameter details fields. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/IControlRecord.cs |
Adds value-injection API for controls. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/ParamsPanel.cs |
Tracks parameter row containers for highlighting. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/ParamsPanelFactory.cs |
Adds details tooltip UI and row highlight wrappers. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/TextControl.cs |
Supports setting text values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/PasswordControl.cs |
Supports setting password values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/CheckboxControl.cs |
Supports setting checkbox values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/DropdownControl.cs |
Supports setting dropdown values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/MultiSelectControl.cs |
Supports setting multi-select values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/NumericControl.cs |
Supports setting numeric values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/DatePickerControl.cs |
Supports setting date values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/TimePickerControl.cs |
Supports setting time values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/FilePickerControl.cs |
Supports setting file picker values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/DirectoryPickerControl.cs |
Supports setting directory picker values from MCP. |
src/ScriptRunner/ScriptRunner.GUI/Parameters/FileContent.cs |
Supports setting file-content editor values from MCP. |
schema/v1/ScriptRunnerSchema.json |
Documents the new details parameter field in schema. |
README.md |
Documents the new details parameter field. |
src/ScriptRunner/ScriptRunner.GUI/Scripts/TextInputScript.json |
Updates sample parameters to exercise new behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+158
to
+159
| // Refresh the list when actions are reloaded while the dialog is open | ||
| _mainVm.ActionsReloaded += OnActionsReloaded; |
Comment on lines
+170
to
+184
| ct.Register(() => | ||
| { | ||
| // If we've been detached (fire-and-forget timeout), leave the running job alone. | ||
| if (detach?.Value == true) return; | ||
|
|
||
| // Try to cancel the job if it was started, or cancel a pending safe-mode approval | ||
| Dispatcher.UIThread.Post(() => _vm.CancelMcpApproval()); | ||
|
|
||
| if (_vm.RunningJobs.Count > jobCountBefore) | ||
| { | ||
| var job = _vm.RunningJobs[_vm.RunningJobs.Count - 1]; | ||
| job.CancelExecution(); | ||
| } | ||
| tcs.TrySetCanceled(ct); | ||
| }); |
Comment on lines
+57
to
+68
| string Deduplicate(string baseName) | ||
| { | ||
| if (!seen.ContainsKey(baseName)) | ||
| { | ||
| seen[baseName] = 1; | ||
| return baseName; | ||
| } | ||
| var n = ++seen[baseName]; | ||
| // Reserve 3 chars for "_NN" suffix (supports up to _99 cleanly, more if needed) | ||
| var trimmed = baseName.Length <= 61 ? baseName : baseName[..61]; | ||
| return $"{trimmed}_{n}"; | ||
| } |
| return McpToolBuilder.CreateTool(t.Action, t.ToolName, docsResourceUri, docsHttpUri, bridge, includeOutput, safeMode, fireAndForget, t.ArgumentSet); | ||
| }).ToList(); | ||
|
|
||
| var builder = WebApplication.CreateSlimBuilder(); |
7ec4c77 to
c2f5b9c
Compare
9dd6f05 to
a2ebf5f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.