Files
fil/docs/snippets/c/mcp/mcp_server_start.md
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

863 B

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

/* The kreuzberg C FFI does not embed the MCP server. Spawn the kreuzberg
 * CLI from a host process that uses libkreuzberg for in-process extraction. */
int main(void) {
    pid_t pid = fork();
    if (pid < 0) {
        perror("fork");
        return 1;
    }
    if (pid == 0) {
        execlp("kreuzberg", "kreuzberg", "mcp", (char *)NULL);
        perror("execlp");
        _exit(127);
    }

    int status = 0;
    if (waitpid(pid, &status, 0) < 0) {
        perror("waitpid");
        return 1;
    }
    return WIFEXITED(status) ? WEXITSTATUS(status) : 1;
}
The MCP server is exposed only through the kreuzberg CLI; libkreuzberg's C FFI offers no MCP entry point. This snippet spawns the CLI from a host that already links against libkreuzberg.