plcsharp/PLCSharp.Mcp/ProjectTools.cs

23 lines
1.4 KiB
C#

using System.ComponentModel;
using ModelContextProtocol.Server;
using System.Text.Json.Nodes;
namespace PLCSharp.Mcp;
[McpServerToolType]
internal sealed class ProjectTools(ProjectGateway gateway)
{
[McpServerTool(Name = "find_references", ReadOnly = true), Description("Find C# references to a Variables, SystemVariables or Workflows ID within its recipe. Dynamic hits require human review.")]
public string FindReferences(string kind, string id) => gateway.Call("references", new() { ["kind"] = kind, ["id"] = id });
[McpServerTool(Name = "get_project_summary", ReadOnly = true), Description("Read the bound PLCSharp project, default recipe and available object kinds.")]
public string Summary() => gateway.Call("summary", new());
[McpServerTool(Name = "list_objects", ReadOnly = true), Description("List one object kind from the summary, optionally scoped to a recipe. Pages start at offset zero.")]
public string ListObjects(string kind, string recipeId = null, int offset = 0, int limit = 50) =>
gateway.Call("list", new() { ["kind"] = kind, ["recipeId"] = recipeId, ["offset"] = offset, ["limit"] = limit });
[McpServerTool(Name = "get_object", ReadOnly = true), Description("Read one project object by kind and stable ID, including source for workflows.")]
public string GetObject(string kind, string id) => gateway.Call("get", new() { ["kind"] = kind, ["id"] = id });
}