From 4687a057bc0c7e26f7d7ae402be3e62848a9990e Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Sun, 19 Oct 2025 16:32:31 +1100 Subject: [PATCH 1/9] fix claude script --- .../run-for-claude.sh | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Samples/NucliaDbClient.McpServer/run-for-claude.sh b/Samples/NucliaDbClient.McpServer/run-for-claude.sh index a0a85194..7f65988e 100755 --- a/Samples/NucliaDbClient.McpServer/run-for-claude.sh +++ b/Samples/NucliaDbClient.McpServer/run-for-claude.sh @@ -1,13 +1,19 @@ #!/bin/bash -# Run script for Claude MCP integration -# This script is called by Claude to start the MCP server +# Add the NucliaDB MCP server to Claude Code +# This allows Claude Code to interact with NucliaDB via the Model Context Protocol -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Get the absolute path to the project directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_PATH="$SCRIPT_DIR/NucliaDbClient.McpServer.csproj" -# Set environment variable for NucliaDB URL -export NUCLIA_BASE_URL="http://localhost:8080/api/v1" +# Add the MCP server to Claude Code configuration +claude mcp add nuclia-db dotnet run --project "$PROJECT_PATH" --env NUCLIA_BASE_URL=http://localhost:8080/api/v1 -# Run the MCP server -cd "$SCRIPT_DIR" -exec dotnet run --no-build +echo "NucliaDB MCP server added to Claude Code!" +echo "" +echo "Make sure NucliaDB is running before using the MCP tools:" +echo " cd $SCRIPT_DIR && ./start-mcp-server.sh" +echo "" +echo "You can verify the server is configured by running:" +echo " claude-code mcp list" From 976c3ac0744442adec54f143dbdb8f6ed642a1f0 Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Sun, 19 Oct 2025 16:41:09 +1100 Subject: [PATCH 2/9] get the mcp up and running --- .../NucliaDbClient.McpServer.csproj | 3 +- Samples/NucliaDbClient.McpServer/Program.cs | 34 ++++-- .../run-for-claude.sh | 36 +++++- .../Generated/NucliaDbMcpTools.g.cs | 112 ++++++++++++++++++ 4 files changed, 165 insertions(+), 20 deletions(-) diff --git a/Samples/NucliaDbClient.McpServer/NucliaDbClient.McpServer.csproj b/Samples/NucliaDbClient.McpServer/NucliaDbClient.McpServer.csproj index 30efeb44..a7b94ce1 100644 --- a/Samples/NucliaDbClient.McpServer/NucliaDbClient.McpServer.csproj +++ b/Samples/NucliaDbClient.McpServer/NucliaDbClient.McpServer.csproj @@ -2,9 +2,10 @@ Exe net9.0 - CA1303;CA2000 + CA1303;CA2000;CA2007;IDE0005 + diff --git a/Samples/NucliaDbClient.McpServer/Program.cs b/Samples/NucliaDbClient.McpServer/Program.cs index 1c9fbb59..ce6bd54a 100644 --- a/Samples/NucliaDbClient.McpServer/Program.cs +++ b/Samples/NucliaDbClient.McpServer/Program.cs @@ -1,16 +1,24 @@ using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using ModelContextProtocol.Server; using NucliaDB.Mcp; +var builder = Host.CreateApplicationBuilder(args); + +// Configure logging to stderr to not interfere with stdio MCP protocol +builder.Logging.AddConsole(consoleLogOptions => +{ + consoleLogOptions.LogToStandardErrorThreshold = LogLevel.Trace; +}); + // Get the NucliaDB base URL from environment or use default var nucleaBaseUrl = Environment.GetEnvironmentVariable("NUCLIA_BASE_URL") ?? "http://localhost:8080/api/v1"; -// Create a simple HTTP client factory -var services = new ServiceCollection(); - // Configure HttpClient with base URL -services.AddHttpClient( - "default", +builder.Services.AddHttpClient( + string.Empty, client => { client.BaseAddress = new Uri(nucleaBaseUrl); @@ -19,13 +27,13 @@ ); // Add the NucliaDB tools to DI -services.AddSingleton(); - -var serviceProvider = services.BuildServiceProvider(); +builder.Services.AddSingleton(); -// TODO: Wire up MCP server when ModelContextProtocol API stabilizes -Console.WriteLine("NucliaDB MCP Server - MCP tools generated successfully!"); -Console.WriteLine($"Configured for NucliaDB at: {nucleaBaseUrl}"); -Console.WriteLine("Ready to integrate with ModelContextProtocol when API is stable."); +// Add MCP server with stdio transport and tools from assembly +builder.Services + .AddMcpServer() + .WithStdioServerTransport() + .WithToolsFromAssembly(); -await Task.CompletedTask.ConfigureAwait(false); +var host = builder.Build(); +await host.RunAsync(); diff --git a/Samples/NucliaDbClient.McpServer/run-for-claude.sh b/Samples/NucliaDbClient.McpServer/run-for-claude.sh index 7f65988e..eece1073 100755 --- a/Samples/NucliaDbClient.McpServer/run-for-claude.sh +++ b/Samples/NucliaDbClient.McpServer/run-for-claude.sh @@ -3,17 +3,41 @@ # Add the NucliaDB MCP server to Claude Code # This allows Claude Code to interact with NucliaDB via the Model Context Protocol +set -e + # Get the absolute path to the project directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_PATH="$SCRIPT_DIR/NucliaDbClient.McpServer.csproj" +# Find the dotnet executable +DOTNET_PATH=$(which dotnet) + +echo "Configuring NucliaDB MCP server for Claude Code..." +echo " Script directory: $SCRIPT_DIR" +echo " Project path: $PROJECT_PATH" +echo " Dotnet path: $DOTNET_PATH" +echo "" + # Add the MCP server to Claude Code configuration -claude mcp add nuclia-db dotnet run --project "$PROJECT_PATH" --env NUCLIA_BASE_URL=http://localhost:8080/api/v1 +# The command structure is: claude mcp add [options] [--env KEY=value] -- [args...] +claude mcp add --transport stdio nucliadb-mcp --env NUCLIA_BASE_URL=http://localhost:8080/api/v1 -- "$DOTNET_PATH" run --project "$PROJECT_PATH" --no-build -echo "NucliaDB MCP server added to Claude Code!" echo "" -echo "Make sure NucliaDB is running before using the MCP tools:" -echo " cd $SCRIPT_DIR && ./start-mcp-server.sh" +echo "✓ NucliaDB MCP server added to Claude Code!" +echo "" +echo "Next steps:" +echo " 1. Make sure NucliaDB is running:" +echo " cd $SCRIPT_DIR && docker-compose up -d" +echo "" +echo " 2. Verify the MCP server is configured:" +echo " claude mcp list" +echo "" +echo " 3. Test the connection:" +echo " The server should appear as 'nucliadb-mcp' with a ✓ or ✗ status" echo "" -echo "You can verify the server is configured by running:" -echo " claude-code mcp list" +echo "Available MCP tools:" +echo " - Knowledge box management (get, create, delete)" +echo " - Search (full-text, semantic, catalog)" +echo " - Ask (question-answering)" +echo " - Resources (CRUD operations)" +echo " - And 100+ more NucliaDB API operations!" diff --git a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs index d7750ad3..e6db4020 100644 --- a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs +++ b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs @@ -1,12 +1,14 @@ #nullable enable using System.ComponentModel; using System.Text.Json; +using ModelContextProtocol.Server; using Outcome; using NucliaDB.Generated; namespace NucliaDB.Mcp; /// MCP server tools for NucliaDb API. +[McpServerToolType] public class NucliaDbTools(IHttpClientFactory httpClientFactory) { private static readonly JsonSerializerOptions JsonOptions = new() @@ -18,6 +20,7 @@ public class NucliaDbTools(IHttpClientFactory httpClientFactory) /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` /// slug [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + [McpServerTool] public async Task KbBySlugKbSSlugGet(string slug) { var httpClient = httpClientFactory.CreateClient(); @@ -43,6 +46,7 @@ public async Task KbBySlugKbSSlugGet(string slug) /// kbid /// xNUCLIADBROLES [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + [McpServerTool] public async Task KbKbKbidGet(string kbid, string xNUCLIADBROLES = "READER") { var httpClient = httpClientFactory.CreateClient(); @@ -73,6 +77,7 @@ public async Task KbKbKbidGet(string kbid, string xNUCLIADBROLES = "READ /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body [Description("Ask questions on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task AskKnowledgeboxEndpointKbKbidAsk(string kbid, AskRequest body, string xNdbClient = "api", bool xShowConsumption = false, string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { var httpClient = httpClientFactory.CreateClient(); @@ -113,6 +118,7 @@ public async Task AskKnowledgeboxEndpointKbKbidAsk(string kbid, AskReque /// Set to filter only hidden or only non-hidden resources. Default is to return everything /// Controls which types of metadata are serialized on resources of search results [Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task CatalogGetKbKbidCatalog(string kbid, string? query = null, object? filterExpression = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int pageNumber = 0, int pageSize = 20, object? withStatus = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, object? hidden = null, List? show = null) { var httpClient = httpClientFactory.CreateClient(); @@ -138,6 +144,7 @@ public async Task CatalogGetKbKbidCatalog(string kbid, string? query = n /// kbid /// Request body [Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task CatalogPostKbKbidCatalog(string kbid, CatalogRequest body) { var httpClient = httpClientFactory.CreateClient(); @@ -162,6 +169,7 @@ public async Task CatalogPostKbKbidCatalog(string kbid, CatalogRequest b /// Current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` /// kbid [Description("Current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task ConfigurationKbKbidConfigurationGet(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -187,6 +195,7 @@ public async Task ConfigurationKbKbidConfigurationGet(string kbid) /// kbid /// Request body [Description("Update current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task ConfigurationKbKbidConfigurationPatch(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -212,6 +221,7 @@ public async Task ConfigurationKbKbidConfigurationPatch(string kbid, obj /// kbid /// Request body [Description("Create configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task SetConfigurationKbKbidConfiguration(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -238,6 +248,7 @@ public async Task SetConfigurationKbKbidConfiguration(string kbid, objec /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. /// xNUCLIADBROLES [Description("Summary of amount of different things inside a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task KnowledgeboxCountersKbKbidCounters(string kbid, bool debug = false, string xNUCLIADBROLES = "READER") { var httpClient = httpClientFactory.CreateClient(); @@ -263,6 +274,7 @@ public async Task KnowledgeboxCountersKbKbidCounters(string kbid, bool d /// kbid /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task SetCustomSynonymsKbKbidCustomSynonyms(string kbid, KnowledgeBoxSynonyms body) { var httpClient = httpClientFactory.CreateClient(); @@ -287,6 +299,7 @@ public async Task SetCustomSynonymsKbKbidCustomSynonyms(string kbid, Kno /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` /// kbid [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task CustomSynonymsKbKbidCustomSynonymsDelete(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -311,6 +324,7 @@ public async Task CustomSynonymsKbKbidCustomSynonymsDelete(string kbid) /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task CustomSynonymsKbKbidCustomSynonymsGet(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -337,6 +351,7 @@ public async Task CustomSynonymsKbKbidCustomSynonymsGet(string kbid) /// group /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UpdateEntitiesGroupKbKbidEntitiesgroupGroup(string kbid, string group, UpdateEntitiesGroupPayload body) { var httpClient = httpClientFactory.CreateClient(); @@ -362,6 +377,7 @@ public async Task UpdateEntitiesGroupKbKbidEntitiesgroupGroup(string kbi /// kbid /// group [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task EntitiesKbKbidEntitiesgroupGroupDelete(string kbid, string group) { var httpClient = httpClientFactory.CreateClient(); @@ -387,6 +403,7 @@ public async Task EntitiesKbKbidEntitiesgroupGroupDelete(string kbid, st /// kbid /// group [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task EntityKbKbidEntitiesgroupGroupGet(string kbid, string group) { var httpClient = httpClientFactory.CreateClient(); @@ -412,6 +429,7 @@ public async Task EntityKbKbidEntitiesgroupGroupGet(string kbid, string /// kbid /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task CreateEntitiesGroupKbKbidEntitiesgroups(string kbid, CreateEntitiesGroupPayload body) { var httpClient = httpClientFactory.CreateClient(); @@ -437,6 +455,7 @@ public async Task CreateEntitiesGroupKbKbidEntitiesgroups(string kbid, C /// kbid /// showEntities [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task EntitiesKbKbidEntitiesgroupsGet(string kbid, bool showEntities = false) { var httpClient = httpClientFactory.CreateClient(); @@ -462,6 +481,7 @@ public async Task EntitiesKbKbidEntitiesgroupsGet(string kbid, bool show /// kbid /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task StartKbExportEndpointKbKbidExport(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -487,6 +507,7 @@ public async Task StartKbExportEndpointKbKbidExport(string kbid, object /// kbid /// exportId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + [McpServerTool] public async Task DownloadExportKbEndpointKbKbidExportExportId(string kbid, string exportId) { var httpClient = httpClientFactory.CreateClient(); @@ -512,6 +533,7 @@ public async Task DownloadExportKbEndpointKbKbidExportExportId(string kb /// kbid /// exportId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + [McpServerTool] public async Task ExportStatusEndpointKbKbidExportExportIdStatusGet(string kbid, string exportId) { var httpClient = httpClientFactory.CreateClient(); @@ -537,6 +559,7 @@ public async Task ExportStatusEndpointKbKbidExportExportIdStatusGet(stri /// kbid /// Request body [Description("Add a extract strategy to a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task AddStrategyKbKbidExtractStrategies(string kbid, ExtractConfig body) { var httpClient = httpClientFactory.CreateClient(); @@ -561,6 +584,7 @@ public async Task AddStrategyKbKbidExtractStrategies(string kbid, Extrac /// Get available extract strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` /// kbid [Description("Get available extract strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task ExtractStrategiesKbKbidExtractStrategiesGet(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -586,6 +610,7 @@ public async Task ExtractStrategiesKbKbidExtractStrategiesGet(string kbi /// kbid /// strategyId [Description("Removes a extract strategy from a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task StrategyKbKbidExtractStrategiesStrategyStrategyIdDelete(string kbid, string strategyId) { var httpClient = httpClientFactory.CreateClient(); @@ -611,6 +636,7 @@ public async Task StrategyKbKbidExtractStrategiesStrategyStrategyIdDelet /// kbid /// strategyId [Description("Get extract strategy for a given id --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task ExtractStrategyFromIdKbKbidExtractStrategiesStrategyStrategyIdGet(string kbid, string strategyId) { var httpClient = httpClientFactory.CreateClient(); @@ -639,6 +665,7 @@ public async Task ExtractStrategyFromIdKbKbidExtractStrategiesStrategySt /// xForwardedFor /// Request body [Description("Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, FeedbackRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -693,6 +720,7 @@ public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, Feedba /// xNucliadbUser /// xForwardedFor [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task FindKnowledgeboxKbKbidFind(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, object? topK = null, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string rankFusion = "rrf", object? reranker = null, object? searchConfiguration = null, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -721,6 +749,7 @@ public async Task FindKnowledgeboxKbKbidFind(string kbid, string? query /// xForwardedFor /// Request body [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -749,6 +778,7 @@ public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindReques /// xForwardedFor /// Request body [Description("Search on the Knowledge Box graph and retrieve triplets of vertex-edge-vertex --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task GraphSearchKnowledgeboxKbKbidGraph(string kbid, GraphSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -777,6 +807,7 @@ public async Task GraphSearchKnowledgeboxKbKbidGraph(string kbid, GraphS /// xForwardedFor /// Request body [Description("Search on the Knowledge Box graph and retrieve nodes (vertices) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(string kbid, GraphNodesSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -805,6 +836,7 @@ public async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(string kb /// xForwardedFor /// Request body [Description("Search on the Knowledge Box graph and retrieve relations (edges) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRelations(string kbid, GraphRelationsSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -830,6 +862,7 @@ public async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRelations(s /// kbid /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task StartKbImportEndpointKbKbidImport(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -855,6 +888,7 @@ public async Task StartKbImportEndpointKbKbidImport(string kbid, object /// kbid /// importId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + [McpServerTool] public async Task ImportStatusEndpointKbKbidImportImportIdStatusGet(string kbid, string importId) { var httpClient = httpClientFactory.CreateClient(); @@ -881,6 +915,7 @@ public async Task ImportStatusEndpointKbKbidImportImportIdStatusGet(stri /// labelset /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task SetLabelsetEndpointKbKbidLabelsetLabelset(string kbid, string labelset, LabelSet body) { var httpClient = httpClientFactory.CreateClient(); @@ -906,6 +941,7 @@ public async Task SetLabelsetEndpointKbKbidLabelsetLabelset(string kbid, /// kbid /// labelset [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task LabelsetEndpointKbKbidLabelsetLabelsetDelete(string kbid, string labelset) { var httpClient = httpClientFactory.CreateClient(); @@ -931,6 +967,7 @@ public async Task LabelsetEndpointKbKbidLabelsetLabelsetDelete(string kb /// kbid /// labelset [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task LabelsetEndpointKbKbidLabelsetLabelsetGet(string kbid, string labelset) { var httpClient = httpClientFactory.CreateClient(); @@ -955,6 +992,7 @@ public async Task LabelsetEndpointKbKbidLabelsetLabelsetGet(string kbid, /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task LabelsetsEndointKbKbidLabelsetsGet(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -980,6 +1018,7 @@ public async Task LabelsetsEndointKbKbidLabelsetsGet(string kbid) /// kbid /// modelId [Description("Get metadata for a particular model --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task ModelKbKbidModelModelIdGet(string kbid, string modelId) { var httpClient = httpClientFactory.CreateClient(); @@ -1004,6 +1043,7 @@ public async Task ModelKbKbidModelModelIdGet(string kbid, string modelId /// Get available models --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` /// kbid [Description("Get available models --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task ModelsKbKbidModelsGet(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -1030,6 +1070,7 @@ public async Task ModelsKbKbidModelsGet(string kbid) /// modelId /// filename [Description("Download the trained model or any other generated file as a result of a training task on a Knowledge Box. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task DownloadModelKbKbidModelsModelIdFilename(string kbid, string modelId, string filename) { var httpClient = httpClientFactory.CreateClient(); @@ -1054,6 +1095,7 @@ public async Task DownloadModelKbKbidModelsModelIdFilename(string kbid, /// Provides a stream of activity notifications for the given Knowledge Box. The stream will be automatically closed after 2 minutes. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid [Description("Provides a stream of activity notifications for the given Knowledge Box. The stream will be automatically closed after 2 minutes. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task NotificationsEndpointKbKbidNotifications(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -1083,6 +1125,7 @@ public async Task NotificationsEndpointKbKbidNotifications(string kbid) /// xForwardedFor /// Request body [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task PredictProxyEndpointKbKbidPredictEndpoint(string kbid, string endpoint, object body, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1111,6 +1154,7 @@ public async Task PredictProxyEndpointKbKbidPredictEndpoint(string kbid, /// xNdbClient /// xForwardedFor [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task PredictProxyEndpointKbKbidPredictEndpoint2(string kbid, string endpoint, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1138,6 +1182,7 @@ public async Task PredictProxyEndpointKbKbidPredictEndpoint2(string kbid /// scheduled /// limit [Description("Provides the status of the processing of the given Knowledge Box. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ProcessingStatusKbKbidProcessingStatus(string kbid, object? cursor = null, object? scheduled = null, int limit = 20) { var httpClient = httpClientFactory.CreateClient(); @@ -1167,6 +1212,7 @@ public async Task ProcessingStatusKbKbidProcessingStatus(string kbid, ob /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task TusPostRidPrefixKbKbidResourcePathRidFileFieldTusupload(string kbid, string pathRid, string field, object body, object? xExtractStrategy = null, object? xSplitStrategy = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1194,6 +1240,7 @@ public async Task TusPostRidPrefixKbKbidResourcePathRidFileFieldTusuploa /// field /// uploadId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UploadInformationKbKbidResourcePathRidFileFieldTusuploadUploadId(string kbid, string pathRid, string field, string uploadId) { var httpClient = httpClientFactory.CreateClient(); @@ -1227,6 +1274,7 @@ public async Task UploadInformationKbKbidResourcePathRidFileFieldTusuplo /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. /// Request body [Description("Upload a file as a field on an existing resource, if the field exists will return a conflict (419) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UploadRidPrefixKbKbidResourcePathRidFileFieldUpload(string kbid, string pathRid, string field, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1256,6 +1304,7 @@ public async Task UploadRidPrefixKbKbidResourcePathRidFileFieldUpload(st /// xNUCLIADBROLES /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ModifyResourceRidPrefixKbKbidResourceRid(string kbid, string rid, UpdateResourcePayload body, string? xNucliadbUser = null, bool xSkipStore = false, string xNUCLIADBROLES = "WRITER") { var httpClient = httpClientFactory.CreateClient(); @@ -1282,6 +1331,7 @@ public async Task ModifyResourceRidPrefixKbKbidResourceRid(string kbid, /// rid /// xNUCLIADBROLES [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ResourceRidPrefixKbKbidResourceRidDelete(string kbid, string rid, string xNUCLIADBROLES = "WRITER") { var httpClient = httpClientFactory.CreateClient(); @@ -1313,6 +1363,7 @@ public async Task ResourceRidPrefixKbKbidResourceRidDelete(string kbid, /// xForwardedFor /// xNUCLIADBROLES [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ResourceByUuidKbKbidResourceRidGet(string kbid, string rid, List? show = null, List? fieldType = null, List? extracted = null, string? xNucliadbUser = null, string? xForwardedFor = null, string xNUCLIADBROLES = "READER") { var httpClient = httpClientFactory.CreateClient(); @@ -1344,6 +1395,7 @@ public async Task ResourceByUuidKbKbidResourceRidGet(string kbid, string /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body [Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ResourceAskEndpointByUuidKbKbidResourceRidAsk(string kbid, string rid, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { var httpClient = httpClientFactory.CreateClient(); @@ -1371,6 +1423,7 @@ public async Task ResourceAskEndpointByUuidKbKbidResourceRidAsk(string k /// fieldId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldConversationRidPrefixKbKbidResourceRidConversationFieldId(string kbid, string rid, string fieldId, InputConversationField body) { var httpClient = httpClientFactory.CreateClient(); @@ -1399,6 +1452,7 @@ public async Task AddResourceFieldConversationRidPrefixKbKbidResourceRid /// messageId /// fileNum [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task DownloadFieldConversationAttachmentRidPrefixKbKbidResourceRidConversationFieldIdDownloadFieldMessageIdFileNum(string kbid, string rid, string fieldId, string messageId, int fileNum) { var httpClient = httpClientFactory.CreateClient(); @@ -1426,6 +1480,7 @@ public async Task DownloadFieldConversationAttachmentRidPrefixKbKbidReso /// fieldId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AppendMessagesToConversationFieldRidPrefixKbKbidResourceRidConversationFieldIdMessages(string kbid, string rid, string fieldId, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -1454,6 +1509,7 @@ public async Task AppendMessagesToConversationFieldRidPrefixKbKbidResour /// If set to true, file fields will not be saved in the blob storage. They will only be sent to process. /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldFileRidPrefixKbKbidResourceRidFileFieldId(string kbid, string rid, string fieldId, FileField body, bool xSkipStore = false) { var httpClient = httpClientFactory.CreateClient(); @@ -1481,6 +1537,7 @@ public async Task AddResourceFieldFileRidPrefixKbKbidResourceRidFileFiel /// fieldId /// inline [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task DownloadFieldFileRidPrefixKbKbidResourceRidFileFieldIdDownloadField(string kbid, string rid, string fieldId, bool inline = false) { var httpClient = httpClientFactory.CreateClient(); @@ -1511,6 +1568,7 @@ public async Task DownloadFieldFileRidPrefixKbKbidResourceRidFileFieldId /// If a file is password protected, the password must be provided here for the file to be processed /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ReprocessFileFieldKbKbidResourceRidFileFieldIdReprocess(string kbid, string rid, string fieldId, object body, bool resetTitle = false, string? xNucliadbUser = null, object? xFilePassword = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1539,6 +1597,7 @@ public async Task ReprocessFileFieldKbKbidResourceRidFileFieldIdReproces /// uploadId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task TusPatchRidPrefixKbKbidResourceRidFileFieldTusuploadUploadId(string kbid, string rid, string field, string uploadId, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -1566,6 +1625,7 @@ public async Task TusPatchRidPrefixKbKbidResourceRidFileFieldTusuploadUp /// fieldId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldLinkRidPrefixKbKbidResourceRidLinkFieldId(string kbid, string rid, string fieldId, LinkField body) { var httpClient = httpClientFactory.CreateClient(); @@ -1593,6 +1653,7 @@ public async Task AddResourceFieldLinkRidPrefixKbKbidResourceRidLinkFiel /// reindexVectors /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ReindexResourceRidPrefixKbKbidResourceRidReindex(string kbid, string rid, object body, bool reindexVectors = false) { var httpClient = httpClientFactory.CreateClient(); @@ -1621,6 +1682,7 @@ public async Task ReindexResourceRidPrefixKbKbidResourceRidReindex(strin /// xNucliadbUser /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ReprocessResourceRidPrefixKbKbidResourceRidReprocess(string kbid, string rid, object body, bool resetTitle = false, string? xNucliadbUser = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1648,6 +1710,7 @@ public async Task ReprocessResourceRidPrefixKbKbidResourceRidReprocess(s /// xNucliadbUser /// Request body [Description("Run Agents on Resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task RunAgentsByUuidKbKbidResourceRidRunAgents(string kbid, string rid, ResourceAgentsRequest body, string? xNucliadbUser = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1688,6 +1751,7 @@ public async Task RunAgentsByUuidKbKbidResourceRidRunAgents(string kbid, /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. /// xNdbClient [Description("Search on a single resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ResourceSearchKbKbidResourceRidSearch(string kbid, string rid, string query, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, object? sortField = null, string sortOrder = "desc", object? topK = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, bool highlight = false, bool debug = false, string xNdbClient = "api") { var httpClient = httpClientFactory.CreateClient(); @@ -1716,6 +1780,7 @@ public async Task ResourceSearchKbKbidResourceRidSearch(string kbid, str /// xNUCLIADBROLES /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldTextRidPrefixKbKbidResourceRidTextFieldId(string kbid, string rid, string fieldId, TextField body, string xNUCLIADBROLES = "WRITER") { var httpClient = httpClientFactory.CreateClient(); @@ -1743,6 +1808,7 @@ public async Task AddResourceFieldTextRidPrefixKbKbidResourceRidTextFiel /// fieldType /// fieldId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldIdDelete(string kbid, string rid, string fieldType, string fieldId) { var httpClient = httpClientFactory.CreateClient(); @@ -1773,6 +1839,7 @@ public async Task ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldI /// extracted /// page [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldIdGet(string kbid, string rid, string fieldType, string fieldId, List? show = null, List? extracted = null, object? page = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1801,6 +1868,7 @@ public async Task ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldI /// fieldId /// downloadField [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task DownloadExtractFileRidPrefixKbKbidResourceRidFieldTypeFieldIdDownloadExtractedDownloadField(string kbid, string rid, string fieldType, string fieldId, string downloadField) { var httpClient = httpClientFactory.CreateClient(); @@ -1829,6 +1897,7 @@ public async Task DownloadExtractFileRidPrefixKbKbidResourceRidFieldType /// xNUCLIADBROLES /// Request body [Description("Create a new Resource in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task CreateResourceKbKbidResources(string kbid, CreateResourcePayload body, bool xSkipStore = false, string? xNucliadbUser = null, string xNUCLIADBROLES = "WRITER") { var httpClient = httpClientFactory.CreateClient(); @@ -1856,6 +1925,7 @@ public async Task CreateResourceKbKbidResources(string kbid, CreateResou /// Page size /// xNUCLIADBROLES [Description("List of resources of a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ListResourcesKbKbidResources(string kbid, int page = 0, int size = 20, string xNUCLIADBROLES = "READER") { var httpClient = httpClientFactory.CreateClient(); @@ -1880,6 +1950,7 @@ public async Task ListResourcesKbKbidResources(string kbid, int page = 0 /// Get jsonschema definition to update the `learning_configuration` of your Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` /// kbid [Description("Get jsonschema definition to update the `learning_configuration` of your Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task SchemaForConfigurationUpdatesKbKbidSchemaGet(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -1935,6 +2006,7 @@ public async Task SchemaForConfigurationUpdatesKbKbidSchemaGet(string kb /// xNucliadbUser /// xForwardedFor [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task SearchKnowledgeboxKbKbidSearch(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int topK = 20, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1963,6 +2035,7 @@ public async Task SearchKnowledgeboxKbKbidSearch(string kbid, string? qu /// xForwardedFor /// Request body [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task SearchPostKnowledgeboxKbKbidSearch(string kbid, SearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -1987,6 +2060,7 @@ public async Task SearchPostKnowledgeboxKbKbidSearch(string kbid, Search /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ListSearchConfigurationsKbKbidSearchConfigurations(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -2013,6 +2087,7 @@ public async Task ListSearchConfigurationsKbKbidSearchConfigurations(str /// configName /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task CreateSearchConfigurationKbKbidSearchConfigurationsConfigName(string kbid, string configName, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -2039,6 +2114,7 @@ public async Task CreateSearchConfigurationKbKbidSearchConfigurationsCon /// configName /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UpdateSearchConfigurationKbKbidSearchConfigurationsConfigName(string kbid, string configName, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -2064,6 +2140,7 @@ public async Task UpdateSearchConfigurationKbKbidSearchConfigurationsCon /// kbid /// configName [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task SearchConfigurationKbKbidSearchConfigurationsConfigNameDelete(string kbid, string configName) { var httpClient = httpClientFactory.CreateClient(); @@ -2089,6 +2166,7 @@ public async Task SearchConfigurationKbKbidSearchConfigurationsConfigNam /// kbid /// configName [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task SearchConfigurationKbKbidSearchConfigurationsConfigNameGet(string kbid, string configName) { var httpClient = httpClientFactory.CreateClient(); @@ -2117,6 +2195,7 @@ public async Task SearchConfigurationKbKbidSearchConfigurationsConfigNam /// xNucliadbUser /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ModifyResourceRslugPrefixKbKbidSlugRslug(string kbid, string rslug, UpdateResourcePayload body, bool xSkipStore = false, string? xNucliadbUser = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2142,6 +2221,7 @@ public async Task ModifyResourceRslugPrefixKbKbidSlugRslug(string kbid, /// kbid /// rslug [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ResourceRslugPrefixKbKbidSlugRslugDelete(string kbid, string rslug) { var httpClient = httpClientFactory.CreateClient(); @@ -2172,6 +2252,7 @@ public async Task ResourceRslugPrefixKbKbidSlugRslugDelete(string kbid, /// xNucliadbUser /// xForwardedFor [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ResourceBySlugKbKbidSlugRslugGet(string kbid, string rslug, List? show = null, List? fieldType = null, List? extracted = null, string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2199,6 +2280,7 @@ public async Task ResourceBySlugKbKbidSlugRslugGet(string kbid, string r /// fieldId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldConversationRslugPrefixKbKbidSlugRslugConversationFieldId(string kbid, string rslug, string fieldId, InputConversationField body) { var httpClient = httpClientFactory.CreateClient(); @@ -2227,6 +2309,7 @@ public async Task AddResourceFieldConversationRslugPrefixKbKbidSlugRslug /// messageId /// fileNum [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task DownloadFieldConversationRslugPrefixKbKbidSlugRslugConversationFieldIdDownloadFieldMessageIdFileNum(string kbid, string rslug, string fieldId, string messageId, int fileNum) { var httpClient = httpClientFactory.CreateClient(); @@ -2254,6 +2337,7 @@ public async Task DownloadFieldConversationRslugPrefixKbKbidSlugRslugCon /// fieldId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AppendMessagesToConversationFieldRslugPrefixKbKbidSlugRslugConversationFieldIdMessages(string kbid, string rslug, string fieldId, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -2282,6 +2366,7 @@ public async Task AppendMessagesToConversationFieldRslugPrefixKbKbidSlug /// If set to true, file fields will not be saved in the blob storage. They will only be sent to process. /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldFileRslugPrefixKbKbidSlugRslugFileFieldId(string kbid, string rslug, string fieldId, FileField body, bool xSkipStore = false) { var httpClient = httpClientFactory.CreateClient(); @@ -2309,6 +2394,7 @@ public async Task AddResourceFieldFileRslugPrefixKbKbidSlugRslugFileFiel /// fieldId /// inline [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task DownloadFieldFileRslugPrefixKbKbidSlugRslugFileFieldIdDownloadField(string kbid, string rslug, string fieldId, bool inline = false) { var httpClient = httpClientFactory.CreateClient(); @@ -2338,6 +2424,7 @@ public async Task DownloadFieldFileRslugPrefixKbKbidSlugRslugFileFieldId /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task TusPostRslugPrefixKbKbidSlugRslugFileFieldTusupload(string kbid, string rslug, string field, object body, object? xExtractStrategy = null, object? xSplitStrategy = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2366,6 +2453,7 @@ public async Task TusPostRslugPrefixKbKbidSlugRslugFileFieldTusupload(st /// uploadId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task TusPatchRslugPrefixKbKbidSlugRslugFileFieldTusuploadUploadId(string kbid, string rslug, string field, string uploadId, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -2393,6 +2481,7 @@ public async Task TusPatchRslugPrefixKbKbidSlugRslugFileFieldTusuploadUp /// field /// uploadId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UploadInformationKbKbidSlugRslugFileFieldTusuploadUploadId(string kbid, string rslug, string field, string uploadId) { var httpClient = httpClientFactory.CreateClient(); @@ -2426,6 +2515,7 @@ public async Task UploadInformationKbKbidSlugRslugFileFieldTusuploadUplo /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. /// Request body [Description("Upload a file as a field on an existing resource, if the field exists will return a conflict (419) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UploadRslugPrefixKbKbidSlugRslugFileFieldUpload(string kbid, string rslug, string field, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2453,6 +2543,7 @@ public async Task UploadRslugPrefixKbKbidSlugRslugFileFieldUpload(string /// fieldId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldLinkRslugPrefixKbKbidSlugRslugLinkFieldId(string kbid, string rslug, string fieldId, LinkField body) { var httpClient = httpClientFactory.CreateClient(); @@ -2480,6 +2571,7 @@ public async Task AddResourceFieldLinkRslugPrefixKbKbidSlugRslugLinkFiel /// reindexVectors /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ReindexResourceRslugPrefixKbKbidSlugRslugReindex(string kbid, string rslug, object body, bool reindexVectors = false) { var httpClient = httpClientFactory.CreateClient(); @@ -2508,6 +2600,7 @@ public async Task ReindexResourceRslugPrefixKbKbidSlugRslugReindex(strin /// xNucliadbUser /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ReprocessResourceRslugPrefixKbKbidSlugRslugReprocess(string kbid, string rslug, object body, bool resetTitle = false, string? xNucliadbUser = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2535,6 +2628,7 @@ public async Task ReprocessResourceRslugPrefixKbKbidSlugRslugReprocess(s /// fieldId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task AddResourceFieldTextRslugPrefixKbKbidSlugRslugTextFieldId(string kbid, string rslug, string fieldId, TextField body) { var httpClient = httpClientFactory.CreateClient(); @@ -2562,6 +2656,7 @@ public async Task AddResourceFieldTextRslugPrefixKbKbidSlugRslugTextFiel /// fieldType /// fieldId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDelete(string kbid, string rslug, string fieldType, string fieldId) { var httpClient = httpClientFactory.CreateClient(); @@ -2592,6 +2687,7 @@ public async Task ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldI /// extracted /// page [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldIdGet(string kbid, string rslug, string fieldType, string fieldId, List? show = null, List? extracted = null, object? page = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2620,6 +2716,7 @@ public async Task ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldI /// fieldId /// downloadField [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task DownloadExtractFileRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDownloadExtractedDownloadField(string kbid, string rslug, string fieldType, string fieldId, string downloadField) { var httpClient = httpClientFactory.CreateClient(); @@ -2651,6 +2748,7 @@ public async Task DownloadExtractFileRslugPrefixKbKbidSlugRslugFieldType /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body [Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task ResourceAskEndpointBySlugKbKbidSlugSlugAsk(string kbid, string slug, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { var httpClient = httpClientFactory.CreateClient(); @@ -2678,6 +2776,7 @@ public async Task ResourceAskEndpointBySlugKbKbidSlugSlugAsk(string kbid /// xNucliadbUser /// Request body [Description("Run Agents on Resource (by slug) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task RunAgentsBySlugKbKbidSlugSlugRunAgents(string kbid, string slug, ResourceAgentsRequest body, string? xNucliadbUser = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2703,6 +2802,7 @@ public async Task RunAgentsBySlugKbKbidSlugSlugRunAgents(string kbid, st /// kbid /// Request body [Description("Add a split strategy to a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task AddSplitStrategyKbKbidSplitStrategies(string kbid, SplitConfiguration body) { var httpClient = httpClientFactory.CreateClient(); @@ -2727,6 +2827,7 @@ public async Task AddSplitStrategyKbKbidSplitStrategies(string kbid, Spl /// Get available split strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` /// kbid [Description("Get available split strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task SplitStrategiesKbKbidSplitStrategiesGet(string kbid) { var httpClient = httpClientFactory.CreateClient(); @@ -2752,6 +2853,7 @@ public async Task SplitStrategiesKbKbidSplitStrategiesGet(string kbid) /// kbid /// strategyId [Description("Removes a split strategy from a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + [McpServerTool] public async Task SplitStrategyKbKbidSplitStrategiesStrategyStrategyIdDelete(string kbid, string strategyId) { var httpClient = httpClientFactory.CreateClient(); @@ -2777,6 +2879,7 @@ public async Task SplitStrategyKbKbidSplitStrategiesStrategyStrategyIdDe /// kbid /// strategyId [Description("Get split strategy for a given id --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + [McpServerTool] public async Task SplitStrategyFromIdKbKbidSplitStrategiesStrategyStrategyIdGet(string kbid, string strategyId) { var httpClient = httpClientFactory.CreateClient(); @@ -2818,6 +2921,7 @@ public async Task SplitStrategyFromIdKbKbidSplitStrategiesStrategyStrate /// xNucliadbUser /// xForwardedFor [Description("Suggestions on a knowledge box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task SuggestKnowledgeboxKbKbidSuggest(string kbid, string query, List? fields = null, List? filters = null, List? faceted = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, List? show = null, List? fieldType = null, bool debug = false, bool highlight = false, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2844,6 +2948,7 @@ public async Task SuggestKnowledgeboxKbKbidSuggest(string kbid, string q /// xShowConsumption /// Request body [Description("Summarize Your Documents --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + [McpServerTool] public async Task SummarizeEndpointKbKbidSummarize(string kbid, SummarizeRequest body, bool xShowConsumption = false) { var httpClient = httpClientFactory.CreateClient(); @@ -2871,6 +2976,7 @@ public async Task SummarizeEndpointKbKbidSummarize(string kbid, Summariz /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task TusPostKbKbidTusupload(string kbid, object body, object? xExtractStrategy = null, object? xSplitStrategy = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2899,6 +3005,7 @@ public async Task TusPostKbKbidTusupload(string kbid, object body, objec /// uploadId /// field [Description("TUS Server information")] + [McpServerTool] public async Task TusOptionsKbKbidTusupload(string kbid, object? rid = null, object? rslug = null, object? uploadId = null, object? field = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2925,6 +3032,7 @@ public async Task TusOptionsKbKbidTusupload(string kbid, object? rid = n /// uploadId /// Request body [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task KbKbidTusuploadUploadIdPatch(string kbid, string uploadId, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -2950,6 +3058,7 @@ public async Task KbKbidTusuploadUploadIdPatch(string kbid, string uploa /// kbid /// uploadId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UploadInformationKbKbidTusuploadUploadId(string kbid, string uploadId) { var httpClient = httpClientFactory.CreateClient(); @@ -2981,6 +3090,7 @@ public async Task UploadInformationKbKbidTusuploadUploadId(string kbid, /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. /// Request body [Description("Upload a file onto a Knowledge Box, field id will be file and rid will be autogenerated. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + [McpServerTool] public async Task UploadKbKbidUpload(string kbid, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) { var httpClient = httpClientFactory.CreateClient(); @@ -3006,6 +3116,7 @@ public async Task UploadKbKbidUpload(string kbid, object body, object? x /// xNUCLIADBROLES /// Request body [Description("Create a new knowledge box")] + [McpServerTool] public async Task CreateKnowledgeBoxKbs(object body, string xNUCLIADBROLES = "MANAGER") { var httpClient = httpClientFactory.CreateClient(); @@ -3030,6 +3141,7 @@ public async Task CreateKnowledgeBoxKbs(object body, string xNUCLIADBROL /// Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload [Description("Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload")] + [McpServerTool] public async Task LearningConfigurationSchemaLearningConfigurationSchema() { var httpClient = httpClientFactory.CreateClient(); From afc1352712ec63a841287a486e6671bc826d038d Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Sun, 19 Oct 2025 17:03:59 +1100 Subject: [PATCH 3/9] Filter tools --- RestClient.Net.McpGenerator.Cli/Program.cs | 29 +- .../McpServerGenerator.cs | 7 +- .../McpToolGenerator.cs | 19 +- .../NucliaDbClient.Demo.csproj | 11 - Samples/NucliaDbClient.Demo/Program.cs | 64 - Samples/NucliaDbClient.McpServer/Program.cs | 5 +- Samples/NucliaDbClient.McpServer/README.md | 88 +- Samples/NucliaDbClient.McpServer/SETUP.md | 247 -- .../SETUP_COMPLETE.md | 116 - Samples/NucliaDbClient.McpServer/STATUS.md | 98 - .../run-for-claude.sh | 79 +- .../start-mcp-server.sh | 57 - .../Generated/NucliaDbMcpTools.g.cs | 2578 ++--------------- 13 files changed, 347 insertions(+), 3051 deletions(-) delete mode 100644 Samples/NucliaDbClient.Demo/NucliaDbClient.Demo.csproj delete mode 100644 Samples/NucliaDbClient.Demo/Program.cs delete mode 100644 Samples/NucliaDbClient.McpServer/SETUP.md delete mode 100644 Samples/NucliaDbClient.McpServer/SETUP_COMPLETE.md delete mode 100644 Samples/NucliaDbClient.McpServer/STATUS.md delete mode 100755 Samples/NucliaDbClient.McpServer/start-mcp-server.sh diff --git a/RestClient.Net.McpGenerator.Cli/Program.cs b/RestClient.Net.McpGenerator.Cli/Program.cs index 87d3e29b..996eb406 100644 --- a/RestClient.Net.McpGenerator.Cli/Program.cs +++ b/RestClient.Net.McpGenerator.Cli/Program.cs @@ -41,6 +41,9 @@ static void PrintUsage() Console.WriteLine( " --ext-class Extensions class name (default: 'ApiExtensions')" ); + Console.WriteLine( + " -t, --tags Comma-separated list of OpenAPI tags to include (optional)" + ); Console.WriteLine(" -h, --help Show this help message"); } @@ -52,6 +55,7 @@ static void PrintUsage() var serverName = "ApiMcp"; var extensionsNamespace = "Generated"; var extensionsClass = "ApiExtensions"; + string? tagsFilter = null; for (var i = 0; i < args.Length; i++) { @@ -79,6 +83,10 @@ static void PrintUsage() case "--ext-class": extensionsClass = GetNextArg(args, i++, "ext-class") ?? extensionsClass; break; + case "-t" + or "--tags": + tagsFilter = GetNextArg(args, i++, "tags"); + break; default: break; } @@ -104,7 +112,8 @@ static void PrintUsage() namespaceName, serverName, extensionsNamespace, - extensionsClass + extensionsClass, + tagsFilter ); } @@ -154,13 +163,26 @@ static async Task GenerateCode(Config config) } Console.WriteLine($"Read {openApiSpec.Length} characters\n"); + + // Parse tags filter if provided + ISet? includeTags = null; + if (!string.IsNullOrWhiteSpace(config.TagsFilter)) + { + includeTags = new HashSet( + config.TagsFilter.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries), + StringComparer.OrdinalIgnoreCase + ); + Console.WriteLine($"Filtering to tags: {string.Join(", ", includeTags)}"); + } + Console.WriteLine("Generating MCP tools code..."); var result = McpServerGenerator.Generate( openApiSpec, @namespace: config.Namespace, serverName: config.ServerName, - extensionsNamespace: config.ExtensionsNamespace + extensionsNamespace: config.ExtensionsNamespace, + includeTags: includeTags ); #pragma warning disable IDE0010 @@ -186,5 +208,6 @@ internal sealed record Config( string Namespace, string ServerName, string ExtensionsNamespace, - string ExtensionsClass + string ExtensionsClass, + string? TagsFilter ); diff --git a/RestClient.Net.McpGenerator/McpServerGenerator.cs b/RestClient.Net.McpGenerator/McpServerGenerator.cs index c07da37e..3af504fc 100644 --- a/RestClient.Net.McpGenerator/McpServerGenerator.cs +++ b/RestClient.Net.McpGenerator/McpServerGenerator.cs @@ -12,13 +12,15 @@ public static class McpServerGenerator /// The namespace for generated MCP tools. /// The MCP server name. /// The namespace of the pre-generated extensions. + /// Optional set of tags to include. If specified, only operations with these tags are generated. /// A Result containing the generated C# code or error message. #pragma warning disable CA1054 public static Result Generate( string openApiContent, string @namespace, string serverName, - string extensionsNamespace + string extensionsNamespace, + ISet? includeTags = null ) #pragma warning restore CA1054 { @@ -43,7 +45,8 @@ string extensionsNamespace document, @namespace, serverName, - extensionsNamespace + extensionsNamespace, + includeTags ) ); } diff --git a/RestClient.Net.McpGenerator/McpToolGenerator.cs b/RestClient.Net.McpGenerator/McpToolGenerator.cs index a5ecf299..d44acbcc 100644 --- a/RestClient.Net.McpGenerator/McpToolGenerator.cs +++ b/RestClient.Net.McpGenerator/McpToolGenerator.cs @@ -18,12 +18,14 @@ internal static class McpToolGenerator /// The namespace for the MCP server. /// The MCP server name. /// The namespace of the extensions. + /// Optional set of tags to filter operations. If specified, only operations with these tags are generated. /// The generated MCP tools code. public static string GenerateTools( OpenApiDocument document, string @namespace, string serverName, - string extensionsNamespace + string extensionsNamespace, + ISet? includeTags = null ) { var tools = new List(); @@ -38,6 +40,21 @@ string extensionsNamespace foreach (var operation in path.Value.Operations) { + // Skip if tags filter is specified and operation doesn't match + if (includeTags != null && includeTags.Count > 0) + { + var operationTags = operation.Value.Tags; + if ( + operationTags == null + || !operationTags.Any(tag => + includeTags.Contains(tag.Name, StringComparer.OrdinalIgnoreCase) + ) + ) + { + continue; + } + } + var toolMethod = GenerateTool( path.Key, operation.Key, diff --git a/Samples/NucliaDbClient.Demo/NucliaDbClient.Demo.csproj b/Samples/NucliaDbClient.Demo/NucliaDbClient.Demo.csproj deleted file mode 100644 index 084d64b5..00000000 --- a/Samples/NucliaDbClient.Demo/NucliaDbClient.Demo.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - Exe - net9.0 - enable - - - - - - diff --git a/Samples/NucliaDbClient.Demo/Program.cs b/Samples/NucliaDbClient.Demo/Program.cs deleted file mode 100644 index 47861df9..00000000 --- a/Samples/NucliaDbClient.Demo/Program.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using NucliaDB.Generated; -using Outcome; - -// Setup HTTP client factory -var services = new ServiceCollection(); -services.AddHttpClient( - "default", - client => - { - client.BaseAddress = new Uri("http://localhost:8080/api/v1"); - client.Timeout = TimeSpan.FromSeconds(30); - } -); - -var serviceProvider = services.BuildServiceProvider(); -var httpClientFactory = serviceProvider.GetRequiredService(); -var httpClient = httpClientFactory.CreateClient("default"); - -Console.WriteLine("NucliaDB Demo - Creating and retrieving a Knowledge Box\n"); - -// Create a knowledge box -var kbSlug = $"test-kb-{DateTime.UtcNow:yyyyMMddHHmmss}"; -var createPayload = new -{ - slug = kbSlug, - title = "Test Knowledge Box", - description = "A test KB created via RestClient.Net", -}; - -Console.WriteLine($"Creating knowledge box with slug: {kbSlug}"); -var createResult = await httpClient.CreateKnowledgeBoxKbsAsync(createPayload).ConfigureAwait(false); - -var kbId = createResult switch -{ - OkKnowledgeBoxObj ok => $"Created successfully! UUID: {ok.Value.Uuid}", - ErrorKnowledgeBoxObj error => error.Value switch - { - HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {err.Body}", - HttpError.ExceptionError err => $"Exception: {err.Exception.Message}", - _ => "Unknown error", - }, -}; - -Console.WriteLine(kbId); - -// Retrieve the knowledge box by slug -Console.WriteLine($"\nRetrieving knowledge box by slug: {kbSlug}"); -var getResult = await httpClient.KbBySlugKbSSlugGetAsync(kbSlug).ConfigureAwait(false); - -var kbDetails = getResult switch -{ - OkKnowledgeBoxObjHTTPValidationError ok => - $"Retrieved KB:\n Slug: {ok.Value.Slug}\n UUID: {ok.Value.Uuid}", - ErrorKnowledgeBoxObjHTTPValidationError error => error.Value switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {err.Body}", - HttpError.ExceptionError err => $"Exception: {err.Exception.Message}", - _ => "Unknown error", - }, -}; - -Console.WriteLine(kbDetails); diff --git a/Samples/NucliaDbClient.McpServer/Program.cs b/Samples/NucliaDbClient.McpServer/Program.cs index ce6bd54a..e83ed6f1 100644 --- a/Samples/NucliaDbClient.McpServer/Program.cs +++ b/Samples/NucliaDbClient.McpServer/Program.cs @@ -30,10 +30,7 @@ builder.Services.AddSingleton(); // Add MCP server with stdio transport and tools from assembly -builder.Services - .AddMcpServer() - .WithStdioServerTransport() - .WithToolsFromAssembly(); +builder.Services.AddMcpServer().WithStdioServerTransport().WithToolsFromAssembly(); var host = builder.Build(); await host.RunAsync(); diff --git a/Samples/NucliaDbClient.McpServer/README.md b/Samples/NucliaDbClient.McpServer/README.md index dc4cc9a8..54bb27a8 100644 --- a/Samples/NucliaDbClient.McpServer/README.md +++ b/Samples/NucliaDbClient.McpServer/README.md @@ -10,27 +10,20 @@ This is a Model Context Protocol (MCP) server that provides Claude Code with acc ## Quick Start -### 1. Start NucliaDB and MCP Server +### Run the setup script ```bash cd Samples/NucliaDbClient.McpServer -./start-mcp-server.sh +./run-for-claude.sh ``` -This will: -- Start NucliaDB via docker-compose (PostgreSQL + NucliaDB containers) -- Wait for NucliaDB to be ready -- Build and run the MCP server +This ONE script does everything: +- Starts NucliaDB via docker-compose (if not already running) +- Waits for NucliaDB to be ready +- Builds the MCP server +- Adds it to Claude Code configuration -### 2. Alternative: Run MCP Server Only - -If NucliaDB is already running: - -```bash -./run-mcp-server.sh -``` - -### 3. Stop NucliaDB +### Stop NucliaDB ```bash ./stop-nucliadb.sh @@ -94,16 +87,22 @@ Then edit the file to update paths for your system. ## Available Tools -The MCP server provides access to all NucliaDB REST API operations, including: +The MCP server is **filtered to Search operations only** (18 tools) to avoid flooding Claude Code: -- **Knowledge Box Management**: Get, create, delete knowledge boxes -- **Search**: Full-text search, semantic search, catalog search - **Ask**: Question-answering on knowledge bases -- **Resources**: Create, read, update, delete resources -- **Labels & Entities**: Manage labels and entity recognition -- **Configuration**: Configure models and settings +- **Search**: Full-text search, semantic search, catalog search +- **List Resources**: Query and list knowledge box contents +- **Suggest**: Get suggestions based on queries -See the [generated MCP tools](../NucliaDbClient/Generated/NucliaDbMcpTools.g.cs) for the complete list. +The full NucliaDB API has 110+ operations across these tags: +- Search (18 tools) ✓ Currently enabled +- Resources - Resource CRUD operations +- Knowledge Boxes - KB management +- Models - Model configuration +- Knowledge Box Services - Advanced KB services +- And more... + +See the [generated MCP tools](../NucliaDbClient/Generated/NucliaDbMcpTools.g.cs) for the current filtered list. To include different operations, see the **Tag Filtering** section in Development below. ## Environment Variables @@ -166,7 +165,17 @@ dotnet run --project RestClient.Net.OpenApiGenerator.Cli/RestClient.Net.OpenApiG -n NucliaDB.Generated \ -c NucliaDBApiExtensions -# Regenerate the MCP tools +# Regenerate the MCP tools with tag filtering (recommended to reduce tool count) +# Only include Search-related tools (18 tools instead of 110) +dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator.Cli.csproj -- \ + --openapi-url Samples/NucliaDbClient/api.yaml \ + --output-file Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs \ + --namespace NucliaDB.Mcp \ + --server-name NucliaDb \ + --ext-namespace NucliaDB.Generated \ + --tags Search + +# Or generate all tools (not recommended - creates 110 tools) dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator.Cli.csproj -- \ --openapi-url Samples/NucliaDbClient/api.yaml \ --output-file Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs \ @@ -174,6 +183,39 @@ dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator --server-name NucliaDb \ --ext-namespace NucliaDB.Generated +# Or include multiple tags (e.g., Search and Resources) +dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator.Cli.csproj -- \ + --openapi-url Samples/NucliaDbClient/api.yaml \ + --output-file Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs \ + --namespace NucliaDB.Mcp \ + --server-name NucliaDb \ + --ext-namespace NucliaDB.Generated \ + --tags "Search,Resources" + # Rebuild the MCP server dotnet build Samples/NucliaDbClient.McpServer ``` + +### Tag Filtering + +The NucliaDB OpenAPI spec has many operations organized by tags. To avoid flooding Claude Code with too many tools, use the `--tags` parameter to specify which sections you want: + +**Available tags:** +- `Search` - Search and ask operations (18 tools) +- `Resources` - Resource CRUD operations +- `Knowledge Boxes` - Knowledge box management +- `Models` - Model configuration +- `Knowledge Box Services` - Advanced KB services +- And more... + +**Examples:** +```bash +# Only search operations (recommended for most use cases) +--tags Search + +# Search and resources only +--tags "Search,Resources" + +# Multiple tags +--tags "Search,Resources,Knowledge Boxes" +``` diff --git a/Samples/NucliaDbClient.McpServer/SETUP.md b/Samples/NucliaDbClient.McpServer/SETUP.md deleted file mode 100644 index 092f384b..00000000 --- a/Samples/NucliaDbClient.McpServer/SETUP.md +++ /dev/null @@ -1,247 +0,0 @@ -# NucliaDB MCP Server - Complete Setup Guide - -## ✅ What's Been Completed - -The MCP generator is **fully functional** and has successfully generated all the necessary code: - -1. ✅ **MCP Generator** - Generates MCP server tools from OpenAPI specs -2. ✅ **Generated MCP Tools** - 161KB of MCP tools code generated from NucliaDB API -3. ✅ **MCP Server Project** - Project structure with all dependencies -4. ✅ **Startup Scripts** - Shell scripts to start/stop Docker and MCP server -5. ✅ **Claude Code Configuration** - Example configuration files -6. ✅ **Parameter Ordering Fix** - Required parameters now correctly appear before optional -7. ✅ **Type Aliases** - Generated code uses clean type aliases (`OkKnowledgeBoxObj` vs verbose Result types) - -## 📋 Scripts Created - -### Start Everything (Docker + MCP Server) -```bash -cd Samples/NucliaDbClient.McpServer -./start-mcp-server.sh -``` - -This script: -- Starts docker-compose (PostgreSQL + NucliaDB) -- Waits for NucliaDB to be ready -- Builds the MCP server -- Runs the MCP server - -### Run MCP Server Only -```bash -./run-mcp-server.sh -``` - -Use this when NucliaDB is already running. - -### Stop NucliaDB -```bash -./stop-nucliadb.sh -``` - -## 🔧 Current Status - -The MCP server project compiles with attribute errors because the `ModelContextProtocol` package version `0.4.0-preview.2` may not yet expose the `McpServerToolType` and `McpServerTool` attributes in the expected way. - -### Two Options to Proceed: - -#### Option 1: Wait for Stable Package Release -The ModelContextProtocol package is in preview. When a stable version is released with proper attribute support, the server should compile without changes. - -#### Option 2: Manual Tool Registration (Working Now) -Modify `Program.cs` to manually register tools instead of using attributes: - -```csharp -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using ModelContextProtocol; -using NucliaDB.Mcp; - -var builder = Host.CreateApplicationBuilder(args); - -var nucleaBaseUrl = - Environment.GetEnvironmentVariable("NUCLIA_BASE_URL") ?? "http://localhost:8080/api/v1"; - -builder.Services.AddHttpClient( - Options.DefaultName, - client => - { - client.BaseAddress = new Uri(nucleaBaseUrl); - client.Timeout = TimeSpan.FromSeconds(30); - } -); - -// Register the tools class -builder.Services.AddSingleton(); - -// Add MCP server and register tools manually -builder.Services - .AddMcpServer(new ServerInfo(name: "nuclia-db-mcp-server", version: "1.0.0")) - .WithTools(); // Or manually add each tool method - -var host = builder.Build(); -await host.RunAsync(); -``` - -Then remove the `[McpServerToolType]` and `[McpServerTool]` attributes from the generated code. - -## 📝 Claude Code Configuration - -### macOS/Linux -Edit: `~/.config/Claude/claude_desktop_config.json` - -### Windows -Edit: `%APPDATA%/Claude/claude_desktop_config.json` - -### Configuration -```json -{ - "mcpServers": { - "nuclia-db": { - "command": "/usr/local/share/dotnet/dotnet", - "args": [ - "run", - "--project", - "/Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer/NucliaDbClient.McpServer.csproj" - ], - "env": { - "NUCLIA_BASE_URL": "http://localhost:8080/api/v1" - } - } - } -} -``` - -**Important:** Update paths: -- Find your `dotnet` path: `which dotnet` -- Use the full absolute path to the `.csproj` file - -## 🚀 Testing - -1. Start NucliaDB: - ```bash - cd Samples/NucliaDbClient - docker-compose up -d - ``` - -2. Verify NucliaDB is running: - ```bash - curl http://localhost:8080 - ``` - -3. Test the MCP server (once attributes are resolved): - ```bash - cd Samples/NucliaDbClient.McpServer - ./run-mcp-server.sh - ``` - -4. In Claude Code, ask: - - "List all knowledge boxes" - - "Search for documents" - - "What NucliaDB tools are available?" - -## 📊 Generated Tools Summary - -The generated MCP server provides access to **all** NucliaDB REST API operations: - -- **Knowledge Box Management** - Create, read, update, delete knowledge boxes -- **Search** - Full-text search, semantic search, catalog search -- **Ask** - Question-answering on knowledge bases -- **Resources** - Manage documents and content -- **Labels & Entities** - Entity recognition and labeling -- **Configuration** - Model and service configuration - -See [`NucliaDbMcpTools.g.cs`](../NucliaDbClient/Generated/NucliaDbMcpTools.g.cs) for the complete list of 100+ generated tools. - -## 🏗️ Architecture - -``` -┌─────────────────────────────────────────────────────────────┐ -│ OpenAPI Spec (api.yaml) │ -└────────────┬────────────────────────────────────────────────┘ - │ - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ RestClient.Net.OpenApiGenerator │ -│ Generates: Extension Methods + Models │ -└────────────┬────────────────────────────────────────────────┘ - │ - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ RestClient.Net.McpGenerator │ -│ Generates: MCP Tool Wrappers │ -└────────────┬────────────────────────────────────────────────┘ - │ - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ NucliaDbClient.McpServer │ -│ Hosts: MCP Server with generated tools │ -└─────────────────────────────────────────────────────────────┘ - │ - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ Claude Code via stdio │ -└─────────────────────────────────────────────────────────────┘ -``` - -## 🔄 Regenerating Code - -If the OpenAPI spec changes: - -```bash -cd /Users/christianfindlay/Documents/Code/RestClient.Net - -# 1. Regenerate API client -dotnet run --project RestClient.Net.OpenApiGenerator.Cli/RestClient.Net.OpenApiGenerator.Cli.csproj -- \ - -u Samples/NucliaDbClient/api.yaml \ - -o Samples/NucliaDbClient/Generated \ - -n NucliaDB.Generated \ - -c NucliaDBApiExtensions - -# 2. Regenerate MCP tools -dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator.Cli.csproj -- \ - --openapi-url Samples/NucliaDbClient/api.yaml \ - --output-file Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs \ - --namespace NucliaDB.Mcp \ - --server-name NucliaDb \ - --ext-namespace NucliaDB.Generated - -# 3. Rebuild MCP server -dotnet build Samples/NucliaDbClient.McpServer -``` - -## 🐛 Troubleshooting - -### Port Conflicts -```bash -# Check what's using the ports -lsof -i :8080 -lsof -i :5432 - -# Kill processes if needed -kill -9 -``` - -### Docker Issues -```bash -# View logs -cd Samples/NucliaDbClient -docker-compose logs - -# Reset everything -docker-compose down -v -docker-compose up -d -``` - -### MCP Attribute Errors -These are expected until the ModelContextProtocol package stabilizes. See "Option 2" above for manual tool registration. - -## 📚 References - -- [Model Context Protocol Docs](https://modelcontextprotocol.io/) -- [Claude Code MCP Documentation](https://docs.claude.com/en/docs/claude-code/mcp) -- [ModelContextProtocol NuGet Package](https://www.nuget.org/packages/ModelContextProtocol) -- [NucliaDB Documentation](https://docs.nuclia.dev/) - -## ✨ Summary - -**Everything is ready except for the final MCP attribute resolution**, which depends on the ModelContextProtocol package reaching a stable release. All code generation works perfectly, parameter ordering is correct, and the complete infrastructure is in place for running the MCP server with Claude Code! diff --git a/Samples/NucliaDbClient.McpServer/SETUP_COMPLETE.md b/Samples/NucliaDbClient.McpServer/SETUP_COMPLETE.md deleted file mode 100644 index f51744a0..00000000 --- a/Samples/NucliaDbClient.McpServer/SETUP_COMPLETE.md +++ /dev/null @@ -1,116 +0,0 @@ -# NucliaDB MCP Server - Setup Complete! ✅ - -## 🎉 What's Running - -### Docker Containers -- **PostgreSQL** - Running on port 5432 -- **NucliaDB** - Running on port 8080, 8060, 8040 - -### MCP Server -- **Name**: `nucliadb-mcp` -- **Transport**: stdio -- **Command**: `/Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer/run-for-claude.sh` - -## 🚀 Quick Start - -### Check Docker Status -```bash -docker ps -``` - -You should see: -- `nucliadb-local` - NucliaDB server -- `nucliadb-postgres` - PostgreSQL database - -### Access NucliaDB -- **Web UI**: http://localhost:8080 -- **API**: http://localhost:8080/api/v1 - -### Stop Services -```bash -cd /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient -docker-compose down -``` - -### Restart Services -```bash -cd /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient -docker-compose up -d -``` - -## 🔧 Claude Integration - -The MCP server has been added to Claude! You can now: - -1. **Start a new Claude session** - The MCP server will automatically connect -2. **Access 100+ NucliaDB tools** - All API operations are available -3. **Type-safe operations** - Full IntelliSense support - -### Verify MCP Configuration -```bash -cat ~/.claude.json | grep nucliadb-mcp -``` - -## 📦 Generated Tools - -The MCP server provides **100+ tools** including: -- Knowledge box management -- Resource operations -- Search functionality -- File uploads -- Vector operations -- And much more! - -All tools are: -- ✅ Type-safe with proper aliases -- ✅ Error handling via discriminated unions -- ✅ Full XML documentation -- ✅ 100% compilable code - -## 🛠️ Development - -### Rebuild MCP Server -```bash -cd /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer -dotnet build -c Release -``` - -### Regenerate MCP Tools -```bash -cd /Users/christianfindlay/Documents/Code/RestClient.Net -dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator.Cli.csproj -- \ - --openapi-url Samples/NucliaDbClient/api.yaml \ - --output-file Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs \ - --namespace NucliaDB.Mcp \ - --server-name NucliaDb \ - --ext-namespace NucliaDB.Generated -``` - -### Update Claude Configuration -```bash -# Remove server -claude mcp remove nucliadb-mcp - -# Re-add server -claude mcp add --transport stdio nucliadb-mcp /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer/run-for-claude.sh -``` - -## 📊 Status - -- **MCP Generator**: ✅ 100% Complete -- **Docker Services**: ✅ Running -- **Claude Integration**: ✅ Configured -- **Build Status**: ✅ 0 errors, 0 warnings - -## 🎯 Ready to Use! - -Your NucliaDB MCP server is **production-ready** and integrated with Claude! - -Start using it by: -1. Opening a new Claude Code session -2. The MCP server will automatically connect -3. Start calling NucliaDB tools! - ---- - -**Generated by RestClient.Net MCP Generator** 🚀 diff --git a/Samples/NucliaDbClient.McpServer/STATUS.md b/Samples/NucliaDbClient.McpServer/STATUS.md deleted file mode 100644 index 029ac866..00000000 --- a/Samples/NucliaDbClient.McpServer/STATUS.md +++ /dev/null @@ -1,98 +0,0 @@ -# MCP Generator - ✅ COMPLETE! - -## 🎉 FULLY FUNCTIONAL - -The MCP generator is **100% complete** and generates **production-ready** MCP server code from OpenAPI specifications! - -### What Works - -1. ✅ **Full Code Generation** - 201KB of MCP tools code generated from NucliaDB OpenAPI spec -2. ✅ **Type-Safe Aliases** - Uses clean type aliases (`OkKnowledgeBoxObjHTTPValidationError`) instead of verbose generic types -3. ✅ **Error Handling** - Proper discriminated union pattern matching for `HttpError` -4. ✅ **Parameter Handling** - Correctly orders required/optional parameters, adds null-coalescing for optional strings -5. ✅ **CancellationToken** - Always added as last parameter -6. ✅ **Body Parameters** - Correctly handles POST/PUT/PATCH operations with request bodies -7. ✅ **Default Values** - Treats parameters with defaults as optional, regardless of `required` flag -8. ✅ **XML Documentation** - Generates proper XML docs from OpenAPI descriptions -9. ✅ **100+ API Operations** - Successfully wraps all NucliaDB REST API operations - -### Generated Output - -- **Input**: `Samples/NucliaDbClient/api.yaml` (OpenAPI 3.0 spec) -- **Output**: `Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs` (201KB, 100+ tools) -- **Build Status**: ✅ **0 errors, 0 warnings** - Compiles perfectly! - -## ✅ All Issues Resolved - -### 1. ✅ Body Parameter Detection -- **Issue**: POST/PUT/PATCH operations missing body parameters -- **Solution**: Match ExtensionMethodGenerator behavior - always add body for POST/PUT/PATCH -- **Status**: FIXED - -### 2. ✅ Parameter with Default Values -- **Issue**: Parameters with defaults but `required: true` treated as required -- **Solution**: Treat any parameter with a default value as optional, regardless of `required` flag -- **Status**: FIXED - -### 3. ✅ Parameter Ordering -- **Issue**: Tool method parameter order didn't match extension method signatures -- **Solution**: Order parameters as: required params → body → optional params -- **Status**: FIXED - -### 4. ✅ Primitive Response Types -- **Issue**: Some operations return `string` but generator used `object` alias -- **Solution**: Enhanced `GetResponseType()` to detect primitive types using `JsonSchemaType` enum -- **Status**: FIXED - -### 5. ✅ Program.cs Compilation -- **Issue**: ModelContextProtocol API not yet stable -- **Solution**: Simplified Program.cs to not depend on unstable MCP APIs -- **Status**: FIXED - -## 📊 Success Rate - -- **Total Methods Generated**: 100+ -- **Fully Working**: 100+ (100%) -- **Compilation Errors**: 0 (0%) -- **Build Warnings**: 0 (0%) - -## 🎯 Generator Status: ✅ PRODUCTION READY - -The MCP generator successfully: -1. ✅ Parses OpenAPI 3.x specifications -2. ✅ Generates type-safe MCP tool wrappers -3. ✅ Uses proper type aliases and error handling -4. ✅ Handles parameters correctly (required/optional, ordering, defaults) -5. ✅ Detects and includes body parameters for POST/PUT/PATCH operations -6. ✅ Generates primitive response types correctly -7. ✅ Produces 100% compilable, working C# code - -## 🚀 Ready for Use - -You can use the MCP generator NOW to: -- Generate MCP tools from any OpenAPI 3.x spec -- Create type-safe MCP servers for RestClient.Net APIs -- Automatically wrap 80-100% of API operations - -The remaining edge cases can be: -1. Fixed manually in generated code (for immediate use) -2. Fixed in the OpenAPI spec (proper solution) -3. Fixed in the generator with additional heuristics (future enhancement) - -## 📝 Usage - -```bash -# Generate MCP tools -dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator.Cli.csproj -- \ - --openapi-url path/to/spec.yaml \ - --output-file path/to/Output.g.cs \ - --namespace YourNamespace.Mcp \ - --server-name YourApi \ - --ext-namespace YourNamespace.Generated - -# Result: Fully functional MCP tools ready to use! -``` - -## 🎉 MISSION ACCOMPLISHED - -The MCP generator is **done** and **working**! 🚀 diff --git a/Samples/NucliaDbClient.McpServer/run-for-claude.sh b/Samples/NucliaDbClient.McpServer/run-for-claude.sh index eece1073..e11aee25 100755 --- a/Samples/NucliaDbClient.McpServer/run-for-claude.sh +++ b/Samples/NucliaDbClient.McpServer/run-for-claude.sh @@ -1,43 +1,70 @@ #!/bin/bash -# Add the NucliaDB MCP server to Claude Code -# This allows Claude Code to interact with NucliaDB via the Model Context Protocol +# Setup NucliaDB MCP server for Claude Code +# This script: +# 1. Starts NucliaDB via docker-compose (if not running) +# 2. Builds the MCP server +# 3. Adds it to Claude Code configuration set -e -# Get the absolute path to the project directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_PATH="$SCRIPT_DIR/NucliaDbClient.McpServer.csproj" - -# Find the dotnet executable +DOCKER_DIR="$SCRIPT_DIR/../NucliaDbClient" DOTNET_PATH=$(which dotnet) -echo "Configuring NucliaDB MCP server for Claude Code..." -echo " Script directory: $SCRIPT_DIR" -echo " Project path: $PROJECT_PATH" -echo " Dotnet path: $DOTNET_PATH" +echo "NucliaDB MCP Server Setup" +echo "=========================" echo "" -# Add the MCP server to Claude Code configuration -# The command structure is: claude mcp add [options] [--env KEY=value] -- [args...] -claude mcp add --transport stdio nucliadb-mcp --env NUCLIA_BASE_URL=http://localhost:8080/api/v1 -- "$DOTNET_PATH" run --project "$PROJECT_PATH" --no-build +# Check if NucliaDB is running +if curl -s -f "http://localhost:8080" > /dev/null 2>&1; then + echo "✓ NucliaDB is already running" +else + echo "Starting NucliaDB..." + cd "$DOCKER_DIR" + docker-compose up -d + + # Wait for NucliaDB to be ready + echo "Waiting for NucliaDB to start..." + MAX_RETRIES=30 + RETRY_COUNT=0 + + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + if curl -s -f "http://localhost:8080" > /dev/null 2>&1; then + echo "✓ NucliaDB is ready!" + break + fi + RETRY_COUNT=$((RETRY_COUNT + 1)) + if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then + echo "✗ Timeout waiting for NucliaDB" + exit 1 + fi + sleep 2 + done +fi echo "" -echo "✓ NucliaDB MCP server added to Claude Code!" +echo "Building MCP server..." +cd "$SCRIPT_DIR" +dotnet build + +echo "" +echo "Adding to Claude Code configuration..." +claude mcp add --transport stdio nucliadb-mcp --env NUCLIA_BASE_URL=http://localhost:8080/api/v1 -- "$DOTNET_PATH" run --project "$PROJECT_PATH" --no-build + echo "" -echo "Next steps:" -echo " 1. Make sure NucliaDB is running:" -echo " cd $SCRIPT_DIR && docker-compose up -d" +echo "✓ Setup complete!" echo "" -echo " 2. Verify the MCP server is configured:" -echo " claude mcp list" +echo "Verify with: claude mcp list" +echo "The server should appear as 'nucliadb-mcp' with a ✓ status" echo "" -echo " 3. Test the connection:" -echo " The server should appear as 'nucliadb-mcp' with a ✓ or ✗ status" +echo "Available MCP tools (filtered to Search operations only):" +echo " - Ask questions on knowledge boxes" +echo " - Search resources (full-text, semantic, catalog)" +echo " - List and query knowledge box contents" +echo " - 18 total Search-related operations" echo "" -echo "Available MCP tools:" -echo " - Knowledge box management (get, create, delete)" -echo " - Search (full-text, semantic, catalog)" -echo " - Ask (question-answering)" -echo " - Resources (CRUD operations)" -echo " - And 100+ more NucliaDB API operations!" +echo "Note: The MCP tools are filtered to Search operations only to avoid" +echo " flooding Claude Code. To include more operations, regenerate" +echo " with different tags (see README.md)." diff --git a/Samples/NucliaDbClient.McpServer/start-mcp-server.sh b/Samples/NucliaDbClient.McpServer/start-mcp-server.sh deleted file mode 100755 index b94fb3b1..00000000 --- a/Samples/NucliaDbClient.McpServer/start-mcp-server.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -set -e - -echo "Starting NucliaDB MCP Server Setup" -echo "===================================" -echo "" - -# Get the directory where this script is located -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_ROOT="$SCRIPT_DIR/../.." -NUCLIA_DIR="$SCRIPT_DIR/.." - -# Start docker-compose -echo "Starting NucliaDB via docker-compose..." -cd "$NUCLIA_DIR" -docker-compose up -d - -# Wait for NucliaDB to be ready -echo "" -echo "Waiting for NucliaDB to be ready..." -MAX_RETRIES=30 -RETRY_COUNT=0 -NUCLIA_URL="http://localhost:8080" - -while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do - if curl -s -f "$NUCLIA_URL" > /dev/null 2>&1; then - echo "✓ NucliaDB is ready!" - break - fi - - RETRY_COUNT=$((RETRY_COUNT + 1)) - if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then - echo "✗ Timeout waiting for NucliaDB to start" - exit 1 - fi - - echo " Waiting... ($RETRY_COUNT/$MAX_RETRIES)" - sleep 2 -done - -echo "" -echo "Building MCP server..." -cd "$SCRIPT_DIR" -dotnet build - -echo "" -echo "Starting NucliaDB MCP Server..." -echo "Server will communicate via stdio" -echo "===================================" -echo "" - -# Set environment variable for NucliaDB URL -export NUCLIA_BASE_URL="http://localhost:8080/api/v1" - -# Run the MCP server -dotnet run --no-build diff --git a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs index e6db4020..e9f2cc8a 100644 --- a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs +++ b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs @@ -1,14 +1,12 @@ #nullable enable using System.ComponentModel; using System.Text.Json; -using ModelContextProtocol.Server; using Outcome; using NucliaDB.Generated; namespace NucliaDB.Mcp; /// MCP server tools for NucliaDb API. -[McpServerToolType] public class NucliaDbTools(IHttpClientFactory httpClientFactory) { private static readonly JsonSerializerOptions JsonOptions = new() @@ -20,7 +18,6 @@ public class NucliaDbTools(IHttpClientFactory httpClientFactory) /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` /// slug [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - [McpServerTool] public async Task KbBySlugKbSSlugGet(string slug) { var httpClient = httpClientFactory.CreateClient(); @@ -46,7 +43,6 @@ public async Task KbBySlugKbSSlugGet(string slug) /// kbid /// xNUCLIADBROLES [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - [McpServerTool] public async Task KbKbKbidGet(string kbid, string xNUCLIADBROLES = "READER") { var httpClient = httpClientFactory.CreateClient(); @@ -77,7 +73,6 @@ public async Task KbKbKbidGet(string kbid, string xNUCLIADBROLES = "READ /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body [Description("Ask questions on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] public async Task AskKnowledgeboxEndpointKbKbidAsk(string kbid, AskRequest body, string xNdbClient = "api", bool xShowConsumption = false, string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { var httpClient = httpClientFactory.CreateClient(); @@ -118,7 +113,6 @@ public async Task AskKnowledgeboxEndpointKbKbidAsk(string kbid, AskReque /// Set to filter only hidden or only non-hidden resources. Default is to return everything /// Controls which types of metadata are serialized on resources of search results [Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] public async Task CatalogGetKbKbidCatalog(string kbid, string? query = null, object? filterExpression = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int pageNumber = 0, int pageSize = 20, object? withStatus = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, object? hidden = null, List? show = null) { var httpClient = httpClientFactory.CreateClient(); @@ -144,7 +138,6 @@ public async Task CatalogGetKbKbidCatalog(string kbid, string? query = n /// kbid /// Request body [Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] public async Task CatalogPostKbKbidCatalog(string kbid, CatalogRequest body) { var httpClient = httpClientFactory.CreateClient(); @@ -166,36 +159,10 @@ public async Task CatalogPostKbKbidCatalog(string kbid, CatalogRequest b }; } - /// Current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - [Description("Current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task ConfigurationKbKbidConfigurationGet(string kbid) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ConfigurationKbKbidConfigurationGetAsync(kbid, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - /// Update current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` /// kbid /// Request body [Description("Update current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] public async Task ConfigurationKbKbidConfigurationPatch(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -221,7 +188,6 @@ public async Task ConfigurationKbKbidConfigurationPatch(string kbid, obj /// kbid /// Request body [Description("Create configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] public async Task SetConfigurationKbKbidConfiguration(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); @@ -248,7 +214,6 @@ public async Task SetConfigurationKbKbidConfiguration(string kbid, objec /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. /// xNUCLIADBROLES [Description("Summary of amount of different things inside a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] public async Task KnowledgeboxCountersKbKbidCounters(string kbid, bool debug = false, string xNUCLIADBROLES = "READER") { var httpClient = httpClientFactory.CreateClient(); @@ -270,21 +235,20 @@ public async Task KnowledgeboxCountersKbKbidCounters(string kbid, bool d }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` /// kbid /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task SetCustomSynonymsKbKbidCustomSynonyms(string kbid, KnowledgeBoxSynonyms body) + [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + public async Task StartKbExportEndpointKbKbidExport(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SetCustomSynonymsKbKbidCustomSynonymsAsync(kbid, body, CancellationToken.None); + var result = await httpClient.StartKbExportEndpointKbKbidExportAsync(kbid, body, CancellationToken.None); return result switch { - OkobjectHTTPValidationError(var success) => + OkCreateExportResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch + ErrorCreateExportResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -296,20 +260,20 @@ public async Task SetCustomSynonymsKbKbidCustomSynonyms(string kbid, Kno }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` /// kbid - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task CustomSynonymsKbKbidCustomSynonymsDelete(string kbid) + /// exportId + [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + public async Task DownloadExportKbEndpointKbKbidExportExportId(string kbid, string exportId) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.CustomSynonymsKbKbidCustomSynonymsDeleteAsync(kbid, CancellationToken.None); + var result = await httpClient.DownloadExportKbEndpointKbKbidExportExportIdAsync(kbid, exportId, CancellationToken.None); return result switch { - OkUnitHTTPValidationError(var success) => + OkobjectHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch + ErrorobjectHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -321,20 +285,20 @@ public async Task CustomSynonymsKbKbidCustomSynonymsDelete(string kbid) }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` /// kbid - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task CustomSynonymsKbKbidCustomSynonymsGet(string kbid) + /// exportId + [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + public async Task ExportStatusEndpointKbKbidExportExportIdStatusGet(string kbid, string exportId) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.CustomSynonymsKbKbidCustomSynonymsGetAsync(kbid, CancellationToken.None); + var result = await httpClient.ExportStatusEndpointKbKbidExportExportIdStatusGetAsync(kbid, exportId, CancellationToken.None); return result switch { - OkKnowledgeBoxSynonymsHTTPValidationError(var success) => + OkStatusResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeBoxSynonymsHTTPValidationError(var httpError) => httpError switch + ErrorStatusResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -346,16 +310,17 @@ public async Task CustomSynonymsKbKbidCustomSynonymsGet(string kbid) }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` + /// Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid - /// group + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task UpdateEntitiesGroupKbKbidEntitiesgroupGroup(string kbid, string group, UpdateEntitiesGroupPayload body) + [Description("Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, FeedbackRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UpdateEntitiesGroupKbKbidEntitiesgroupGroupAsync(kbid, group, body, CancellationToken.None); + var result = await httpClient.SendFeedbackEndpointKbKbidFeedbackAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { @@ -373,21 +338,49 @@ public async Task UpdateEntitiesGroupKbKbidEntitiesgroupGroup(string kbi }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` + /// Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid - /// group - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task EntitiesKbKbidEntitiesgroupGroupDelete(string kbid, string group) + /// The query to search for + /// Returns only documents that match this filter expression.Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters This allows building complex filtering expressions and replaces the following parameters:`fields`, `filters`, `range_*`, `resource_filters`, `keyword_filters`. + /// The list of fields to search in. For instance: `a/title` to search only on title field. For more details on filtering by field, see: https://docs.nuclia.dev/docs/rag/advanced/search/#search-in-a-specific-field. + /// The list of filters to apply. Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters + /// The number of results search should return. The maximum number of results allowed is 200. + /// Minimum similarity score to filter vector index results. If not specified, the default minimum score of the semantic model associated to the Knowledge Box will be used. Check out the documentation for more information on how to use this parameter: https://docs.nuclia.dev/docs/rag/advanced/search#minimum-score + /// Minimum semantic similarity score to filter vector index results. If not specified, the default minimum score of the semantic model associated to the Knowledge Box will be used. Check out the documentation for more information on how to use this parameter: https://docs.nuclia.dev/docs/rag/advanced/search#minimum-score + /// Minimum bm25 score to filter paragraph and document index results + /// Vectors index to perform the search in. If not provided, NucliaDB will use the default one + /// Resources created before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// Resources created after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// Resources modified before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// Resources modified after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// List of search features to use. Each value corresponds to a lookup into on of the different indexes + /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. + /// If set to true, the query terms will be highlighted in the results between ... tags + /// Controls which types of metadata are serialized on resources of search results + /// Define which field types are serialized on resources of search results + /// [Deprecated] Please use GET resource endpoint instead to get extracted metadata + /// Whether to return duplicate paragraphs on the same document + /// Whether to return matches for custom knowledge box synonyms of the query terms. Note: only supported for `keyword` and `fulltext` search options. + /// If set to true, the search will automatically add filters to the query. For example, it will filter results containing the entities detected in the query + /// List of security groups to filter search results for. Only resources matching the query and containing the specified security groups will be returned. If empty, all resources will be considered for the search. + /// If set to false (default), excludes hidden resources from search + /// Rank fusion algorithm to use to merge results from multiple retrievers (keyword, semantic) + /// Reranker let you specify which method you want to use to rerank your results at the end of retrieval + /// Load find parameters from this configuration. Parameters in the request override parameters from the configuration. + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor + [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task FindKnowledgeboxKbKbidFind(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, object? topK = null, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string rankFusion = "rrf", object? reranker = null, object? searchConfiguration = null, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.EntitiesKbKbidEntitiesgroupGroupDeleteAsync(kbid, group, CancellationToken.None); + var result = await httpClient.FindKnowledgeboxKbKbidFindAsync(kbid, query ?? "", filterExpression, fields, filters, topK, minScore, minScoreSemantic, minScoreBm25, vectorset, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, features, debug, highlight, show, fieldType, extracted, withDuplicates, withSynonyms, autofilter, securityGroups, showHidden, rankFusion, reranker, searchConfiguration, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { - OkUnitHTTPValidationError(var success) => + OkKnowledgeboxFindResultsHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch + ErrorKnowledgeboxFindResultsHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -399,21 +392,23 @@ public async Task EntitiesKbKbidEntitiesgroupGroupDelete(string kbid, st }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` + /// Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid - /// group - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task EntityKbKbidEntitiesgroupGroupGet(string kbid, string group) + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor + /// Request body + [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.EntityKbKbidEntitiesgroupGroupGetAsync(kbid, group, CancellationToken.None); + var result = await httpClient.FindPostKnowledgeboxKbKbidFindAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { - OkEntitiesGroupHTTPValidationError(var success) => + OkKnowledgeboxFindResultsHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorEntitiesGroupHTTPValidationError(var httpError) => httpError switch + ErrorKnowledgeboxFindResultsHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -425,21 +420,23 @@ public async Task EntityKbKbidEntitiesgroupGroupGet(string kbid, string }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` + /// Search on the Knowledge Box graph and retrieve triplets of vertex-edge-vertex --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task CreateEntitiesGroupKbKbidEntitiesgroups(string kbid, CreateEntitiesGroupPayload body) + [Description("Search on the Knowledge Box graph and retrieve triplets of vertex-edge-vertex --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task GraphSearchKnowledgeboxKbKbidGraph(string kbid, GraphSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.CreateEntitiesGroupKbKbidEntitiesgroupsAsync(kbid, body, CancellationToken.None); + var result = await httpClient.GraphSearchKnowledgeboxKbKbidGraphAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { - OkobjectHTTPValidationError(var success) => + OkGraphSearchResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch + ErrorGraphSearchResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -451,21 +448,23 @@ public async Task CreateEntitiesGroupKbKbidEntitiesgroups(string kbid, C }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` + /// Search on the Knowledge Box graph and retrieve nodes (vertices) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid - /// showEntities - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task EntitiesKbKbidEntitiesgroupsGet(string kbid, bool showEntities = false) + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor + /// Request body + [Description("Search on the Knowledge Box graph and retrieve nodes (vertices) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(string kbid, GraphNodesSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.EntitiesKbKbidEntitiesgroupsGetAsync(kbid, showEntities, CancellationToken.None); + var result = await httpClient.GraphNodesSearchKnowledgeboxKbKbidGraphNodesAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { - OkKnowledgeBoxEntitiesHTTPValidationError(var success) => + OkGraphNodesSearchResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeBoxEntitiesHTTPValidationError(var httpError) => httpError switch + ErrorGraphNodesSearchResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -477,21 +476,23 @@ public async Task EntitiesKbKbidEntitiesgroupsGet(string kbid, bool show }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` + /// Search on the Knowledge Box graph and retrieve relations (edges) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] - public async Task StartKbExportEndpointKbKbidExport(string kbid, object body) + [Description("Search on the Knowledge Box graph and retrieve relations (edges) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRelations(string kbid, GraphRelationsSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.StartKbExportEndpointKbKbidExportAsync(kbid, body, CancellationToken.None); + var result = await httpClient.GraphRelationsSearchKnowledgeboxKbKbidGraphRelationsAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { - OkCreateExportResponseHTTPValidationError(var success) => + OkGraphRelationsSearchResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorCreateExportResponseHTTPValidationError(var httpError) => httpError switch + ErrorGraphRelationsSearchResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -503,21 +504,20 @@ public async Task StartKbExportEndpointKbKbidExport(string kbid, object }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` /// kbid - /// exportId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - [McpServerTool] - public async Task DownloadExportKbEndpointKbKbidExportExportId(string kbid, string exportId) + /// Request body + [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + public async Task StartKbImportEndpointKbKbidImport(string kbid, object body) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadExportKbEndpointKbKbidExportExportIdAsync(kbid, exportId, CancellationToken.None); + var result = await httpClient.StartKbImportEndpointKbKbidImportAsync(kbid, body, CancellationToken.None); return result switch { - OkobjectHTTPValidationError(var success) => + OkCreateImportResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch + ErrorCreateImportResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -531,13 +531,12 @@ public async Task DownloadExportKbEndpointKbKbidExportExportId(string kb /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` /// kbid - /// exportId + /// importId [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - [McpServerTool] - public async Task ExportStatusEndpointKbKbidExportExportIdStatusGet(string kbid, string exportId) + public async Task ImportStatusEndpointKbKbidImportImportIdStatusGet(string kbid, string importId) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ExportStatusEndpointKbKbidExportExportIdStatusGetAsync(kbid, exportId, CancellationToken.None); + var result = await httpClient.ImportStatusEndpointKbKbidImportImportIdStatusGetAsync(kbid, importId, CancellationToken.None); return result switch { @@ -555,40 +554,18 @@ public async Task ExportStatusEndpointKbKbidExportExportIdStatusGet(stri }; } - /// Add a extract strategy to a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` + /// Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid + /// endpoint + /// xNucliadbUser + /// xNdbClient + /// xForwardedFor /// Request body - [Description("Add a extract strategy to a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] - public async Task AddStrategyKbKbidExtractStrategies(string kbid, ExtractConfig body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddStrategyKbKbidExtractStrategiesAsync(kbid, body, CancellationToken.None); - - return result switch - { - OkstringHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorstringHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Get available extract strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - [Description("Get available extract strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task ExtractStrategiesKbKbidExtractStrategiesGet(string kbid) + [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task PredictProxyEndpointKbKbidPredictEndpoint(string kbid, string endpoint, object body, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ExtractStrategiesKbKbidExtractStrategiesGetAsync(kbid, CancellationToken.None); + var result = await httpClient.PredictProxyEndpointKbKbidPredictEndpointAsync(kbid, endpoint, body, xNucliadbUser ?? "", xNdbClient, xForwardedFor ?? "", CancellationToken.None); return result switch { @@ -606,21 +583,23 @@ public async Task ExtractStrategiesKbKbidExtractStrategiesGet(string kbi }; } - /// Removes a extract strategy from a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` + /// Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid - /// strategyId - [Description("Removes a extract strategy from a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] - public async Task StrategyKbKbidExtractStrategiesStrategyStrategyIdDelete(string kbid, string strategyId) + /// endpoint + /// xNucliadbUser + /// xNdbClient + /// xForwardedFor + [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task PredictProxyEndpointKbKbidPredictEndpoint2(string kbid, string endpoint, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.StrategyKbKbidExtractStrategiesStrategyStrategyIdDeleteAsync(kbid, strategyId, CancellationToken.None); + var result = await httpClient.PredictProxyEndpointKbKbidPredictEndpointAsync2(kbid, endpoint, xNucliadbUser ?? "", xNdbClient, xForwardedFor ?? "", CancellationToken.None); return result switch { - OkUnitHTTPValidationError(var success) => + OkobjectHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch + ErrorobjectHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -632,21 +611,26 @@ public async Task StrategyKbKbidExtractStrategiesStrategyStrategyIdDelet }; } - /// Get extract strategy for a given id --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` + /// Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid - /// strategyId - [Description("Get extract strategy for a given id --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task ExtractStrategyFromIdKbKbidExtractStrategiesStrategyStrategyIdGet(string kbid, string strategyId) + /// rid + /// xShowConsumption + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor + /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. + /// Request body + [Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task ResourceAskEndpointByUuidKbKbidResourceRidAsk(string kbid, string rid, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ExtractStrategyFromIdKbKbidExtractStrategiesStrategyStrategyIdGetAsync(kbid, strategyId, CancellationToken.None); + var result = await httpClient.ResourceAskEndpointByUuidKbKbidResourceRidAskAsync(kbid, rid, body, xShowConsumption, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", xSynchronous, CancellationToken.None); return result switch { - OkobjectHTTPValidationError(var success) => + OkSyncAskResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch + ErrorSyncAskResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -658,24 +642,35 @@ public async Task ExtractStrategyFromIdKbKbidExtractStrategiesStrategySt }; } - /// Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` + /// Search on a single resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid + /// rid + /// query + /// Returns only documents that match this filter expression.Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters This allows building complex filtering expressions and replaces the following parameters:`fields`, `filters`, `range_*`, `resource_filters`, `keyword_filters`. + /// The list of fields to search in. For instance: `a/title` to search only on title field. For more details on filtering by field, see: https://docs.nuclia.dev/docs/rag/advanced/search/#search-in-a-specific-field. + /// The list of filters to apply. Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters + /// The list of facets to calculate. The facets follow the same syntax as filters: https://docs.nuclia.dev/docs/rag/advanced/search-filters + /// Field to sort results with (Score not supported in catalog) + /// Order to sort results with + /// The number of results search should return. The maximum number of results allowed is 200. + /// Resources created before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// Resources created after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// Resources modified before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// Resources modified after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. + /// If set to true, the query terms will be highlighted in the results between ... tags + /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. /// xNdbClient - /// xNucliadbUser - /// xForwardedFor - /// Request body - [Description("Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, FeedbackRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + [Description("Search on a single resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task ResourceSearchKbKbidResourceRidSearch(string kbid, string rid, string query, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, object? sortField = null, string sortOrder = "desc", object? topK = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, bool highlight = false, bool debug = false, string xNdbClient = "api") { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SendFeedbackEndpointKbKbidFeedbackAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); + var result = await httpClient.ResourceSearchKbKbidResourceRidSearchAsync(kbid, rid, query, filterExpression, fields, filters, faceted, sortField, sortOrder, topK, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, highlight, debug, xNdbClient, CancellationToken.None); return result switch { - OkobjectHTTPValidationError(var success) => + OkResourceSearchResultsHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch + ErrorResourceSearchResultsHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -687,12 +682,16 @@ public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, Feedba }; } - /// Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` + /// Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// The query to search for /// Returns only documents that match this filter expression.Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters This allows building complex filtering expressions and replaces the following parameters:`fields`, `filters`, `range_*`, `resource_filters`, `keyword_filters`. /// The list of fields to search in. For instance: `a/title` to search only on title field. For more details on filtering by field, see: https://docs.nuclia.dev/docs/rag/advanced/search/#search-in-a-specific-field. /// The list of filters to apply. Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters + /// The list of facets to calculate. The facets follow the same syntax as filters: https://docs.nuclia.dev/docs/rag/advanced/search-filters + /// Field to sort results with (Score not supported in catalog) + /// sortLimit + /// Order to sort results with /// The number of results search should return. The maximum number of results allowed is 200. /// Minimum similarity score to filter vector index results. If not specified, the default minimum score of the semantic model associated to the Knowledge Box will be used. Check out the documentation for more information on how to use this parameter: https://docs.nuclia.dev/docs/rag/advanced/search#minimum-score /// Minimum semantic similarity score to filter vector index results. If not specified, the default minimum score of the semantic model associated to the Knowledge Box will be used. Check out the documentation for more information on how to use this parameter: https://docs.nuclia.dev/docs/rag/advanced/search#minimum-score @@ -713,24 +712,20 @@ public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, Feedba /// If set to true, the search will automatically add filters to the query. For example, it will filter results containing the entities detected in the query /// List of security groups to filter search results for. Only resources matching the query and containing the specified security groups will be returned. If empty, all resources will be considered for the search. /// If set to false (default), excludes hidden resources from search - /// Rank fusion algorithm to use to merge results from multiple retrievers (keyword, semantic) - /// Reranker let you specify which method you want to use to rerank your results at the end of retrieval - /// Load find parameters from this configuration. Parameters in the request override parameters from the configuration. /// xNdbClient /// xNucliadbUser /// xForwardedFor - [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task FindKnowledgeboxKbKbidFind(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, object? topK = null, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string rankFusion = "rrf", object? reranker = null, object? searchConfiguration = null, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task SearchKnowledgeboxKbKbidSearch(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int topK = 20, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.FindKnowledgeboxKbKbidFindAsync(kbid, query ?? "", filterExpression, fields, filters, topK, minScore, minScoreSemantic, minScoreBm25, vectorset, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, features, debug, highlight, show, fieldType, extracted, withDuplicates, withSynonyms, autofilter, securityGroups, showHidden, rankFusion, reranker, searchConfiguration, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); + var result = await httpClient.SearchKnowledgeboxKbKbidSearchAsync(kbid, query ?? "", filterExpression, fields, filters, faceted, sortField ?? "", sortLimit, sortOrder, topK, minScore, minScoreSemantic, minScoreBm25, vectorset, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, features, debug, highlight, show, fieldType, extracted, withDuplicates, withSynonyms, autofilter, securityGroups, showHidden, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { - OkKnowledgeboxFindResultsHTTPValidationError(var success) => + OkKnowledgeboxSearchResultsHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeboxFindResultsHTTPValidationError(var httpError) => httpError switch + ErrorKnowledgeboxSearchResultsHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -742,1991 +737,23 @@ public async Task FindKnowledgeboxKbKbidFind(string kbid, string? query }; } - /// Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` + /// Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// xNdbClient /// xNucliadbUser /// xForwardedFor /// Request body - [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.FindPostKnowledgeboxKbKbidFindAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkKnowledgeboxFindResultsHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeboxFindResultsHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Search on the Knowledge Box graph and retrieve triplets of vertex-edge-vertex --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// xNdbClient - /// xNucliadbUser - /// xForwardedFor - /// Request body - [Description("Search on the Knowledge Box graph and retrieve triplets of vertex-edge-vertex --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task GraphSearchKnowledgeboxKbKbidGraph(string kbid, GraphSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.GraphSearchKnowledgeboxKbKbidGraphAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkGraphSearchResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorGraphSearchResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Search on the Knowledge Box graph and retrieve nodes (vertices) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// xNdbClient - /// xNucliadbUser - /// xForwardedFor - /// Request body - [Description("Search on the Knowledge Box graph and retrieve nodes (vertices) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(string kbid, GraphNodesSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.GraphNodesSearchKnowledgeboxKbKbidGraphNodesAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkGraphNodesSearchResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorGraphNodesSearchResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Search on the Knowledge Box graph and retrieve relations (edges) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// xNdbClient - /// xNucliadbUser - /// xForwardedFor - /// Request body - [Description("Search on the Knowledge Box graph and retrieve relations (edges) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRelations(string kbid, GraphRelationsSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.GraphRelationsSearchKnowledgeboxKbKbidGraphRelationsAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkGraphRelationsSearchResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorGraphRelationsSearchResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` - /// kbid - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] - public async Task StartKbImportEndpointKbKbidImport(string kbid, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.StartKbImportEndpointKbKbidImportAsync(kbid, body, CancellationToken.None); - - return result switch - { - OkCreateImportResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorCreateImportResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` - /// kbid - /// importId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - [McpServerTool] - public async Task ImportStatusEndpointKbKbidImportImportIdStatusGet(string kbid, string importId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ImportStatusEndpointKbKbidImportImportIdStatusGetAsync(kbid, importId, CancellationToken.None); - - return result switch - { - OkStatusResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorStatusResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// labelset - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task SetLabelsetEndpointKbKbidLabelsetLabelset(string kbid, string labelset, LabelSet body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SetLabelsetEndpointKbKbidLabelsetLabelsetAsync(kbid, labelset, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// labelset - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task LabelsetEndpointKbKbidLabelsetLabelsetDelete(string kbid, string labelset) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.LabelsetEndpointKbKbidLabelsetLabelsetDeleteAsync(kbid, labelset, CancellationToken.None); - - return result switch - { - OkUnitHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// labelset - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task LabelsetEndpointKbKbidLabelsetLabelsetGet(string kbid, string labelset) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.LabelsetEndpointKbKbidLabelsetLabelsetGetAsync(kbid, labelset, CancellationToken.None); - - return result switch - { - OkLabelSet(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorLabelSet(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task LabelsetsEndointKbKbidLabelsetsGet(string kbid) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.LabelsetsEndointKbKbidLabelsetsGetAsync(kbid, CancellationToken.None); - - return result switch - { - OkKnowledgeBoxLabelsHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeBoxLabelsHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Get metadata for a particular model --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - /// modelId - [Description("Get metadata for a particular model --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task ModelKbKbidModelModelIdGet(string kbid, string modelId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ModelKbKbidModelModelIdGetAsync(kbid, modelId, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Get available models --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - [Description("Get available models --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task ModelsKbKbidModelsGet(string kbid) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ModelsKbKbidModelsGetAsync(kbid, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Download the trained model or any other generated file as a result of a training task on a Knowledge Box. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - /// modelId - /// filename - [Description("Download the trained model or any other generated file as a result of a training task on a Knowledge Box. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task DownloadModelKbKbidModelsModelIdFilename(string kbid, string modelId, string filename) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadModelKbKbidModelsModelIdFilenameAsync(kbid, modelId, filename, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Provides a stream of activity notifications for the given Knowledge Box. The stream will be automatically closed after 2 minutes. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - [Description("Provides a stream of activity notifications for the given Knowledge Box. The stream will be automatically closed after 2 minutes. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task NotificationsEndpointKbKbidNotifications(string kbid) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.NotificationsEndpointKbKbidNotificationsAsync(kbid, CancellationToken.None); - - return result switch - { - Okobject(var success) => - JsonSerializer.Serialize(success, JsonOptions), - Errorobject(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// endpoint - /// xNucliadbUser - /// xNdbClient - /// xForwardedFor - /// Request body - [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task PredictProxyEndpointKbKbidPredictEndpoint(string kbid, string endpoint, object body, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.PredictProxyEndpointKbKbidPredictEndpointAsync(kbid, endpoint, body, xNucliadbUser ?? "", xNdbClient, xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// endpoint - /// xNucliadbUser - /// xNdbClient - /// xForwardedFor - [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task PredictProxyEndpointKbKbidPredictEndpoint2(string kbid, string endpoint, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.PredictProxyEndpointKbKbidPredictEndpointAsync2(kbid, endpoint, xNucliadbUser ?? "", xNdbClient, xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Provides the status of the processing of the given Knowledge Box. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// cursor - /// scheduled - /// limit - [Description("Provides the status of the processing of the given Knowledge Box. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ProcessingStatusKbKbidProcessingStatus(string kbid, object? cursor = null, object? scheduled = null, int limit = 20) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ProcessingStatusKbKbidProcessingStatusAsync(kbid, cursor, scheduled, limit, CancellationToken.None); - - return result switch - { - OkRequestsResults(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorRequestsResults(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// pathRid - /// field - /// Extract strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task TusPostRidPrefixKbKbidResourcePathRidFileFieldTusupload(string kbid, string pathRid, string field, object body, object? xExtractStrategy = null, object? xSplitStrategy = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.TusPostRidPrefixKbKbidResourcePathRidFileFieldTusuploadAsync(kbid, pathRid, field, body, xExtractStrategy, xSplitStrategy, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// pathRid - /// field - /// uploadId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task UploadInformationKbKbidResourcePathRidFileFieldTusuploadUploadId(string kbid, string pathRid, string field, string uploadId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UploadInformationKbKbidResourcePathRidFileFieldTusuploadUploadIdAsync(kbid, pathRid, field, uploadId, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Upload a file as a field on an existing resource, if the field exists will return a conflict (419) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// pathRid - /// field - /// Name of the file being uploaded. - /// If the file is password protected, the password must be provided here. - /// xLanguage - /// MD5 hash of the file being uploaded. This is used to check if the file has been uploaded before. - /// Extract strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Request body - [Description("Upload a file as a field on an existing resource, if the field exists will return a conflict (419) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task UploadRidPrefixKbKbidResourcePathRidFileFieldUpload(string kbid, string pathRid, string field, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UploadRidPrefixKbKbidResourcePathRidFileFieldUploadAsync(kbid, pathRid, field, body, xFilename, xPassword, xLanguage, xMd5, xExtractStrategy, xSplitStrategy, CancellationToken.None); - - return result switch - { - OkResourceFileUploadedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFileUploadedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// xNucliadbUser - /// If set to true, file fields will not be saved in the blob storage. They will only be sent to process. - /// xNUCLIADBROLES - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ModifyResourceRidPrefixKbKbidResourceRid(string kbid, string rid, UpdateResourcePayload body, string? xNucliadbUser = null, bool xSkipStore = false, string xNUCLIADBROLES = "WRITER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ModifyResourceRidPrefixKbKbidResourceRidAsync(kbid, rid, body, xNucliadbUser ?? "", xSkipStore, xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkResourceUpdatedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceUpdatedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// xNUCLIADBROLES - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ResourceRidPrefixKbKbidResourceRidDelete(string kbid, string rid, string xNUCLIADBROLES = "WRITER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceRidPrefixKbKbidResourceRidDeleteAsync(kbid, rid, xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkUnitHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// show - /// fieldType - /// extracted - /// xNucliadbUser - /// xForwardedFor - /// xNUCLIADBROLES - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ResourceByUuidKbKbidResourceRidGet(string kbid, string rid, List? show = null, List? fieldType = null, List? extracted = null, string? xNucliadbUser = null, string? xForwardedFor = null, string xNUCLIADBROLES = "READER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceByUuidKbKbidResourceRidGetAsync(kbid, rid, show, fieldType, extracted, xNucliadbUser ?? "", xForwardedFor ?? "", xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkNucliadbModelsResourceResourceHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorNucliadbModelsResourceResourceHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// xShowConsumption - /// xNdbClient - /// xNucliadbUser - /// xForwardedFor - /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. - /// Request body - [Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ResourceAskEndpointByUuidKbKbidResourceRidAsk(string kbid, string rid, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceAskEndpointByUuidKbKbidResourceRidAskAsync(kbid, rid, body, xShowConsumption, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", xSynchronous, CancellationToken.None); - - return result switch - { - OkSyncAskResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorSyncAskResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// fieldId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldConversationRidPrefixKbKbidResourceRidConversationFieldId(string kbid, string rid, string fieldId, InputConversationField body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldConversationRidPrefixKbKbidResourceRidConversationFieldIdAsync(kbid, rid, fieldId, body, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// fieldId - /// messageId - /// fileNum - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task DownloadFieldConversationAttachmentRidPrefixKbKbidResourceRidConversationFieldIdDownloadFieldMessageIdFileNum(string kbid, string rid, string fieldId, string messageId, int fileNum) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadFieldConversationAttachmentRidPrefixKbKbidResourceRidConversationFieldIdDownloadFieldMessageIdFileNumAsync(kbid, rid, fieldId, messageId, fileNum, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// fieldId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AppendMessagesToConversationFieldRidPrefixKbKbidResourceRidConversationFieldIdMessages(string kbid, string rid, string fieldId, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AppendMessagesToConversationFieldRidPrefixKbKbidResourceRidConversationFieldIdMessagesAsync(kbid, rid, fieldId, body, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// fieldId - /// If set to true, file fields will not be saved in the blob storage. They will only be sent to process. - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldFileRidPrefixKbKbidResourceRidFileFieldId(string kbid, string rid, string fieldId, FileField body, bool xSkipStore = false) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldFileRidPrefixKbKbidResourceRidFileFieldIdAsync(kbid, rid, fieldId, body, xSkipStore, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// fieldId - /// inline - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task DownloadFieldFileRidPrefixKbKbidResourceRidFileFieldIdDownloadField(string kbid, string rid, string fieldId, bool inline = false) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadFieldFileRidPrefixKbKbidResourceRidFileFieldIdDownloadFieldAsync(kbid, rid, fieldId, inline, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// fieldId - /// Reset the title of the resource so that the file or link computed titles are set after processing. - /// xNucliadbUser - /// If a file is password protected, the password must be provided here for the file to be processed - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ReprocessFileFieldKbKbidResourceRidFileFieldIdReprocess(string kbid, string rid, string fieldId, object body, bool resetTitle = false, string? xNucliadbUser = null, object? xFilePassword = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ReprocessFileFieldKbKbidResourceRidFileFieldIdReprocessAsync(kbid, rid, fieldId, body, resetTitle, xNucliadbUser ?? "", xFilePassword, CancellationToken.None); - - return result switch - { - OkResourceUpdatedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceUpdatedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// field - /// uploadId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task TusPatchRidPrefixKbKbidResourceRidFileFieldTusuploadUploadId(string kbid, string rid, string field, string uploadId, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.TusPatchRidPrefixKbKbidResourceRidFileFieldTusuploadUploadIdAsync(kbid, rid, field, uploadId, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// fieldId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldLinkRidPrefixKbKbidResourceRidLinkFieldId(string kbid, string rid, string fieldId, LinkField body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldLinkRidPrefixKbKbidResourceRidLinkFieldIdAsync(kbid, rid, fieldId, body, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// reindexVectors - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ReindexResourceRidPrefixKbKbidResourceRidReindex(string kbid, string rid, object body, bool reindexVectors = false) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ReindexResourceRidPrefixKbKbidResourceRidReindexAsync(kbid, rid, body, reindexVectors, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// Reset the title of the resource so that the file or link computed titles are set after processing. - /// xNucliadbUser - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ReprocessResourceRidPrefixKbKbidResourceRidReprocess(string kbid, string rid, object body, bool resetTitle = false, string? xNucliadbUser = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ReprocessResourceRidPrefixKbKbidResourceRidReprocessAsync(kbid, rid, body, resetTitle, xNucliadbUser ?? "", CancellationToken.None); - - return result switch - { - OkResourceUpdatedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceUpdatedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Run Agents on Resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// xNucliadbUser - /// Request body - [Description("Run Agents on Resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task RunAgentsByUuidKbKbidResourceRidRunAgents(string kbid, string rid, ResourceAgentsRequest body, string? xNucliadbUser = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.RunAgentsByUuidKbKbidResourceRidRunAgentsAsync(kbid, rid, body, xNucliadbUser ?? "", CancellationToken.None); - - return result switch - { - OkResourceAgentsResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceAgentsResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Search on a single resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// query - /// Returns only documents that match this filter expression.Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters This allows building complex filtering expressions and replaces the following parameters:`fields`, `filters`, `range_*`, `resource_filters`, `keyword_filters`. - /// The list of fields to search in. For instance: `a/title` to search only on title field. For more details on filtering by field, see: https://docs.nuclia.dev/docs/rag/advanced/search/#search-in-a-specific-field. - /// The list of filters to apply. Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters - /// The list of facets to calculate. The facets follow the same syntax as filters: https://docs.nuclia.dev/docs/rag/advanced/search-filters - /// Field to sort results with (Score not supported in catalog) - /// Order to sort results with - /// The number of results search should return. The maximum number of results allowed is 200. - /// Resources created before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// Resources created after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// Resources modified before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// Resources modified after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// If set to true, the query terms will be highlighted in the results between ... tags - /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. - /// xNdbClient - [Description("Search on a single resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ResourceSearchKbKbidResourceRidSearch(string kbid, string rid, string query, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, object? sortField = null, string sortOrder = "desc", object? topK = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, bool highlight = false, bool debug = false, string xNdbClient = "api") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceSearchKbKbidResourceRidSearchAsync(kbid, rid, query, filterExpression, fields, filters, faceted, sortField, sortOrder, topK, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, highlight, debug, xNdbClient, CancellationToken.None); - - return result switch - { - OkResourceSearchResultsHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceSearchResultsHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// fieldId - /// xNUCLIADBROLES - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldTextRidPrefixKbKbidResourceRidTextFieldId(string kbid, string rid, string fieldId, TextField body, string xNUCLIADBROLES = "WRITER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldTextRidPrefixKbKbidResourceRidTextFieldIdAsync(kbid, rid, fieldId, body, xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rid - /// fieldType - /// fieldId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldIdDelete(string kbid, string rid, string fieldType, string fieldId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldIdDeleteAsync(kbid, rid, fieldType, fieldId, CancellationToken.None); - - return result switch - { - OkUnitHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// fieldType - /// fieldId - /// show - /// extracted - /// page - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldIdGet(string kbid, string rid, string fieldType, string fieldId, List? show = null, List? extracted = null, object? page = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceFieldRidPrefixKbKbidResourceRidFieldTypeFieldIdGetAsync(kbid, rid, fieldType, fieldId, show, extracted, page, CancellationToken.None); - - return result switch - { - OkResourceFieldHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rid - /// fieldType - /// fieldId - /// downloadField - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task DownloadExtractFileRidPrefixKbKbidResourceRidFieldTypeFieldIdDownloadExtractedDownloadField(string kbid, string rid, string fieldType, string fieldId, string downloadField) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadExtractFileRidPrefixKbKbidResourceRidFieldTypeFieldIdDownloadExtractedDownloadFieldAsync(kbid, rid, fieldType, fieldId, downloadField, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Create a new Resource in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// If set to true, file fields will not be saved in the blob storage. They will only be sent to process. - /// xNucliadbUser - /// xNUCLIADBROLES - /// Request body - [Description("Create a new Resource in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task CreateResourceKbKbidResources(string kbid, CreateResourcePayload body, bool xSkipStore = false, string? xNucliadbUser = null, string xNUCLIADBROLES = "WRITER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.CreateResourceKbKbidResourcesAsync(kbid, body, xSkipStore, xNucliadbUser ?? "", xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkResourceCreatedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceCreatedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// List of resources of a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// Requested page number (0-based) - /// Page size - /// xNUCLIADBROLES - [Description("List of resources of a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ListResourcesKbKbidResources(string kbid, int page = 0, int size = 20, string xNUCLIADBROLES = "READER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ListResourcesKbKbidResourcesAsync(kbid, page, size, xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkResourceListHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceListHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Get jsonschema definition to update the `learning_configuration` of your Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - [Description("Get jsonschema definition to update the `learning_configuration` of your Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task SchemaForConfigurationUpdatesKbKbidSchemaGet(string kbid) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SchemaForConfigurationUpdatesKbKbidSchemaGetAsync(kbid, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// The query to search for - /// Returns only documents that match this filter expression.Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters This allows building complex filtering expressions and replaces the following parameters:`fields`, `filters`, `range_*`, `resource_filters`, `keyword_filters`. - /// The list of fields to search in. For instance: `a/title` to search only on title field. For more details on filtering by field, see: https://docs.nuclia.dev/docs/rag/advanced/search/#search-in-a-specific-field. - /// The list of filters to apply. Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters - /// The list of facets to calculate. The facets follow the same syntax as filters: https://docs.nuclia.dev/docs/rag/advanced/search-filters - /// Field to sort results with (Score not supported in catalog) - /// sortLimit - /// Order to sort results with - /// The number of results search should return. The maximum number of results allowed is 200. - /// Minimum similarity score to filter vector index results. If not specified, the default minimum score of the semantic model associated to the Knowledge Box will be used. Check out the documentation for more information on how to use this parameter: https://docs.nuclia.dev/docs/rag/advanced/search#minimum-score - /// Minimum semantic similarity score to filter vector index results. If not specified, the default minimum score of the semantic model associated to the Knowledge Box will be used. Check out the documentation for more information on how to use this parameter: https://docs.nuclia.dev/docs/rag/advanced/search#minimum-score - /// Minimum bm25 score to filter paragraph and document index results - /// Vectors index to perform the search in. If not provided, NucliaDB will use the default one - /// Resources created before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// Resources created after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// Resources modified before this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// Resources modified after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. - /// List of search features to use. Each value corresponds to a lookup into on of the different indexes - /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. - /// If set to true, the query terms will be highlighted in the results between ... tags - /// Controls which types of metadata are serialized on resources of search results - /// Define which field types are serialized on resources of search results - /// [Deprecated] Please use GET resource endpoint instead to get extracted metadata - /// Whether to return duplicate paragraphs on the same document - /// Whether to return matches for custom knowledge box synonyms of the query terms. Note: only supported for `keyword` and `fulltext` search options. - /// If set to true, the search will automatically add filters to the query. For example, it will filter results containing the entities detected in the query - /// List of security groups to filter search results for. Only resources matching the query and containing the specified security groups will be returned. If empty, all resources will be considered for the search. - /// If set to false (default), excludes hidden resources from search - /// xNdbClient - /// xNucliadbUser - /// xForwardedFor - [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task SearchKnowledgeboxKbKbidSearch(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int topK = 20, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SearchKnowledgeboxKbKbidSearchAsync(kbid, query ?? "", filterExpression, fields, filters, faceted, sortField ?? "", sortLimit, sortOrder, topK, minScore, minScoreSemantic, minScoreBm25, vectorset, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, features, debug, highlight, show, fieldType, extracted, withDuplicates, withSynonyms, autofilter, securityGroups, showHidden, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkKnowledgeboxSearchResultsHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeboxSearchResultsHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// xNdbClient - /// xNucliadbUser - /// xForwardedFor - /// Request body - [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task SearchPostKnowledgeboxKbKbidSearch(string kbid, SearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SearchPostKnowledgeboxKbKbidSearchAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkKnowledgeboxSearchResultsHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeboxSearchResultsHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ListSearchConfigurationsKbKbidSearchConfigurations(string kbid) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ListSearchConfigurationsKbKbidSearchConfigurationsAsync(kbid, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// configName - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task CreateSearchConfigurationKbKbidSearchConfigurationsConfigName(string kbid, string configName, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.CreateSearchConfigurationKbKbidSearchConfigurationsConfigNameAsync(kbid, configName, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// configName - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task UpdateSearchConfigurationKbKbidSearchConfigurationsConfigName(string kbid, string configName, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UpdateSearchConfigurationKbKbidSearchConfigurationsConfigNameAsync(kbid, configName, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// configName - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task SearchConfigurationKbKbidSearchConfigurationsConfigNameDelete(string kbid, string configName) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SearchConfigurationKbKbidSearchConfigurationsConfigNameDeleteAsync(kbid, configName, CancellationToken.None); - - return result switch - { - OkUnitHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// configName - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task SearchConfigurationKbKbidSearchConfigurationsConfigNameGet(string kbid, string configName) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SearchConfigurationKbKbidSearchConfigurationsConfigNameGetAsync(kbid, configName, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// If set to true, file fields will not be saved in the blob storage. They will only be sent to process. - /// xNucliadbUser - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ModifyResourceRslugPrefixKbKbidSlugRslug(string kbid, string rslug, UpdateResourcePayload body, bool xSkipStore = false, string? xNucliadbUser = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ModifyResourceRslugPrefixKbKbidSlugRslugAsync(kbid, rslug, body, xSkipStore, xNucliadbUser ?? "", CancellationToken.None); - - return result switch - { - OkResourceUpdatedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceUpdatedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ResourceRslugPrefixKbKbidSlugRslugDelete(string kbid, string rslug) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceRslugPrefixKbKbidSlugRslugDeleteAsync(kbid, rslug, CancellationToken.None); - - return result switch - { - OkUnitHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rslug - /// show - /// fieldType - /// extracted - /// xNucliadbUser - /// xForwardedFor - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ResourceBySlugKbKbidSlugRslugGet(string kbid, string rslug, List? show = null, List? fieldType = null, List? extracted = null, string? xNucliadbUser = null, string? xForwardedFor = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceBySlugKbKbidSlugRslugGetAsync(kbid, rslug, show, fieldType, extracted, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); - - return result switch - { - OkNucliadbModelsResourceResourceHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorNucliadbModelsResourceResourceHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// fieldId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldConversationRslugPrefixKbKbidSlugRslugConversationFieldId(string kbid, string rslug, string fieldId, InputConversationField body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldConversationRslugPrefixKbKbidSlugRslugConversationFieldIdAsync(kbid, rslug, fieldId, body, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rslug - /// fieldId - /// messageId - /// fileNum - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task DownloadFieldConversationRslugPrefixKbKbidSlugRslugConversationFieldIdDownloadFieldMessageIdFileNum(string kbid, string rslug, string fieldId, string messageId, int fileNum) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadFieldConversationRslugPrefixKbKbidSlugRslugConversationFieldIdDownloadFieldMessageIdFileNumAsync(kbid, rslug, fieldId, messageId, fileNum, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// fieldId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AppendMessagesToConversationFieldRslugPrefixKbKbidSlugRslugConversationFieldIdMessages(string kbid, string rslug, string fieldId, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AppendMessagesToConversationFieldRslugPrefixKbKbidSlugRslugConversationFieldIdMessagesAsync(kbid, rslug, fieldId, body, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// fieldId - /// If set to true, file fields will not be saved in the blob storage. They will only be sent to process. - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldFileRslugPrefixKbKbidSlugRslugFileFieldId(string kbid, string rslug, string fieldId, FileField body, bool xSkipStore = false) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldFileRslugPrefixKbKbidSlugRslugFileFieldIdAsync(kbid, rslug, fieldId, body, xSkipStore, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rslug - /// fieldId - /// inline - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task DownloadFieldFileRslugPrefixKbKbidSlugRslugFileFieldIdDownloadField(string kbid, string rslug, string fieldId, bool inline = false) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadFieldFileRslugPrefixKbKbidSlugRslugFileFieldIdDownloadFieldAsync(kbid, rslug, fieldId, inline, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// field - /// Extract strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task TusPostRslugPrefixKbKbidSlugRslugFileFieldTusupload(string kbid, string rslug, string field, object body, object? xExtractStrategy = null, object? xSplitStrategy = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.TusPostRslugPrefixKbKbidSlugRslugFileFieldTusuploadAsync(kbid, rslug, field, body, xExtractStrategy, xSplitStrategy, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// field - /// uploadId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task TusPatchRslugPrefixKbKbidSlugRslugFileFieldTusuploadUploadId(string kbid, string rslug, string field, string uploadId, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.TusPatchRslugPrefixKbKbidSlugRslugFileFieldTusuploadUploadIdAsync(kbid, rslug, field, uploadId, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// field - /// uploadId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task UploadInformationKbKbidSlugRslugFileFieldTusuploadUploadId(string kbid, string rslug, string field, string uploadId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UploadInformationKbKbidSlugRslugFileFieldTusuploadUploadIdAsync(kbid, rslug, field, uploadId, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Upload a file as a field on an existing resource, if the field exists will return a conflict (419) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// field - /// Name of the file being uploaded. - /// If the file is password protected, the password must be provided here. - /// xLanguage - /// MD5 hash of the file being uploaded. This is used to check if the file has been uploaded before. - /// Extract strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Request body - [Description("Upload a file as a field on an existing resource, if the field exists will return a conflict (419) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task UploadRslugPrefixKbKbidSlugRslugFileFieldUpload(string kbid, string rslug, string field, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UploadRslugPrefixKbKbidSlugRslugFileFieldUploadAsync(kbid, rslug, field, body, xFilename, xPassword, xLanguage, xMd5, xExtractStrategy, xSplitStrategy, CancellationToken.None); - - return result switch - { - OkResourceFileUploadedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFileUploadedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// fieldId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldLinkRslugPrefixKbKbidSlugRslugLinkFieldId(string kbid, string rslug, string fieldId, LinkField body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldLinkRslugPrefixKbKbidSlugRslugLinkFieldIdAsync(kbid, rslug, fieldId, body, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// reindexVectors - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ReindexResourceRslugPrefixKbKbidSlugRslugReindex(string kbid, string rslug, object body, bool reindexVectors = false) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ReindexResourceRslugPrefixKbKbidSlugRslugReindexAsync(kbid, rslug, body, reindexVectors, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// Reset the title of the resource so that the file or link computed titles are set after processing. - /// xNucliadbUser - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ReprocessResourceRslugPrefixKbKbidSlugRslugReprocess(string kbid, string rslug, object body, bool resetTitle = false, string? xNucliadbUser = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ReprocessResourceRslugPrefixKbKbidSlugRslugReprocessAsync(kbid, rslug, body, resetTitle, xNucliadbUser ?? "", CancellationToken.None); - - return result switch - { - OkResourceUpdatedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceUpdatedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// fieldId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task AddResourceFieldTextRslugPrefixKbKbidSlugRslugTextFieldId(string kbid, string rslug, string fieldId, TextField body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddResourceFieldTextRslugPrefixKbKbidSlugRslugTextFieldIdAsync(kbid, rslug, fieldId, body, CancellationToken.None); - - return result switch - { - OkResourceFieldAddedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldAddedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// rslug - /// fieldType - /// fieldId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDelete(string kbid, string rslug, string fieldType, string fieldId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDeleteAsync(kbid, rslug, fieldType, fieldId, CancellationToken.None); - - return result switch - { - OkUnitHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rslug - /// fieldType - /// fieldId - /// show - /// extracted - /// page - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldIdGet(string kbid, string rslug, string fieldType, string fieldId, List? show = null, List? extracted = null, object? page = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ResourceFieldRslugPrefixKbKbidSlugRslugFieldTypeFieldIdGetAsync(kbid, rslug, fieldType, fieldId, show, extracted, page, CancellationToken.None); - - return result switch - { - OkResourceFieldHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFieldHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// rslug - /// fieldType - /// fieldId - /// downloadField - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task DownloadExtractFileRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDownloadExtractedDownloadField(string kbid, string rslug, string fieldType, string fieldId, string downloadField) + [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public async Task SearchPostKnowledgeboxKbKbidSearch(string kbid, SearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadExtractFileRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDownloadExtractedDownloadFieldAsync(kbid, rslug, fieldType, fieldId, downloadField, CancellationToken.None); + var result = await httpClient.SearchPostKnowledgeboxKbKbidSearchAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { - OkobjectHTTPValidationError(var success) => + OkKnowledgeboxSearchResultsHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch + ErrorKnowledgeboxSearchResultsHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -2748,7 +775,6 @@ public async Task DownloadExtractFileRslugPrefixKbKbidSlugRslugFieldType /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body [Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] public async Task ResourceAskEndpointBySlugKbKbidSlugSlugAsk(string kbid, string slug, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { var httpClient = httpClientFactory.CreateClient(); @@ -2770,137 +796,6 @@ public async Task ResourceAskEndpointBySlugKbKbidSlugSlugAsk(string kbid }; } - /// Run Agents on Resource (by slug) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - /// kbid - /// slug - /// xNucliadbUser - /// Request body - [Description("Run Agents on Resource (by slug) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] - public async Task RunAgentsBySlugKbKbidSlugSlugRunAgents(string kbid, string slug, ResourceAgentsRequest body, string? xNucliadbUser = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.RunAgentsBySlugKbKbidSlugSlugRunAgentsAsync(kbid, slug, body, xNucliadbUser ?? "", CancellationToken.None); - - return result switch - { - OkResourceAgentsResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceAgentsResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Add a split strategy to a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` - /// kbid - /// Request body - [Description("Add a split strategy to a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] - public async Task AddSplitStrategyKbKbidSplitStrategies(string kbid, SplitConfiguration body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.AddSplitStrategyKbKbidSplitStrategiesAsync(kbid, body, CancellationToken.None); - - return result switch - { - OkstringHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorstringHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Get available split strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - [Description("Get available split strategies --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task SplitStrategiesKbKbidSplitStrategiesGet(string kbid) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SplitStrategiesKbKbidSplitStrategiesGetAsync(kbid, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Removes a split strategy from a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` - /// kbid - /// strategyId - [Description("Removes a split strategy from a KB --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - [McpServerTool] - public async Task SplitStrategyKbKbidSplitStrategiesStrategyStrategyIdDelete(string kbid, string strategyId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SplitStrategyKbKbidSplitStrategiesStrategyStrategyIdDeleteAsync(kbid, strategyId, CancellationToken.None); - - return result switch - { - OkUnitHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorUnitHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Get split strategy for a given id --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - /// strategyId - [Description("Get split strategy for a given id --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - [McpServerTool] - public async Task SplitStrategyFromIdKbKbidSplitStrategiesStrategyStrategyIdGet(string kbid, string strategyId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SplitStrategyFromIdKbKbidSplitStrategiesStrategyStrategyIdGetAsync(kbid, strategyId, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - /// Suggestions on a knowledge box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// The query to get suggestions for @@ -2921,7 +816,6 @@ public async Task SplitStrategyFromIdKbKbidSplitStrategiesStrategyStrate /// xNucliadbUser /// xForwardedFor [Description("Suggestions on a knowledge box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] public async Task SuggestKnowledgeboxKbKbidSuggest(string kbid, string query, List? fields = null, List? filters = null, List? faceted = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, List? show = null, List? fieldType = null, bool debug = false, bool highlight = false, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { var httpClient = httpClientFactory.CreateClient(); @@ -2948,7 +842,6 @@ public async Task SuggestKnowledgeboxKbKbidSuggest(string kbid, string q /// xShowConsumption /// Request body [Description("Summarize Your Documents --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - [McpServerTool] public async Task SummarizeEndpointKbKbidSummarize(string kbid, SummarizeRequest body, bool xShowConsumption = false) { var httpClient = httpClientFactory.CreateClient(); @@ -2970,116 +863,6 @@ public async Task SummarizeEndpointKbKbidSummarize(string kbid, Summariz }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// Extract strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task TusPostKbKbidTusupload(string kbid, object body, object? xExtractStrategy = null, object? xSplitStrategy = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.TusPostKbKbidTusuploadAsync(kbid, body, xExtractStrategy, xSplitStrategy, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// TUS Server information - /// kbid - /// rid - /// rslug - /// uploadId - /// field - [Description("TUS Server information")] - [McpServerTool] - public async Task TusOptionsKbKbidTusupload(string kbid, object? rid = null, object? rslug = null, object? uploadId = null, object? field = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.TusOptionsKbKbidTusuploadAsync(kbid, rid, rslug, uploadId, field, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// uploadId - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task KbKbidTusuploadUploadIdPatch(string kbid, string uploadId, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.KbKbidTusuploadUploadIdPatchAsync(kbid, uploadId, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// uploadId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] - public async Task UploadInformationKbKbidTusuploadUploadId(string kbid, string uploadId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UploadInformationKbKbidTusuploadUploadIdAsync(kbid, uploadId, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - /// Upload a file onto a Knowledge Box, field id will be file and rid will be autogenerated. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` /// kbid /// Name of the file being uploaded. @@ -3090,7 +873,6 @@ public async Task UploadInformationKbKbidTusuploadUploadId(string kbid, /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. /// Request body [Description("Upload a file onto a Knowledge Box, field id will be file and rid will be autogenerated. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - [McpServerTool] public async Task UploadKbKbidUpload(string kbid, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) { var httpClient = httpClientFactory.CreateClient(); @@ -3116,7 +898,6 @@ public async Task UploadKbKbidUpload(string kbid, object body, object? x /// xNUCLIADBROLES /// Request body [Description("Create a new knowledge box")] - [McpServerTool] public async Task CreateKnowledgeBoxKbs(object body, string xNUCLIADBROLES = "MANAGER") { var httpClient = httpClientFactory.CreateClient(); @@ -3141,7 +922,6 @@ public async Task CreateKnowledgeBoxKbs(object body, string xNUCLIADBROL /// Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload [Description("Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload")] - [McpServerTool] public async Task LearningConfigurationSchemaLearningConfigurationSchema() { var httpClient = httpClientFactory.CreateClient(); From cfd348214466fe9841f8aa38f7414dbe9e073f96 Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Mon, 20 Oct 2025 06:51:00 +1100 Subject: [PATCH 4/9] MCP --- .../McpToolGenerator.cs | 13 +- Samples/NucliaDbClient.McpServer/Program.cs | 5 +- .../run-mcp-server.sh | 20 +- Samples/NucliaDbClient.McpServer/test-mcp.sh | 8 + .../Generated/NucliaDbMcpTools.g.cs | 442 +++--------------- 5 files changed, 80 insertions(+), 408 deletions(-) create mode 100755 Samples/NucliaDbClient.McpServer/test-mcp.sh diff --git a/RestClient.Net.McpGenerator/McpToolGenerator.cs b/RestClient.Net.McpGenerator/McpToolGenerator.cs index d44acbcc..422b45e8 100644 --- a/RestClient.Net.McpGenerator/McpToolGenerator.cs +++ b/RestClient.Net.McpGenerator/McpToolGenerator.cs @@ -78,11 +78,13 @@ public static string GenerateTools( using System.Text.Json; using Outcome; using {{extensionsNamespace}}; + using ModelContextProtocol.Server; namespace {{@namespace}}; /// MCP server tools for {{serverName}} API. - public class {{serverName}}Tools(IHttpClientFactory httpClientFactory) + [McpServerToolType] + public static class {{serverName}}Tools { private static readonly JsonSerializerOptions JsonOptions = new() { @@ -225,13 +227,16 @@ string errorType var okAlias = $"Ok{responseType}"; var errorAlias = $"Error{responseType}"; + var httpClientParam = methodParamsStr.Length > 0 ? "HttpClient httpClient, " : "HttpClient httpClient"; + var allParams = httpClientParam + methodParamsStr; + return $$""" /// {{SanitizeDescription(summary)}} {{paramDescriptions}} - [Description("{{SanitizeDescription(summary)}}")] - public async Task {{toolName}}({{methodParamsStr}}) + /// HttpClient instance + [McpServerTool, Description("{{SanitizeDescription(summary)}}")] + public static async Task {{toolName}}({{allParams}}) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.{{extensionMethodName}}({{extensionCallArgsStr}}); return result switch diff --git a/Samples/NucliaDbClient.McpServer/Program.cs b/Samples/NucliaDbClient.McpServer/Program.cs index e83ed6f1..f102ca29 100644 --- a/Samples/NucliaDbClient.McpServer/Program.cs +++ b/Samples/NucliaDbClient.McpServer/Program.cs @@ -16,7 +16,7 @@ var nucleaBaseUrl = Environment.GetEnvironmentVariable("NUCLIA_BASE_URL") ?? "http://localhost:8080/api/v1"; -// Configure HttpClient with base URL +// Configure default HttpClient with base URL builder.Services.AddHttpClient( string.Empty, client => @@ -26,9 +26,6 @@ } ); -// Add the NucliaDB tools to DI -builder.Services.AddSingleton(); - // Add MCP server with stdio transport and tools from assembly builder.Services.AddMcpServer().WithStdioServerTransport().WithToolsFromAssembly(); diff --git a/Samples/NucliaDbClient.McpServer/run-mcp-server.sh b/Samples/NucliaDbClient.McpServer/run-mcp-server.sh index fb9a5654..177abc7d 100755 --- a/Samples/NucliaDbClient.McpServer/run-mcp-server.sh +++ b/Samples/NucliaDbClient.McpServer/run-mcp-server.sh @@ -1,25 +1,15 @@ #!/bin/bash - -# Quick run script for the MCP server (assumes NucliaDB is already running) set -e SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COMPOSE_DIR="$SCRIPT_DIR/../NucliaDbClient" -echo "Starting NucliaDB MCP Server..." -echo "===============================" -echo "" +cd "$COMPOSE_DIR" +docker compose down -v +docker compose up -d -# Check if NucliaDB is running -if ! curl -s -f "http://localhost:8080" > /dev/null 2>&1; then - echo "⚠ Warning: NucliaDB doesn't appear to be running on http://localhost:8080" - echo "Run ./start-mcp-server.sh to start both docker-compose and the MCP server" - echo "" -fi +until curl -s -f "http://localhost:8080" > /dev/null 2>&1; do sleep 1; done cd "$SCRIPT_DIR" - -# Set environment variable for NucliaDB URL export NUCLIA_BASE_URL="http://localhost:8080/api/v1" - -# Run the MCP server dotnet run diff --git a/Samples/NucliaDbClient.McpServer/test-mcp.sh b/Samples/NucliaDbClient.McpServer/test-mcp.sh new file mode 100755 index 00000000..315a6399 --- /dev/null +++ b/Samples/NucliaDbClient.McpServer/test-mcp.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Test if MCP server exposes tools correctly + +# Send tools/list request to the MCP server +echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | \ + dotnet run --project /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer/NucliaDbClient.McpServer.csproj --no-build 2>/dev/null | \ + grep -v "^info:" | \ + head -20 diff --git a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs index e9f2cc8a..9a64e59e 100644 --- a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs +++ b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs @@ -3,11 +3,13 @@ using System.Text.Json; using Outcome; using NucliaDB.Generated; +using ModelContextProtocol.Server; namespace NucliaDB.Mcp; /// MCP server tools for NucliaDb API. -public class NucliaDbTools(IHttpClientFactory httpClientFactory) +[McpServerToolType] +public static class NucliaDbTools { private static readonly JsonSerializerOptions JsonOptions = new() { @@ -15,55 +17,6 @@ public class NucliaDbTools(IHttpClientFactory httpClientFactory) PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` - /// slug - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - public async Task KbBySlugKbSSlugGet(string slug) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.KbBySlugKbSSlugGetAsync(slug, CancellationToken.None); - - return result switch - { - OkKnowledgeBoxObjHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeBoxObjHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` - /// kbid - /// xNUCLIADBROLES - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - public async Task KbKbKbidGet(string kbid, string xNUCLIADBROLES = "READER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.KbKbKbidGetAsync(kbid, xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkKnowledgeBoxObjHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeBoxObjHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - /// Ask questions on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// xNdbClient @@ -72,10 +25,10 @@ public async Task KbKbKbidGet(string kbid, string xNUCLIADBROLES = "READ /// xForwardedFor /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body - [Description("Ask questions on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task AskKnowledgeboxEndpointKbKbidAsk(string kbid, AskRequest body, string xNdbClient = "api", bool xShowConsumption = false, string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) + /// HttpClient instance + [McpServerTool, Description("Ask questions on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task AskKnowledgeboxEndpointKbKbidAsk(HttpClient httpClient, string kbid, AskRequest body, string xNdbClient = "api", bool xShowConsumption = false, string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.AskKnowledgeboxEndpointKbKbidAskAsync(kbid, body, xNdbClient, xShowConsumption, xNucliadbUser ?? "", xForwardedFor ?? "", xSynchronous, CancellationToken.None); return result switch @@ -112,10 +65,10 @@ public async Task AskKnowledgeboxEndpointKbKbidAsk(string kbid, AskReque /// Resources modified after this date will be filtered out of search results. Datetime are represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00. /// Set to filter only hidden or only non-hidden resources. Default is to return everything /// Controls which types of metadata are serialized on resources of search results - [Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task CatalogGetKbKbidCatalog(string kbid, string? query = null, object? filterExpression = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int pageNumber = 0, int pageSize = 20, object? withStatus = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, object? hidden = null, List? show = null) + /// HttpClient instance + [McpServerTool, Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task CatalogGetKbKbidCatalog(HttpClient httpClient, string kbid, string? query = null, object? filterExpression = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int pageNumber = 0, int pageSize = 20, object? withStatus = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, object? hidden = null, List? show = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.CatalogGetKbKbidCatalogAsync(kbid, query ?? "", filterExpression, filters, faceted, sortField ?? "", sortLimit, sortOrder, pageNumber, pageSize, withStatus, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, hidden, show, CancellationToken.None); return result switch @@ -137,10 +90,10 @@ public async Task CatalogGetKbKbidCatalog(string kbid, string? query = n /// List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// Request body - [Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task CatalogPostKbKbidCatalog(string kbid, CatalogRequest body) + /// HttpClient instance + [McpServerTool, Description("List resources of a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task CatalogPostKbKbidCatalog(HttpClient httpClient, string kbid, CatalogRequest body) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.CatalogPostKbKbidCatalogAsync(kbid, body, CancellationToken.None); return result switch @@ -159,167 +112,16 @@ public async Task CatalogPostKbKbidCatalog(string kbid, CatalogRequest b }; } - /// Update current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` - /// kbid - /// Request body - [Description("Update current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - public async Task ConfigurationKbKbidConfigurationPatch(string kbid, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ConfigurationKbKbidConfigurationPatchAsync(kbid, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Create configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` - /// kbid - /// Request body - [Description("Create configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - public async Task SetConfigurationKbKbidConfiguration(string kbid, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.SetConfigurationKbKbidConfigurationAsync(kbid, body, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Summary of amount of different things inside a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` - /// kbid - /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. - /// xNUCLIADBROLES - [Description("Summary of amount of different things inside a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] - public async Task KnowledgeboxCountersKbKbidCounters(string kbid, bool debug = false, string xNUCLIADBROLES = "READER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.KnowledgeboxCountersKbKbidCountersAsync(kbid, debug, xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkKnowledgeboxCountersHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeboxCountersHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` - /// kbid - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - public async Task StartKbExportEndpointKbKbidExport(string kbid, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.StartKbExportEndpointKbKbidExportAsync(kbid, body, CancellationToken.None); - - return result switch - { - OkCreateExportResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorCreateExportResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` - /// kbid - /// exportId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - public async Task DownloadExportKbEndpointKbKbidExportExportId(string kbid, string exportId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadExportKbEndpointKbKbidExportExportIdAsync(kbid, exportId, CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` - /// kbid - /// exportId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - public async Task ExportStatusEndpointKbKbidExportExportIdStatusGet(string kbid, string exportId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ExportStatusEndpointKbKbidExportExportIdStatusGetAsync(kbid, exportId, CancellationToken.None); - - return result switch - { - OkStatusResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorStatusResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - /// Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// xNdbClient /// xNucliadbUser /// xForwardedFor /// Request body - [Description("Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, FeedbackRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task SendFeedbackEndpointKbKbidFeedback(HttpClient httpClient, string kbid, FeedbackRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.SendFeedbackEndpointKbKbidFeedbackAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -370,10 +172,10 @@ public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, Feedba /// xNdbClient /// xNucliadbUser /// xForwardedFor - [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task FindKnowledgeboxKbKbidFind(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, object? topK = null, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string rankFusion = "rrf", object? reranker = null, object? searchConfiguration = null, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task FindKnowledgeboxKbKbidFind(HttpClient httpClient, string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, object? topK = null, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string rankFusion = "rrf", object? reranker = null, object? searchConfiguration = null, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.FindKnowledgeboxKbKbidFindAsync(kbid, query ?? "", filterExpression, fields, filters, topK, minScore, minScoreSemantic, minScoreBm25, vectorset, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, features, debug, highlight, show, fieldType, extracted, withDuplicates, withSynonyms, autofilter, securityGroups, showHidden, rankFusion, reranker, searchConfiguration, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -398,10 +200,10 @@ public async Task FindKnowledgeboxKbKbidFind(string kbid, string? query /// xNucliadbUser /// xForwardedFor /// Request body - [Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Find on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task FindPostKnowledgeboxKbKbidFind(HttpClient httpClient, string kbid, FindRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.FindPostKnowledgeboxKbKbidFindAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -426,10 +228,10 @@ public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindReques /// xNucliadbUser /// xForwardedFor /// Request body - [Description("Search on the Knowledge Box graph and retrieve triplets of vertex-edge-vertex --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task GraphSearchKnowledgeboxKbKbidGraph(string kbid, GraphSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Search on the Knowledge Box graph and retrieve triplets of vertex-edge-vertex --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task GraphSearchKnowledgeboxKbKbidGraph(HttpClient httpClient, string kbid, GraphSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.GraphSearchKnowledgeboxKbKbidGraphAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -454,10 +256,10 @@ public async Task GraphSearchKnowledgeboxKbKbidGraph(string kbid, GraphS /// xNucliadbUser /// xForwardedFor /// Request body - [Description("Search on the Knowledge Box graph and retrieve nodes (vertices) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(string kbid, GraphNodesSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Search on the Knowledge Box graph and retrieve nodes (vertices) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(HttpClient httpClient, string kbid, GraphNodesSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.GraphNodesSearchKnowledgeboxKbKbidGraphNodesAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -482,10 +284,10 @@ public async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(string kb /// xNucliadbUser /// xForwardedFor /// Request body - [Description("Search on the Knowledge Box graph and retrieve relations (edges) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRelations(string kbid, GraphRelationsSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Search on the Knowledge Box graph and retrieve relations (edges) --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRelations(HttpClient httpClient, string kbid, GraphRelationsSearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.GraphRelationsSearchKnowledgeboxKbKbidGraphRelationsAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -504,56 +306,6 @@ public async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRelations(s }; } - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` - /// kbid - /// Request body - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] - public async Task StartKbImportEndpointKbKbidImport(string kbid, object body) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.StartKbImportEndpointKbKbidImportAsync(kbid, body, CancellationToken.None); - - return result switch - { - OkCreateImportResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorCreateImportResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` - /// kbid - /// importId - [Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] - public async Task ImportStatusEndpointKbKbidImportImportIdStatusGet(string kbid, string importId) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ImportStatusEndpointKbKbidImportImportIdStatusGetAsync(kbid, importId, CancellationToken.None); - - return result switch - { - OkStatusResponseHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorStatusResponseHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - /// Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// endpoint @@ -561,10 +313,10 @@ public async Task ImportStatusEndpointKbKbidImportImportIdStatusGet(stri /// xNdbClient /// xForwardedFor /// Request body - [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task PredictProxyEndpointKbKbidPredictEndpoint(string kbid, string endpoint, object body, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task PredictProxyEndpointKbKbidPredictEndpoint(HttpClient httpClient, string kbid, string endpoint, object body, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.PredictProxyEndpointKbKbidPredictEndpointAsync(kbid, endpoint, body, xNucliadbUser ?? "", xNdbClient, xForwardedFor ?? "", CancellationToken.None); return result switch @@ -589,10 +341,10 @@ public async Task PredictProxyEndpointKbKbidPredictEndpoint(string kbid, /// xNucliadbUser /// xNdbClient /// xForwardedFor - [Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task PredictProxyEndpointKbKbidPredictEndpoint2(string kbid, string endpoint, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task PredictProxyEndpointKbKbidPredictEndpoint2(HttpClient httpClient, string kbid, string endpoint, string? xNucliadbUser = null, string xNdbClient = "api", string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.PredictProxyEndpointKbKbidPredictEndpointAsync2(kbid, endpoint, xNucliadbUser ?? "", xNdbClient, xForwardedFor ?? "", CancellationToken.None); return result switch @@ -620,10 +372,10 @@ public async Task PredictProxyEndpointKbKbidPredictEndpoint2(string kbid /// xForwardedFor /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body - [Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task ResourceAskEndpointByUuidKbKbidResourceRidAsk(string kbid, string rid, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) + /// HttpClient instance + [McpServerTool, Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task ResourceAskEndpointByUuidKbKbidResourceRidAsk(HttpClient httpClient, string kbid, string rid, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.ResourceAskEndpointByUuidKbKbidResourceRidAskAsync(kbid, rid, body, xShowConsumption, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", xSynchronous, CancellationToken.None); return result switch @@ -660,10 +412,10 @@ public async Task ResourceAskEndpointByUuidKbKbidResourceRidAsk(string k /// If set to true, the query terms will be highlighted in the results between ... tags /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. /// xNdbClient - [Description("Search on a single resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task ResourceSearchKbKbidResourceRidSearch(string kbid, string rid, string query, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, object? sortField = null, string sortOrder = "desc", object? topK = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, bool highlight = false, bool debug = false, string xNdbClient = "api") + /// HttpClient instance + [McpServerTool, Description("Search on a single resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task ResourceSearchKbKbidResourceRidSearch(HttpClient httpClient, string kbid, string rid, string query, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, object? sortField = null, string sortOrder = "desc", object? topK = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, bool highlight = false, bool debug = false, string xNdbClient = "api") { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.ResourceSearchKbKbidResourceRidSearchAsync(kbid, rid, query, filterExpression, fields, filters, faceted, sortField, sortOrder, topK, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, highlight, debug, xNdbClient, CancellationToken.None); return result switch @@ -715,10 +467,10 @@ public async Task ResourceSearchKbKbidResourceRidSearch(string kbid, str /// xNdbClient /// xNucliadbUser /// xForwardedFor - [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task SearchKnowledgeboxKbKbidSearch(string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int topK = 20, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task SearchKnowledgeboxKbKbidSearch(HttpClient httpClient, string kbid, string? query = null, object? filterExpression = null, List? fields = null, List? filters = null, List? faceted = null, string? sortField = null, object? sortLimit = null, string sortOrder = "desc", int topK = 20, object? minScore = null, object? minScoreSemantic = null, float minScoreBm25 = 0, object? vectorset = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, bool debug = false, bool highlight = false, List? show = null, List? fieldType = null, List? extracted = null, bool withDuplicates = false, bool withSynonyms = false, bool autofilter = false, List? securityGroups = null, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.SearchKnowledgeboxKbKbidSearchAsync(kbid, query ?? "", filterExpression, fields, filters, faceted, sortField ?? "", sortLimit, sortOrder, topK, minScore, minScoreSemantic, minScoreBm25, vectorset, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, features, debug, highlight, show, fieldType, extracted, withDuplicates, withSynonyms, autofilter, securityGroups, showHidden, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -743,10 +495,10 @@ public async Task SearchKnowledgeboxKbKbidSearch(string kbid, string? qu /// xNucliadbUser /// xForwardedFor /// Request body - [Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task SearchPostKnowledgeboxKbKbidSearch(string kbid, SearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Search on a Knowledge Box and retrieve separate results for documents, paragraphs, and sentences. Usually, it is better to use `find` --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task SearchPostKnowledgeboxKbKbidSearch(HttpClient httpClient, string kbid, SearchRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.SearchPostKnowledgeboxKbKbidSearchAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -774,10 +526,10 @@ public async Task SearchPostKnowledgeboxKbKbidSearch(string kbid, Search /// xForwardedFor /// When set to true, outputs response as JSON in a non-streaming way. This is slower and requires waiting for entire answer to be ready. /// Request body - [Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task ResourceAskEndpointBySlugKbKbidSlugSlugAsk(string kbid, string slug, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) + /// HttpClient instance + [McpServerTool, Description("Ask questions to a resource --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task ResourceAskEndpointBySlugKbKbidSlugSlugAsk(HttpClient httpClient, string kbid, string slug, AskRequest body, bool xShowConsumption = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null, bool xSynchronous = false) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.ResourceAskEndpointBySlugKbKbidSlugSlugAskAsync(kbid, slug, body, xShowConsumption, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", xSynchronous, CancellationToken.None); return result switch @@ -815,10 +567,10 @@ public async Task ResourceAskEndpointBySlugKbKbidSlugSlugAsk(string kbid /// xNdbClient /// xNucliadbUser /// xForwardedFor - [Description("Suggestions on a knowledge box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task SuggestKnowledgeboxKbKbidSuggest(string kbid, string query, List? fields = null, List? filters = null, List? faceted = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, List? show = null, List? fieldType = null, bool debug = false, bool highlight = false, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// HttpClient instance + [McpServerTool, Description("Suggestions on a knowledge box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task SuggestKnowledgeboxKbKbidSuggest(HttpClient httpClient, string kbid, string query, List? fields = null, List? filters = null, List? faceted = null, object? rangeCreationStart = null, object? rangeCreationEnd = null, object? rangeModificationStart = null, object? rangeModificationEnd = null, List? features = null, List? show = null, List? fieldType = null, bool debug = false, bool highlight = false, bool showHidden = false, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.SuggestKnowledgeboxKbKbidSuggestAsync(kbid, query, fields, filters, faceted, rangeCreationStart, rangeCreationEnd, rangeModificationStart, rangeModificationEnd, features, show, fieldType, debug, highlight, showHidden, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch @@ -841,10 +593,10 @@ public async Task SuggestKnowledgeboxKbKbidSuggest(string kbid, string q /// kbid /// xShowConsumption /// Request body - [Description("Summarize Your Documents --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] - public async Task SummarizeEndpointKbKbidSummarize(string kbid, SummarizeRequest body, bool xShowConsumption = false) + /// HttpClient instance + [McpServerTool, Description("Summarize Your Documents --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER`")] + public static async Task SummarizeEndpointKbKbidSummarize(HttpClient httpClient, string kbid, SummarizeRequest body, bool xShowConsumption = false) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.SummarizeEndpointKbKbidSummarizeAsync(kbid, body, xShowConsumption, CancellationToken.None); return result switch @@ -862,84 +614,4 @@ public async Task SummarizeEndpointKbKbidSummarize(string kbid, Summariz _ => "Unknown result" }; } - - /// Upload a file onto a Knowledge Box, field id will be file and rid will be autogenerated. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` - /// kbid - /// Name of the file being uploaded. - /// If the file is password protected, the password must be provided here. - /// xLanguage - /// MD5 hash of the file being uploaded. This is used to check if the file has been uploaded before. - /// Extract strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. - /// Request body - [Description("Upload a file onto a Knowledge Box, field id will be file and rid will be autogenerated. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] - public async Task UploadKbKbidUpload(string kbid, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.UploadKbKbidUploadAsync(kbid, body, xFilename, xPassword, xLanguage, xMd5, xExtractStrategy, xSplitStrategy, CancellationToken.None); - - return result switch - { - OkResourceFileUploadedHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorResourceFileUploadedHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Create a new knowledge box - /// xNUCLIADBROLES - /// Request body - [Description("Create a new knowledge box")] - public async Task CreateKnowledgeBoxKbs(object body, string xNUCLIADBROLES = "MANAGER") - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.CreateKnowledgeBoxKbsAsync(body, xNUCLIADBROLES, CancellationToken.None); - - return result switch - { - OkKnowledgeBoxObj(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeBoxObj(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } - - /// Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload - - [Description("Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload")] - public async Task LearningConfigurationSchemaLearningConfigurationSchema() - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.LearningConfigurationSchemaLearningConfigurationSchemaAsync(CancellationToken.None); - - return result switch - { - OkobjectHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorobjectHTTPValidationError(var httpError) => httpError switch - { - HttpError.ErrorResponseError err => - $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", - HttpError.ExceptionError err => - $"Exception: {err.Exception.Message}", - _ => "Unknown error" - }, - _ => "Unknown result" - }; - } } \ No newline at end of file From 6bd8f7b2c73dea4379d9901b79f1ad25a39b17c2 Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Mon, 20 Oct 2025 07:09:27 +1100 Subject: [PATCH 5/9] Works --- .../Generated/NucliaDbMcpTools.g.cs | 330 ++++++++++++++++++ Samples/NucliaDbClient/NucliaDbClient.csproj | 3 + 2 files changed, 333 insertions(+) diff --git a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs index 9a64e59e..8bafd7fa 100644 --- a/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs +++ b/Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs @@ -17,6 +17,55 @@ public static class NucliaDbTools PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` + /// slug + /// HttpClient instance + [McpServerTool, Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + public static async Task KbBySlugKbSSlugGet(HttpClient httpClient, string slug) + { + var result = await httpClient.KbBySlugKbSSlugGetAsync(slug, CancellationToken.None); + + return result switch + { + OkKnowledgeBoxObjHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorKnowledgeBoxObjHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` + /// kbid + /// xNUCLIADBROLES + /// HttpClient instance + [McpServerTool, Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + public static async Task KbKbKbidGet(HttpClient httpClient, string kbid, string xNUCLIADBROLES = "READER") + { + var result = await httpClient.KbKbKbidGetAsync(kbid, xNUCLIADBROLES, CancellationToken.None); + + return result switch + { + OkKnowledgeBoxObjHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorKnowledgeBoxObjHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + /// Ask questions on a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// xNdbClient @@ -112,6 +161,157 @@ public static async Task CatalogPostKbKbidCatalog(HttpClient httpClient, }; } + /// Update current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` + /// kbid + /// Request body + /// HttpClient instance + [McpServerTool, Description("Update current configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + public static async Task ConfigurationKbKbidConfigurationPatch(HttpClient httpClient, string kbid, object body) + { + var result = await httpClient.ConfigurationKbKbidConfigurationPatchAsync(kbid, body, CancellationToken.None); + + return result switch + { + OkobjectHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorobjectHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// Create configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` + /// kbid + /// Request body + /// HttpClient instance + [McpServerTool, Description("Create configuration of models assigned to a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + public static async Task SetConfigurationKbKbidConfiguration(HttpClient httpClient, string kbid, object body) + { + var result = await httpClient.SetConfigurationKbKbidConfigurationAsync(kbid, body, CancellationToken.None); + + return result switch + { + OkobjectHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorobjectHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// Summary of amount of different things inside a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER` + /// kbid + /// If set, the response will include some extra metadata for debugging purposes, like the list of queried nodes. + /// xNUCLIADBROLES + /// HttpClient instance + [McpServerTool, Description("Summary of amount of different things inside a knowledgebox --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` - `MANAGER`")] + public static async Task KnowledgeboxCountersKbKbidCounters(HttpClient httpClient, string kbid, bool debug = false, string xNUCLIADBROLES = "READER") + { + var result = await httpClient.KnowledgeboxCountersKbKbidCountersAsync(kbid, debug, xNUCLIADBROLES, CancellationToken.None); + + return result switch + { + OkKnowledgeboxCountersHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorKnowledgeboxCountersHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` + /// kbid + /// Request body + /// HttpClient instance + [McpServerTool, Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + public static async Task StartKbExportEndpointKbKbidExport(HttpClient httpClient, string kbid, object body) + { + var result = await httpClient.StartKbExportEndpointKbKbidExportAsync(kbid, body, CancellationToken.None); + + return result switch + { + OkCreateExportResponseHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorCreateExportResponseHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` + /// kbid + /// exportId + /// HttpClient instance + [McpServerTool, Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + public static async Task DownloadExportKbEndpointKbKbidExportExportId(HttpClient httpClient, string kbid, string exportId) + { + var result = await httpClient.DownloadExportKbEndpointKbKbidExportExportIdAsync(kbid, exportId, CancellationToken.None); + + return result switch + { + OkobjectHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorobjectHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` + /// kbid + /// exportId + /// HttpClient instance + [McpServerTool, Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + public static async Task ExportStatusEndpointKbKbidExportExportIdStatusGet(HttpClient httpClient, string kbid, string exportId) + { + var result = await httpClient.ExportStatusEndpointKbKbidExportExportIdStatusGetAsync(kbid, exportId, CancellationToken.None); + + return result switch + { + OkStatusResponseHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorStatusResponseHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + /// Send feedback for a search operation in a Knowledge Box --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// xNdbClient @@ -306,6 +506,56 @@ public static async Task GraphRelationsSearchKnowledgeboxKbKbidGraphRela }; } + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER` + /// kbid + /// Request body + /// HttpClient instance + [McpServerTool, Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `WRITER`")] + public static async Task StartKbImportEndpointKbKbidImport(HttpClient httpClient, string kbid, object body) + { + var result = await httpClient.StartKbImportEndpointKbKbidImportAsync(kbid, body, CancellationToken.None); + + return result switch + { + OkCreateImportResponseHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorCreateImportResponseHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER` + /// kbid + /// importId + /// HttpClient instance + [McpServerTool, Description("--- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `MANAGER` - `READER`")] + public static async Task ImportStatusEndpointKbKbidImportImportIdStatusGet(HttpClient httpClient, string kbid, string importId) + { + var result = await httpClient.ImportStatusEndpointKbKbidImportImportIdStatusGetAsync(kbid, importId, CancellationToken.None); + + return result switch + { + OkStatusResponseHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorStatusResponseHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + /// Convenience endpoint that proxies requests to the Predict API. It adds the Knowledge Box configuration settings as headers to the predict API request. Refer to the Predict API documentation for more details about the request and response models: https://docs.nuclia.dev/docs/nua-api#tag/Predict --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `READER` /// kbid /// endpoint @@ -614,4 +864,84 @@ public static async Task SummarizeEndpointKbKbidSummarize(HttpClient htt _ => "Unknown result" }; } + + /// Upload a file onto a Knowledge Box, field id will be file and rid will be autogenerated. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER` + /// kbid + /// Name of the file being uploaded. + /// If the file is password protected, the password must be provided here. + /// xLanguage + /// MD5 hash of the file being uploaded. This is used to check if the file has been uploaded before. + /// Extract strategy to use when uploading a file. If not provided, the default strategy will be used. + /// Split strategy to use when uploading a file. If not provided, the default strategy will be used. + /// Request body + /// HttpClient instance + [McpServerTool, Description("Upload a file onto a Knowledge Box, field id will be file and rid will be autogenerated. --- ## Authorization roles Authenticated user needs to fulfill one of this roles, otherwise the request will be rejected with a `403` response. - `WRITER`")] + public static async Task UploadKbKbidUpload(HttpClient httpClient, string kbid, object body, object? xFilename = null, object? xPassword = null, object? xLanguage = null, object? xMd5 = null, object? xExtractStrategy = null, object? xSplitStrategy = null) + { + var result = await httpClient.UploadKbKbidUploadAsync(kbid, body, xFilename, xPassword, xLanguage, xMd5, xExtractStrategy, xSplitStrategy, CancellationToken.None); + + return result switch + { + OkResourceFileUploadedHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorResourceFileUploadedHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// Create a new knowledge box + /// xNUCLIADBROLES + /// Request body + /// HttpClient instance + [McpServerTool, Description("Create a new knowledge box")] + public static async Task CreateKnowledgeBoxKbs(HttpClient httpClient, object body, string xNUCLIADBROLES = "MANAGER") + { + var result = await httpClient.CreateKnowledgeBoxKbsAsync(body, xNUCLIADBROLES, CancellationToken.None); + + return result switch + { + OkKnowledgeBoxObj(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorKnowledgeBoxObj(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } + + /// Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload + + /// HttpClient instance + [McpServerTool, Description("Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload")] + public static async Task LearningConfigurationSchemaLearningConfigurationSchema(HttpClient httpClient) + { + var result = await httpClient.LearningConfigurationSchemaLearningConfigurationSchemaAsync(CancellationToken.None); + + return result switch + { + OkobjectHTTPValidationError(var success) => + JsonSerializer.Serialize(success, JsonOptions), + ErrorobjectHTTPValidationError(var httpError) => httpError switch + { + HttpError.ErrorResponseError err => + $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", + HttpError.ExceptionError err => + $"Exception: {err.Exception.Message}", + _ => "Unknown error" + }, + _ => "Unknown result" + }; + } } \ No newline at end of file diff --git a/Samples/NucliaDbClient/NucliaDbClient.csproj b/Samples/NucliaDbClient/NucliaDbClient.csproj index 3c25bac2..f2cf1634 100644 --- a/Samples/NucliaDbClient/NucliaDbClient.csproj +++ b/Samples/NucliaDbClient/NucliaDbClient.csproj @@ -18,4 +18,7 @@ + + + From 8786ecc8796b0ba78f0c10bd43361bdb442e35dc Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Mon, 20 Oct 2025 07:14:00 +1100 Subject: [PATCH 6/9] Add template --- .github/pull_request_template.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..51fc71c8 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,5 @@ +# TLDR; + +# Summary + +# Details From 46b4f56dc45c2384c82f4fe5ebf8d30f87cf9858 Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Mon, 20 Oct 2025 07:15:58 +1100 Subject: [PATCH 7/9] format --- RestClient.Net.McpGenerator.Cli/Program.cs | 5 ++++- RestClient.Net.McpGenerator/McpToolGenerator.cs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/RestClient.Net.McpGenerator.Cli/Program.cs b/RestClient.Net.McpGenerator.Cli/Program.cs index 996eb406..7c2cc820 100644 --- a/RestClient.Net.McpGenerator.Cli/Program.cs +++ b/RestClient.Net.McpGenerator.Cli/Program.cs @@ -169,7 +169,10 @@ static async Task GenerateCode(Config config) if (!string.IsNullOrWhiteSpace(config.TagsFilter)) { includeTags = new HashSet( - config.TagsFilter.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries), + config.TagsFilter.Split( + ',', + StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries + ), StringComparer.OrdinalIgnoreCase ); Console.WriteLine($"Filtering to tags: {string.Join(", ", includeTags)}"); diff --git a/RestClient.Net.McpGenerator/McpToolGenerator.cs b/RestClient.Net.McpGenerator/McpToolGenerator.cs index 422b45e8..022a6772 100644 --- a/RestClient.Net.McpGenerator/McpToolGenerator.cs +++ b/RestClient.Net.McpGenerator/McpToolGenerator.cs @@ -227,7 +227,8 @@ string errorType var okAlias = $"Ok{responseType}"; var errorAlias = $"Error{responseType}"; - var httpClientParam = methodParamsStr.Length > 0 ? "HttpClient httpClient, " : "HttpClient httpClient"; + var httpClientParam = + methodParamsStr.Length > 0 ? "HttpClient httpClient, " : "HttpClient httpClient"; var allParams = httpClientParam + methodParamsStr; return $$""" From 39a6b875e904beed8f58ceaffe7dd4d0493245ce Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Mon, 20 Oct 2025 07:21:49 +1100 Subject: [PATCH 8/9] fix build --- RestClient.sln | 28 ++++++++++++++++++++ Samples/NucliaDbClient/NucliaDbClient.csproj | 1 + 2 files changed, 29 insertions(+) diff --git a/RestClient.sln b/RestClient.sln index 5bbab490..1f8166df 100644 --- a/RestClient.sln +++ b/RestClient.sln @@ -39,6 +39,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucliaDbClient", "Samples\N EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucliaDbClient.Tests", "Samples\NucliaDbClient.Tests\NucliaDbClient.Tests.csproj", "{8FD2A6D3-C50D-42BC-A10F-DC9B35F5F2AC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestClient.Net.McpGenerator", "RestClient.Net.McpGenerator\RestClient.Net.McpGenerator.csproj", "{54E7C113-63C4-4079-B355-D678A83BC58B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestClient.Net.McpGenerator.Cli", "RestClient.Net.McpGenerator.Cli\RestClient.Net.McpGenerator.Cli.csproj", "{DC7A5DC9-379E-47BB-9F6B-91B276218CC2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -253,6 +257,30 @@ Global {8FD2A6D3-C50D-42BC-A10F-DC9B35F5F2AC}.Release|x64.Build.0 = Release|Any CPU {8FD2A6D3-C50D-42BC-A10F-DC9B35F5F2AC}.Release|x86.ActiveCfg = Release|Any CPU {8FD2A6D3-C50D-42BC-A10F-DC9B35F5F2AC}.Release|x86.Build.0 = Release|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Debug|x64.ActiveCfg = Debug|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Debug|x64.Build.0 = Debug|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Debug|x86.ActiveCfg = Debug|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Debug|x86.Build.0 = Debug|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Release|Any CPU.Build.0 = Release|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Release|x64.ActiveCfg = Release|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Release|x64.Build.0 = Release|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Release|x86.ActiveCfg = Release|Any CPU + {54E7C113-63C4-4079-B355-D678A83BC58B}.Release|x86.Build.0 = Release|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Debug|x64.ActiveCfg = Debug|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Debug|x64.Build.0 = Debug|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Debug|x86.ActiveCfg = Debug|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Debug|x86.Build.0 = Debug|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Release|Any CPU.Build.0 = Release|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Release|x64.ActiveCfg = Release|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Release|x64.Build.0 = Release|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Release|x86.ActiveCfg = Release|Any CPU + {DC7A5DC9-379E-47BB-9F6B-91B276218CC2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Samples/NucliaDbClient/NucliaDbClient.csproj b/Samples/NucliaDbClient/NucliaDbClient.csproj index f2cf1634..bd7035fd 100644 --- a/Samples/NucliaDbClient/NucliaDbClient.csproj +++ b/Samples/NucliaDbClient/NucliaDbClient.csproj @@ -7,6 +7,7 @@ + From 568b72e2b70e31b9aeada21a29b969b3491e5cb7 Mon Sep 17 00:00:00 2001 From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com> Date: Mon, 20 Oct 2025 07:45:32 +1100 Subject: [PATCH 9/9] Update readme --- README.md | 175 ++++++++++++++++++++++-------------------------------- 1 file changed, 71 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index 5300e48b..a528991e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ **The safest way to make REST calls in C#** +**New!** Generate MCP servers from OpenAPI specs!!! + Built from the ground up with functional programming, type safety, and modern .NET patterns. Successor to the [original RestClient.Net](https://www.nuget.org/packages/RestClient.Net.Abstractions). ## What Makes It Different @@ -16,6 +18,7 @@ This library is uncompromising in its approach to type safety and functional des ## Features +- **Generate an MCP Server and client code** from an OpenAPI 3.x spec. - **Result Types** - Returns `Result>` with closed hierarchy types for compile-time safety (Outcome package) - **Zero Exceptions** - No exception throwing for predictable error handling - **Progress Reporting** - Built-in download/upload progress tracking @@ -108,6 +111,74 @@ global using ExceptionErrorPost = Outcome.HttpError.ExceptionErro If you use the OpenAPI generator, it will generate these type aliases for you automatically. +## OpenAPI Client and MCP Code Generation + +Generate type-safe C# clients and MCP servers from OpenAPI specs. + +### Client Generation + +```bash +dotnet add package RestClient.Net.OpenApiGenerator +``` + +Generate extension methods from OpenAPI 3.x specs: + +```csharp +// Generated code usage +using YourApi.Generated; + +var httpClient = factory.CreateClient(); + +// All HTTP methods supported with Result types +var user = await httpClient.GetUserById("123", ct); +var created = await httpClient.CreateUser(newUser, ct); +var updated = await httpClient.UpdateUser((Params: "123", Body: user), ct); +var deleted = await httpClient.DeleteUser("123", ct); + +// Pattern match on results +switch (user) +{ + case OkUser(var success): + Console.WriteLine($"User: {success.Name}"); + break; + case ErrorUser(var error): + Console.WriteLine($"Error: {error.StatusCode}"); + break; +} +``` + +The generator creates extension methods on `HttpClient`, model classes from schemas, and result type aliases for pattern matching. + +### MCP Server Generation + +Generate Model Context Protocol servers for Claude Code from OpenAPI specs: + +```bash +# Generate API client first +dotnet run --project RestClient.Net.OpenApiGenerator.Cli -- \ + -u api.yaml \ + -o Generated \ + -n YourApi.Generated + +# Generate MCP tools from the same spec +dotnet run --project RestClient.Net.McpGenerator.Cli -- \ + --openapi-url api.yaml \ + --output-file Generated/McpTools.g.cs \ + --namespace YourApi.Mcp \ + --server-name YourApi \ + --ext-namespace YourApi.Generated \ + --tags "Search,Resources" +``` + +The MCP generator wraps the generated extension methods as MCP tools that Claude Code can invoke. + +**Complete example:** See `Samples/NucliaDbClient.McpServer` for a working MCP server built from the NucliaDB OpenAPI spec. The example includes: +- Generated client code (`Samples/NucliaDbClient/Generated`) +- Generated MCP tools (`NucliaDbMcpTools.g.cs`) +- MCP server host project (`NucliaDbClient.McpServer`) +- Docker Compose setup for NucliaDB +- Claude Code integration script (`run-for-claude.sh`) + ## Exhaustiveness Checking with Exhaustion **Exhaustion is integral to RestClient.Net's safety guarantees.** It's a Roslyn analyzer that ensures you handle every possible case when pattern matching on Result types. @@ -155,110 +226,6 @@ Exhaustion works by analyzing sealed type hierarchies in switch expressions and If you don't handle all three, your code won't compile. -### OpenAPI Code Generation - -Generate type-safe extension methods from OpenAPI specs: - -```csharp -using JSONPlaceholder.Generated; - -// Get HttpClient from factory -var httpClient = factory.CreateClient(); - -// GET all todos -var todos = await httpClient.GetTodos(ct); - -// GET todo by ID -var todo = await httpClient.GetTodoById(1, ct); -switch (todo) -{ - case OkTodo(var success): - Console.WriteLine($"Todo: {success.Title}"); - break; - case ErrorTodo(var error): - Console.WriteLine($"Error: {error.StatusCode} - {error.Body}"); - break; -} - -// POST - create a new todo -var newTodo = new TodoInput { Title = "New Task", UserId = 1, Completed = false }; -var created = await httpClient.CreateTodo(newTodo, ct); - -// PUT - update with path param and body -var updated = await httpClient.UpdateTodo((Params: 1, Body: newTodo), ct); - -// DELETE - returns Unit -var deleted = await httpClient.DeleteTodo(1, ct); -``` - -```bash -dotnet add package RestClient.Net.OpenApiGenerator -``` - -Define your schema (OpenAPI 3.x): -```yaml -openapi: 3.0.0 -paths: - /users/{id}: - get: - operationId: getUserById - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/User' - /users: - post: - operationId: createUser - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/User' - responses: - '201': - content: - application/json: - schema: - $ref: '#/components/schemas/User' -``` - -The generator creates: -1. **Extension methods** - Strongly-typed methods on `HttpClient` -2. **Model classes** - DTOs from schema definitions -3. **Result type aliases** - Convenient `OkUser` and `ErrorUser` types - -Generated usage: -```csharp -// Get HttpClient from factory -var httpClient = factory.CreateClient(); - -// GET with path parameter -var user = await httpClient.GetUserById("123", ct); - -// POST with body -var created = await httpClient.CreateUser(newUser, ct); - -// PUT with path param and body -var updated = await httpClient.UpdateUser((Params: "123", Body: user), ct); - -// DELETE returns Unit -var deleted = await httpClient.DeleteUser("123", ct); -``` - -All generated methods: -- Create extension methods on `HttpClient` (use with `IHttpClientFactory.CreateClient()`) -- Return `Result>` for functional error handling -- Bundle URL/body/headers into `HttpRequestParts` via `buildRequest` -- Support progress reporting through `ProgressReportingHttpContent` - ### Progress Reporting You can track upload progress with `ProgressReportingHttpContent`. This example writes to the console when there is a progress report.