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();
}
}
```