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 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. diff --git a/RestClient.Net.McpGenerator.Cli/Program.cs b/RestClient.Net.McpGenerator.Cli/Program.cs index 87d3e29b..7c2cc820 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,29 @@ 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 +211,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..022a6772 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, @@ -61,11 +78,13 @@ string extensionsNamespace 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() { @@ -208,13 +227,17 @@ 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/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.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/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..f102ca29 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", +// Configure default HttpClient with base URL +builder.Services.AddHttpClient( + string.Empty, client => { client.BaseAddress = new Uri(nucleaBaseUrl); @@ -18,14 +26,8 @@ } ); -// Add the NucliaDB tools to DI -services.AddSingleton(); - -var serviceProvider = services.BuildServiceProvider(); - -// 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/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 a0a85194..e11aee25 100755 --- a/Samples/NucliaDbClient.McpServer/run-for-claude.sh +++ b/Samples/NucliaDbClient.McpServer/run-for-claude.sh @@ -1,13 +1,70 @@ #!/bin/bash -# Run script for Claude MCP integration -# This script is called by Claude to start the MCP server +# 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 -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +set -e -# Set environment variable for NucliaDB URL -export NUCLIA_BASE_URL="http://localhost:8080/api/v1" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_PATH="$SCRIPT_DIR/NucliaDbClient.McpServer.csproj" +DOCKER_DIR="$SCRIPT_DIR/../NucliaDbClient" +DOTNET_PATH=$(which dotnet) -# Run the MCP server +echo "NucliaDB MCP Server Setup" +echo "=========================" +echo "" + +# 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 "Building MCP server..." cd "$SCRIPT_DIR" -exec dotnet run --no-build +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 "✓ Setup complete!" +echo "" +echo "Verify with: claude mcp list" +echo "The server should appear as 'nucliadb-mcp' with a ✓ status" +echo "" +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 "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/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/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.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 d7750ad3..8bafd7fa 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() { @@ -17,10 +19,10 @@ 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`")] - public async Task KbBySlugKbSSlugGet(string 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 httpClient = httpClientFactory.CreateClient(); var result = await httpClient.KbBySlugKbSSlugGetAsync(slug, CancellationToken.None); return result switch @@ -42,10 +44,10 @@ public async Task KbBySlugKbSSlugGet(string slug) /// --- ## 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") + /// 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 httpClient = httpClientFactory.CreateClient(); var result = await httpClient.KbKbKbidGetAsync(kbid, xNUCLIADBROLES, CancellationToken.None); return result switch @@ -72,10 +74,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 +114,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 +139,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,37 +161,13 @@ 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`")] - 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`")] - public async Task ConfigurationKbKbidConfigurationPatch(string kbid, object 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 httpClient = httpClientFactory.CreateClient(); var result = await httpClient.ConfigurationKbKbidConfigurationPatchAsync(kbid, body, CancellationToken.None); return result switch @@ -211,10 +189,10 @@ public async Task ConfigurationKbKbidConfigurationPatch(string kbid, obj /// 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) + /// 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 httpClient = httpClientFactory.CreateClient(); var result = await httpClient.SetConfigurationKbKbidConfigurationAsync(kbid, body, CancellationToken.None); return result switch @@ -237,10 +215,10 @@ public async Task SetConfigurationKbKbidConfiguration(string kbid, objec /// 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") + /// 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 httpClient = httpClientFactory.CreateClient(); var result = await httpClient.KnowledgeboxCountersKbKbidCountersAsync(kbid, debug, xNUCLIADBROLES, CancellationToken.None); return result switch @@ -259,20 +237,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`")] - public async Task SetCustomSynonymsKbKbidCustomSynonyms(string kbid, KnowledgeBoxSynonyms 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 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)}", @@ -284,19 +262,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`")] - public async Task CustomSynonymsKbKbidCustomSynonymsDelete(string 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 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)}", @@ -308,19 +287,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`")] - public async Task CustomSynonymsKbKbidCustomSynonymsGet(string 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 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)}", @@ -332,15 +312,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`")] - public async Task UpdateEntitiesGroupKbKbidEntitiesgroupGroup(string kbid, string group, UpdateEntitiesGroupPayload body) + /// 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.UpdateEntitiesGroupKbKbidEntitiesgroupGroupAsync(kbid, group, body, CancellationToken.None); + var result = await httpClient.SendFeedbackEndpointKbKbidFeedbackAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); return result switch { @@ -358,20 +340,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`")] - 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 + /// 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.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)}", @@ -383,20 +394,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`")] - public async Task EntityKbKbidEntitiesgroupGroupGet(string kbid, string group) + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor + /// Request body + /// 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.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)}", @@ -408,20 +422,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`")] - public async Task CreateEntitiesGroupKbKbidEntitiesgroups(string kbid, CreateEntitiesGroupPayload body) + /// 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.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)}", @@ -433,20 +450,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`")] - public async Task EntitiesKbKbidEntitiesgroupsGet(string kbid, bool showEntities = false) + /// xNdbClient + /// xNucliadbUser + /// xForwardedFor + /// Request body + /// 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.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)}", @@ -458,20 +478,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`")] - public async Task StartKbExportEndpointKbKbidExport(string kbid, object body) + /// 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.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)}", @@ -483,20 +506,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`")] - public async Task DownloadExportKbEndpointKbKbidExportExportId(string kbid, string exportId) + /// 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 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)}", @@ -510,12 +533,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 - [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) + /// 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 httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.ExportStatusEndpointKbKbidExportExportIdStatusGetAsync(kbid, exportId, CancellationToken.None); + var result = await httpClient.ImportStatusEndpointKbKbidImportImportIdStatusGetAsync(kbid, importId, CancellationToken.None); return result switch { @@ -533,38 +556,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`")] - 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`")] - public async Task ExtractStrategiesKbKbidExtractStrategiesGet(string kbid) + /// 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.ExtractStrategiesKbKbidExtractStrategiesGetAsync(kbid, CancellationToken.None); + var result = await httpClient.PredictProxyEndpointKbKbidPredictEndpointAsync(kbid, endpoint, body, xNucliadbUser ?? "", xNdbClient, xForwardedFor ?? "", CancellationToken.None); return result switch { @@ -582,20 +585,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`")] - public async Task StrategyKbKbidExtractStrategiesStrategyStrategyIdDelete(string kbid, string strategyId) + /// endpoint + /// xNucliadbUser + /// xNdbClient + /// xForwardedFor + /// 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.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)}", @@ -607,20 +613,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`")] - 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 + /// 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.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)}", @@ -632,23 +644,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`")] - public async Task SendFeedbackEndpointKbKbidFeedback(string kbid, FeedbackRequest body, string xNdbClient = "api", string? xNucliadbUser = null, string? xForwardedFor = null) + /// 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.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)}", @@ -660,12 +684,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 @@ -686,23 +714,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`")] - 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("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.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)}", @@ -714,23 +739,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`")] - public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindRequest 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.FindPostKnowledgeboxKbKbidFindAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); + var result = await httpClient.SearchPostKnowledgeboxKbKbidSearchAsync(kbid, body, 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,23 +767,26 @@ public async Task FindPostKnowledgeboxKbKbidFind(string kbid, FindReques }; } - /// 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` + /// 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 + /// slug + /// 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("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("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.GraphSearchKnowledgeboxKbKbidGraphAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); + var result = await httpClient.ResourceAskEndpointBySlugKbKbidSlugSlugAskAsync(kbid, slug, body, xShowConsumption, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", xSynchronous, CancellationToken.None); return result switch { - OkGraphSearchResponseHTTPValidationError(var success) => + OkSyncAskResponseHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorGraphSearchResponseHTTPValidationError(var httpError) => httpError switch + ErrorSyncAskResponseHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -770,23 +798,36 @@ public async Task GraphSearchKnowledgeboxKbKbidGraph(string kbid, GraphS }; } - /// 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` + /// 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 + /// 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 + /// 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. + /// Features enabled for the suggest endpoint. + /// Controls which types of metadata are serialized on resources of search results + /// Define which field types are serialized on resources of search results + /// 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 + /// If set to false (default), excludes hidden resources from search /// 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) + /// 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.GraphNodesSearchKnowledgeboxKbKbidGraphNodesAsync(kbid, body, xNdbClient, xNucliadbUser ?? "", xForwardedFor ?? "", CancellationToken.None); + 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 { - OkGraphNodesSearchResponseHTTPValidationError(var success) => + OkKnowledgeboxSuggestResultsHTTPValidationError(var success) => JsonSerializer.Serialize(success, JsonOptions), - ErrorGraphNodesSearchResponseHTTPValidationError(var httpError) => httpError switch + ErrorKnowledgeboxSuggestResultsHTTPValidationError(var httpError) => httpError switch { HttpError.ErrorResponseError err => $"Error {err.StatusCode}: {JsonSerializer.Serialize(err.Body, JsonOptions)}", @@ -798,2055 +839,14 @@ public async Task GraphNodesSearchKnowledgeboxKbKbidGraphNodes(string kb }; } - /// 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`")] - 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`")] - 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" - }; - } - - /// --- ## 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - public async Task DownloadExtractFileRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDownloadExtractedDownloadField(string kbid, string rslug, string fieldType, string fieldId, string downloadField) - { - var httpClient = httpClientFactory.CreateClient(); - var result = await httpClient.DownloadExtractFileRslugPrefixKbKbidSlugRslugFieldTypeFieldIdDownloadExtractedDownloadFieldAsync(kbid, rslug, 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" - }; - } - - /// 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 - /// slug - /// 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 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(); - var result = await httpClient.ResourceAskEndpointBySlugKbKbidSlugSlugAskAsync(kbid, slug, 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" - }; - } - - /// 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`")] - 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`")] - 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`")] - 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`")] - 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`")] - 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 - /// 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 - /// 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. - /// Features enabled for the suggest endpoint. - /// Controls which types of metadata are serialized on resources of search results - /// Define which field types are serialized on resources of search results - /// 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 - /// If set to false (default), excludes hidden resources from search - /// 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) - { - 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 - { - OkKnowledgeboxSuggestResultsHTTPValidationError(var success) => - JsonSerializer.Serialize(success, JsonOptions), - ErrorKnowledgeboxSuggestResultsHTTPValidationError(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" - }; - } - - /// 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` + /// 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` /// 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 @@ -2865,112 +865,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`")] - 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")] - 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`")] - 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`")] - 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. @@ -2980,10 +874,10 @@ public async Task UploadInformationKbKbidTusuploadUploadId(string 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("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) + /// 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 httpClient = httpClientFactory.CreateClient(); var result = await httpClient.UploadKbKbidUploadAsync(kbid, body, xFilename, xPassword, xLanguage, xMd5, xExtractStrategy, xSplitStrategy, CancellationToken.None); return result switch @@ -3005,10 +899,10 @@ public async Task UploadKbKbidUpload(string kbid, object body, object? x /// Create a new knowledge box /// xNUCLIADBROLES /// Request body - [Description("Create a new knowledge box")] - public async Task CreateKnowledgeBoxKbs(object body, string xNUCLIADBROLES = "MANAGER") + /// HttpClient instance + [McpServerTool, Description("Create a new knowledge box")] + public static async Task CreateKnowledgeBoxKbs(HttpClient httpClient, object body, string xNUCLIADBROLES = "MANAGER") { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.CreateKnowledgeBoxKbsAsync(body, xNUCLIADBROLES, CancellationToken.None); return result switch @@ -3029,10 +923,10 @@ 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")] - public async Task LearningConfigurationSchemaLearningConfigurationSchema() + /// HttpClient instance + [McpServerTool, Description("Get jsonschema definition for `learning_configuration` field of knowledgebox creation payload")] + public static async Task LearningConfigurationSchemaLearningConfigurationSchema(HttpClient httpClient) { - var httpClient = httpClientFactory.CreateClient(); var result = await httpClient.LearningConfigurationSchemaLearningConfigurationSchemaAsync(CancellationToken.None); return result switch diff --git a/Samples/NucliaDbClient/NucliaDbClient.csproj b/Samples/NucliaDbClient/NucliaDbClient.csproj index 3c25bac2..bd7035fd 100644 --- a/Samples/NucliaDbClient/NucliaDbClient.csproj +++ b/Samples/NucliaDbClient/NucliaDbClient.csproj @@ -7,6 +7,7 @@ + @@ -18,4 +19,7 @@ + + +