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";
|
2026-09-24 11:58:23 +00:00
|
|
|
|
public const string VerifyWizard = "verify_wizard";
|
|
|
|
|
|
public const string StartDevRequest = "start_dev_request";
|
|
|
|
|
|
public const string GetDevRequest = "get_dev_request";
|
2026-09-28 09:28:56 +00:00
|
|
|
|
public const string SaveDevRequestAnalysis = "save_dev_request_analysis";
|
2026-09-24 11:58:23 +00:00
|
|
|
|
public const string AppendDevRequestNote = "append_dev_request_note";
|
2026-09-24 13:29:53 +00:00
|
|
|
|
public const string AddDevRequestSubTasks = "add_dev_request_subtasks";
|
2026-09-18 13:47:23 +00:00
|
|
|
|
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-10-01 12:01:57 +00:00
|
|
|
|
public const string ListReportTemplates = "list_report_templates";
|
|
|
|
|
|
public const string GetReportTemplate = "get_report_template";
|
|
|
|
|
|
public const string SaveReportCategory = "save_report_category";
|
|
|
|
|
|
public const string SaveReportTemplate = "save_report_template";
|
|
|
|
|
|
public const string DeleteReportTemplate = "delete_report_template";
|
2026-09-17 09:01:14 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-10-01 12:01:57 +00:00
|
|
|
|
/// Ekran, bilesen ve rapor sablonu gelistirme araclari; kiraci baglaminda hicbiri acilmaz. Okuyanlar
|
2026-09-24 11:58:23 +00:00
|
|
|
|
/// <c>McpServers.Invoke</c> ile, degistirenler <c>McpServers.Write</c> ile acilir
|
|
|
|
|
|
/// (<see cref="RequiredPermissions"/>).
|
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,
|
2026-09-24 11:58:23 +00:00
|
|
|
|
VerifyWizard,
|
|
|
|
|
|
StartDevRequest,
|
|
|
|
|
|
GetDevRequest,
|
2026-09-28 09:28:56 +00:00
|
|
|
|
SaveDevRequestAnalysis,
|
2026-09-24 11:58:23 +00:00
|
|
|
|
AppendDevRequestNote,
|
2026-09-24 13:29:53 +00:00
|
|
|
|
AddDevRequestSubTasks,
|
2026-09-18 13:47:23 +00:00
|
|
|
|
ListComponents,
|
|
|
|
|
|
GetComponent,
|
|
|
|
|
|
SaveComponent,
|
2026-10-01 12:01:57 +00:00
|
|
|
|
DeleteComponent,
|
|
|
|
|
|
ListReportTemplates,
|
|
|
|
|
|
GetReportTemplate,
|
|
|
|
|
|
SaveReportCategory,
|
|
|
|
|
|
SaveReportTemplate,
|
|
|
|
|
|
DeleteReportTemplate
|
2026-09-18 13:47:23 +00:00
|
|
|
|
];
|
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>
|
2026-09-24 11:58:23 +00:00
|
|
|
|
/// Kiraci kullanicisinin gorebildigi araclarin tamami: veri okuma ve ekranin
|
|
|
|
|
|
/// insert/update/delete sozlesmesinden gecen satir yazma. Yazilim gelistirme araclari
|
|
|
|
|
|
/// (<see cref="DevelopTools"/>) kiraciya acilmaz. <c>AllowedTools</c> bu kumeyi yalnizca
|
|
|
|
|
|
/// daraltabilir, genisletemez. <see cref="RunQuery"/> ve <see cref="ListQueries"/> disarida
|
|
|
|
|
|
/// kalir: procedure ve Custom Endpoint ekran yetkisinden gecmeden veri yazabilir.
|
|
|
|
|
|
/// <see cref="RunSelect"/> ise tek SELECT disindaki her ifadeyi reddettigi icin okumadir.
|
2026-09-18 13:47:23 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static readonly string[] TenantTools =
|
|
|
|
|
|
[
|
|
|
|
|
|
ServerInfo,
|
|
|
|
|
|
ListLists,
|
|
|
|
|
|
DescribeList,
|
|
|
|
|
|
SearchSchema,
|
|
|
|
|
|
QueryList,
|
2026-09-24 11:58:23 +00:00
|
|
|
|
RunSelect,
|
|
|
|
|
|
InsertRow,
|
|
|
|
|
|
UpdateRow,
|
|
|
|
|
|
DeleteRow
|
2026-09-18 13:47:23 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
2026-09-17 09:01:14 +00:00
|
|
|
|
/// <summary>
|
2026-09-24 11:58:23 +00:00
|
|
|
|
/// <c>McpServers.Invoke</c> (/mcp ucunun kendisinde aranir) disinda istenen yetki. Iki
|
|
|
|
|
|
/// turdur: MCP uzerinden her degisiklik <c>McpServers.Write</c> ister; ham SQL liste
|
|
|
|
|
|
/// yetkilerini astigi icin uygulamadaki SQL Query Manager yetkisini ister. Listede olmayan
|
|
|
|
|
|
/// araclar okumadir ve arkadaki servisin kendi yetkisiyle suzulur. MCP yetki vermez:
|
|
|
|
|
|
/// Wizard, Custom Components ve ekran C/U/D yetkileri ayrica aranir.
|
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-24 11:58:23 +00:00
|
|
|
|
[CreateTable] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
|
|
|
|
|
[DeployWizard] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
|
|
|
|
|
[DeleteWizard] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
|
|
|
|
|
[StartDevRequest] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
2026-09-28 09:28:56 +00:00
|
|
|
|
[SaveDevRequestAnalysis] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
2026-09-24 11:58:23 +00:00
|
|
|
|
[AppendDevRequestNote] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
2026-09-24 13:29:53 +00:00
|
|
|
|
[AddDevRequestSubTasks] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
2026-09-24 11:58:23 +00:00
|
|
|
|
[SaveComponent] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
|
|
|
|
|
[DeleteComponent] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
2026-10-01 12:01:57 +00:00
|
|
|
|
[SaveReportCategory] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
|
|
|
|
|
[SaveReportTemplate] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
|
|
|
|
|
[DeleteReportTemplate] = PlatformConsts.AppCodes.DeveloperKits.McpServers.Write,
|
2026-09-24 11:58:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Arkadaki servisin <c>[Authorize]</c> attribute'u ile istedigi yetkiler. Attribute ile
|
|
|
|
|
|
/// reddedilen cagri eksik yetkinin adini tasimaz; kullaniciya hangi yetkinin eksik oldugunu
|
|
|
|
|
|
/// soyleyebilmek icin burada tutulur. Kodda adiyla istenen yetkiler (ekran C/R/U/D,
|
|
|
|
|
|
/// <c>Wizards.Create/Update</c>, Custom Components, <c>App.DevRequests.Update</c>) reddi zaten
|
|
|
|
|
|
/// adiyla bildirdigi icin buraya yazilmaz.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static readonly IReadOnlyDictionary<string, string[]> ServicePermissions = new Dictionary<string, string[]>
|
|
|
|
|
|
{
|
|
|
|
|
|
[ListWizards] = [PlatformConsts.AppCodes.Listforms.Wizard],
|
|
|
|
|
|
[GetWizard] = [PlatformConsts.AppCodes.Listforms.Wizard],
|
|
|
|
|
|
[VerifyWizard] = [PlatformConsts.AppCodes.Listforms.Wizard],
|
|
|
|
|
|
[DeployWizard] = [PlatformConsts.AppCodes.Listforms.Wizard],
|
2026-09-24 13:29:53 +00:00
|
|
|
|
[DeleteWizard] = [PlatformConsts.AppCodes.Listforms.Wizard, PlatformConsts.AppCodes.Listforms.Wizards.Delete, PlatformConsts.AppCodes.SqlQueryManagers.Default],
|
2026-09-17 09:01:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-09-24 11:58:23 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Bir aracin cagrisinda aranabilecek, adi bilinen yetkiler: uc kapisi (Invoke), MCP kapisi
|
|
|
|
|
|
/// (<see cref="RequiredPermissions"/>) ve arkadaki servis (<see cref="ServicePermissions"/>).
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static IEnumerable<string> KnownPermissionsOf(string? toolName)
|
|
|
|
|
|
{
|
|
|
|
|
|
yield return PlatformConsts.AppCodes.DeveloperKits.McpServers.Invoke;
|
|
|
|
|
|
|
|
|
|
|
|
if (toolName is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
yield break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (RequiredPermissions.TryGetValue(toolName, out var required))
|
|
|
|
|
|
{
|
|
|
|
|
|
yield return required;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ServicePermissions.TryGetValue(toolName, out var service))
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var permission in service)
|
|
|
|
|
|
{
|
|
|
|
|
|
yield return permission;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
}
|