/* * sxmcp.h - the MCP stdio server loop, implemented in plugin_fetch.c. */ #ifndef SX_FETCH_MCP_H #define SX_FETCH_MCP_H #include "yyjson.h" #include "sxbuf.h" /* MCP JSON-RPC 2.0 loop over stdin/stdout. Returns exit code. */ int run_mcp(void); /* Tool implementation shared by --mcp and the CGI API. * Fills `out` with model-facing text formatted like the upstream fetch * server's tool result. Returns with out->ok set. */ typedef struct { int ok; char error[1200]; char *text; /* heap */ size_t text_len; int status; char content_type[128]; size_t bytes_read; size_t content_len; /* length of the converted content before chunking */ char final_url[1024]; char title[256]; int redirected; char *raw_html; /* heap: original body, capped, for the UI Raw tab */ } tool_result; void fetch_tool_run(const char *url, long max_length, long start_index, int raw, tool_result *out); void tool_result_free(tool_result *r); #endif /* SX_FETCH_MCP_H */