sozsoft-platform/api/modules/Sozsoft.Mcp/Sozsoft.Mcp.Domain.Shared/McpToolNames.cs

126 lines
5.2 KiB
C#
Raw Normal View History

2026-09-17 09:01:14 +00:00
using System.Collections.Generic;
using System.Linq;
using Sozsoft.Platform;
namespace Sozsoft.Mcp;
/// <summary>
/// /mcp ucunda yayinlanan arac adlari. Ayni degerler MCP Servers ekranindaki
/// <c>AllowedTools</c> alaninin secenek listesini besler; buraya bir arac eklenirse ekranin
/// statik lookup listesi de guncellenir.
/// </summary>
public static class McpToolNames
{
public const string ServerInfo = "server_info";
public const string ListLists = "list_lists";
public const string DescribeList = "describe_list";
public const string SearchSchema = "search_schema";
public const string QueryList = "query_list";
public const string RunSelect = "run_select";
public const string ListQueries = "list_queries";
public const string RunQuery = "run_query";
public const string InsertRow = "insert_row";
public const string UpdateRow = "update_row";
public const string DeleteRow = "delete_row";
2026-09-18 13:47:23 +00:00
public const string GetDevGuide = "get_dev_guide";
public const string CreateTable = "create_table";
public const string ListWizards = "list_wizards";
public const string GetWizard = "get_wizard";
public const string DeployWizard = "deploy_wizard";
public const string DeleteWizard = "delete_wizard";
public const string ListComponents = "list_components";
public const string GetComponent = "get_component";
public const string SaveComponent = "save_component";
public const string DeleteComponent = "delete_component";
2026-09-17 09:01:14 +00:00
/// <summary>
2026-09-18 13:47:23 +00:00
/// Ekran ve bilesen gelistirme araclari. Sunucu bazinda <c>AllowedTools</c> ile, kullanici
/// bazinda <c>McpServers.Develop</c> yetkisiyle kapatilir.
2026-09-17 09:01:14 +00:00
/// </summary>
2026-09-18 13:47:23 +00:00
public static readonly string[] DevelopTools =
[
GetDevGuide,
CreateTable,
ListWizards,
GetWizard,
DeployWizard,
DeleteWizard,
ListComponents,
GetComponent,
SaveComponent,
DeleteComponent
];
2026-09-17 09:01:14 +00:00
/// <summary>
/// Sunucu kaydi olmasa da acik kalan araclar. Istemcinin baglantisinin neden bos
/// gorundugunu anlayabilmesi icin gereklidir.
/// </summary>
public static readonly string[] AlwaysAvailableTools = [ServerInfo];
2026-09-18 13:47:23 +00:00
/// <summary>
/// Kiraci kullanicisinin gorebildigi araclarin tamami; kiraci baglaminda MCP yalnizca veri
/// okur. <c>AllowedTools</c> bu kumeyi yalnizca daraltabilir, genisletemez. <see cref="RunQuery"/>
/// ve <see cref="ListQueries"/> disarida kalir: procedure ve Custom Endpoint cagrisi veri
/// yazabilir, okuma oldugu garanti edilemez. <see cref="RunSelect"/> ise tek SELECT disindaki
/// her ifadeyi reddettigi icin okumadir.
/// </summary>
public static readonly string[] TenantTools =
[
ServerInfo,
ListLists,
DescribeList,
SearchSchema,
QueryList,
RunSelect
];
2026-09-17 09:01:14 +00:00
/// <summary>
/// Kullanicinin uygulamada da sahip olmasi gereken yetki. MCP yetki vermez: ham SQL'i
/// uygulamada SQL Query Manager'i kullanabilen, veri yazmayi yazma yetkisi olan kullanici
2026-09-18 13:47:23 +00:00
/// gorur. Listede olmayan araclar kendi icinde liste bazli yetkiyle suzulur. Gelistirme
/// araclarinin arkasindaki Wizard ve Custom Components servisleri kendi yetkilerini ayrica
/// ister; Develop yalnizca MCP kapisidir.
2026-09-17 09:01:14 +00:00
/// </summary>
public static readonly IReadOnlyDictionary<string, string> RequiredPermissions = new Dictionary<string, string>
{
[RunSelect] = PlatformConsts.AppCodes.SqlQueryManagers.Default,
[InsertRow] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
[UpdateRow] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
[DeleteRow] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
2026-09-18 13:47:23 +00:00
[GetDevGuide] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[CreateTable] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[ListWizards] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[GetWizard] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[DeployWizard] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[DeleteWizard] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[ListComponents] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[GetComponent] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[SaveComponent] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
[DeleteComponent] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Develop,
2026-09-17 09:01:14 +00:00
};
/// <summary>Yayinlanan tum araclar, arac listesindeki siralarina gore.</summary>
public static readonly string[] All =
[
ServerInfo,
ListLists,
DescribeList,
SearchSchema,
QueryList,
RunSelect,
ListQueries,
RunQuery,
InsertRow,
UpdateRow,
2026-09-18 13:47:23 +00:00
DeleteRow,
.. DevelopTools
2026-09-17 09:01:14 +00:00
];
/// <summary>
/// <c>AllowedTools</c> alaninda secilebilen araclar. Her zaman acik olanlar secenek
/// olarak sunulmaz; onlari kapatmak mumkun degildir.
/// </summary>
public static IEnumerable<string> SelectableTools
=> All.Where(name => !AlwaysAvailableTools.Contains(name));
}