Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
```csharp title="client.cs"
using System;
using System.Diagnostics;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
var client = new McpClient();
await client.StartAsync();
var content = await client.ExtractFileAsync("document.pdf");
Console.WriteLine(content);
client.Stop();
class McpClient
{
private Process _mcpProcess;
private StreamReader _reader;
private StreamWriter _writer;
public async Task StartAsync()
{
var processInfo = new ProcessStartInfo
{
FileName = "kreuzberg",
Arguments = "mcp",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
_mcpProcess = Process.Start(processInfo);
_reader = _mcpProcess.StandardOutput;
_writer = _mcpProcess.StandardInput;
}
public async Task<string> ExtractFileAsync(string path)
{
var request = new
{
method = "tools/call",
@params = new
{
name = "extract_file",
arguments = new { path, @async = true }
}
};
var jsonRequest = JsonSerializer.Serialize(request);
await _writer.WriteLineAsync(jsonRequest);
await _writer.FlushAsync();
var response = await _reader.ReadLineAsync();
var json = JsonDocument.Parse(response);
return json.RootElement.GetProperty("result").GetProperty("content").GetString();
}
public void Stop()
{
_writer?.Dispose();
_reader?.Dispose();
_mcpProcess?.Kill();
}
}
```

View File

@@ -0,0 +1,38 @@
<!-- snippet:syntax-only -->
```csharp title="C#"
using System.Diagnostics;
using System.Text.Json;
var processInfo = new ProcessStartInfo
{
FileName = "kreuzberg",
Arguments = "mcp",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
using var process = Process.Start(processInfo)
?? throw new InvalidOperationException("Failed to start kreuzberg mcp");
var request = new
{
method = "tools/call",
@params = new
{
name = "extract_file",
arguments = new { path = "document.pdf" },
},
};
await process.StandardInput.WriteLineAsync(JsonSerializer.Serialize(request));
await process.StandardInput.FlushAsync();
var line = await process.StandardOutput.ReadLineAsync();
Console.WriteLine(line);
process.StandardInput.Close();
await process.WaitForExitAsync();
```

View File

@@ -0,0 +1,20 @@
<!-- snippet:syntax-only -->
```csharp title="C#"
using System.Diagnostics;
var processInfo = new ProcessStartInfo
{
FileName = "kreuzberg",
Arguments = "mcp",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
using var server = Process.Start(processInfo)
?? throw new InvalidOperationException("Failed to start kreuzberg mcp");
await server.WaitForExitAsync();
```

View File

@@ -0,0 +1,50 @@
```csharp title="server.cs"
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
class McpServer
{
public static async Task Main(string[] args)
{
var processInfo = new ProcessStartInfo
{
FileName = "kreuzberg",
Arguments = "mcp",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
var process = Process.Start(processInfo);
await Task.Delay(Timeout.Infinite);
}
}
class McpServerProgram
{
public static async Task Main()
{
var server = new KreuzbergMcpServer();
server.RegisterTool("extract_file", new Dictionary<string, object>
{
{ "description", "Extract text from a document file" },
{ "parameters", new { path = "string" } }
});
server.RegisterTool("extract_bytes", new Dictionary<string, object>
{
{ "description", "Extract text from document bytes" },
{ "parameters", new { data = "string", mimeType = "string" } }
});
await server.StartAsync();
}
}
```