Files
fil/docs/snippets/csharp/mcp/server.cs
Henrik Jess Nielsen b4c07d3693
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s
Nomad changes
2026-06-01 23:40:55 +02:00

51 lines
1.3 KiB
C#

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