Skip to content

Feature/mcp#125

Merged
cezarypiatek merged 23 commits into
mainfrom
feature/mcp
Jun 1, 2026
Merged

Feature/mcp#125
cezarypiatek merged 23 commits into
mainfrom
feature/mcp

Conversation

@cezarypiatek

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 details tooltips.

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();
@cezarypiatek cezarypiatek force-pushed the feature/mcp branch 2 times, most recently from 9dd6f05 to a2ebf5f Compare June 1, 2026 06:16
@cezarypiatek cezarypiatek merged commit c5048d4 into main Jun 1, 2026
1 check passed
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