scorpiox-bot-plugin-fetch
←sxmcp.hc
35 lines · 1 KBHEADBlameDownload
1/*
2 * sxmcp.h - the MCP stdio server loop, implemented in plugin_fetch.c.
3 */
4#ifndef SX_FETCH_MCP_H
5#define SX_FETCH_MCP_H
6
7#include "yyjson.h"
8#include "sxbuf.h"
9
10/* MCP JSON-RPC 2.0 loop over stdin/stdout. Returns exit code. */
11int run_mcp(void);
12
13/* Tool implementation shared by --mcp and the CGI API.
14 * Fills `out` with model-facing text formatted like the upstream fetch
15 * server's tool result. Returns with out->ok set. */
16typedef struct {
17 int ok;
18 char error[1200];
19 char *text; /* heap */
20 size_t text_len;
21 int status;
22 char content_type[128];
23 size_t bytes_read;
24 size_t content_len; /* length of the converted content before chunking */
25 char final_url[1024];
26 char title[256];
27 int redirected;
28 char *raw_html; /* heap: original body, capped, for the UI Raw tab */
29} tool_result;
30
31void fetch_tool_run(const char *url, long max_length, long start_index, int raw,
32 tool_result *out);
33void tool_result_free(tool_result *r);
34
35#endif /* SX_FETCH_MCP_H */