125 lines
5.2 KiB
C#
125 lines
5.2 KiB
C#
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";
|
|
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";
|
|
|
|
/// <summary>
|
|
/// Ekran ve bilesen gelistirme araclari. Sunucu bazinda <c>AllowedTools</c> ile, kullanici
|
|
/// bazinda <c>McpServers.Develop</c> yetkisiyle kapatilir.
|
|
/// </summary>
|
|
public static readonly string[] DevelopTools =
|
|
[
|
|
GetDevGuide,
|
|
CreateTable,
|
|
ListWizards,
|
|
GetWizard,
|
|
DeployWizard,
|
|
DeleteWizard,
|
|
ListComponents,
|
|
GetComponent,
|
|
SaveComponent,
|
|
DeleteComponent
|
|
];
|
|
|
|
/// <summary>
|
|
/// Sunucu kaydi olmasa da acik kalan araclar. Istemcinin baglantisinin neden bos
|
|
/// gorundugunu anlayabilmesi icin gereklidir.
|
|
/// </summary>
|
|
public static readonly string[] AlwaysAvailableTools = [ServerInfo];
|
|
|
|
/// <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
|
|
];
|
|
|
|
/// <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
|
|
/// 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.
|
|
/// </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,
|
|
[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,
|
|
};
|
|
|
|
/// <summary>Yayinlanan tum araclar, arac listesindeki siralarina gore.</summary>
|
|
public static readonly string[] All =
|
|
[
|
|
ServerInfo,
|
|
ListLists,
|
|
DescribeList,
|
|
SearchSchema,
|
|
QueryList,
|
|
RunSelect,
|
|
ListQueries,
|
|
RunQuery,
|
|
InsertRow,
|
|
UpdateRow,
|
|
DeleteRow,
|
|
.. DevelopTools
|
|
];
|
|
|
|
/// <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));
|
|
}
|