Skip to content

Commit a5ac1de

Browse files
authored
Merge pull request #298 from IvanMurzak/feature/tools-editor-window
MCP Tools Editor Window
2 parents 40f5a9c + 8ca509b commit a5ac1de

File tree

10 files changed

+886
-1
lines changed

10 files changed

+886
-1
lines changed

Unity-MCP-Plugin/Assets/root/Editor/Scripts/UI/Window/MainWindowEditor.CreateGUI.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#nullable enable
1212
using System;
13+
using System.Linq;
1314
using com.IvanMurzak.McpPlugin.Common;
1415
using com.IvanMurzak.Unity.MCP.Runtime.Utils;
1516
using Microsoft.AspNetCore.SignalR.Client;
@@ -248,6 +249,42 @@ public void CreateGUI()
248249
}
249250
}));
250251

252+
// Tools Configuration
253+
// -----------------------------------------------------------------
254+
var btnOpenTools = root.Query<Button>("btnOpenTools").First();
255+
btnOpenTools.RegisterCallback<ClickEvent>(evt =>
256+
{
257+
McpToolsWindow.ShowWindow();
258+
});
259+
260+
var toolsStatusLabel = root.Query<Label>("toolsStatusLabel").First();
261+
262+
McpPlugin.McpPlugin.DoAlways(plugin =>
263+
{
264+
var toolManager = plugin.McpManager.ToolManager;
265+
if (toolManager == null)
266+
{
267+
toolsStatusLabel.text = "Total tools (0), active tools (0), disabled tools (0)";
268+
return;
269+
}
270+
271+
void UpdateStats()
272+
{
273+
var allTools = toolManager.GetAllTools();
274+
var total = allTools.Count();
275+
var active = allTools.Count(t => toolManager.IsToolEnabled(t.Name));
276+
var disabled = total - active;
277+
toolsStatusLabel.text = $"Total tools ({total}), active tools ({active}), disabled tools ({disabled})";
278+
}
279+
280+
UpdateStats();
281+
282+
toolManager.OnToolsUpdated
283+
.ObserveOnCurrentSynchronizationContext()
284+
.Subscribe(_ => UpdateStats())
285+
.AddTo(_disposables);
286+
}).AddTo(_disposables);
287+
251288
// Configure MCP Client
252289
// -----------------------------------------------------------------
253290

0 commit comments

Comments
 (0)