Skip to content
pi-c Artifact [8b8a4fd067]
Login

Artifact [8b8a4fd067]

Artifact 8b8a4fd0675fb7bd8ddb4b7bf2a31a4310a86db98aa71c725674a467d5247ed2:


/* The MCP client (mcp.c over mcp_wire.c): servers the person added with pic mcp add, kept as rows
 * of picu_mcp_server in ~/.pic/pic.sqlite, their header and environment values sealed under the
 * credential store's key (bound to the server's name and origin) and never kept or shown in
 * plain text. Each enabled server's tools, as its last tools/list gave them, are registered with
 * the tool registry as mcp__SERVER__TOOL, so building a request needs no connection; a call
 * connects, asks tools/call and returns the result, journaled like any tool's. A tool the server
 * marks readOnlyHint is replay-safe; every other one becomes "outcome unknown" after a crash.
 * pic does not sign in to servers (OAuth): a token is given as a header. */
#ifndef PIC_MCP_H
#define PIC_MCP_H

#include "rpc.h"

/* Registers the tools of every enabled server from their saved lists, with the tool registry: the
 * user's, and a trusted WORKSPACE's own (.mcp.json, then .pic/mcp.json; NULL: none), which replace
 * the user's of the same name. The number registered, or -1 when ~/.pic/pic.sqlite cannot be read. */
int pic_mcp_register(const char *workspace);

/* pic mcp add | add-json | list | get | remove | call in WORKSPACE (NULL: the current directory):
 * the process's exit status. */
int pic_mcp_command(int argc, char **argv, const char *workspace);

/* The RPC commands: get_mcp_servers, add_mcp_server, remove_mcp_server, refresh_mcp_servers,
 * set_mcp_server_enabled. */
extern const pic_rpc_command pic_get_mcp_servers_rpc, pic_add_mcp_server_rpc, pic_remove_mcp_server_rpc,
    pic_refresh_mcp_servers_rpc, pic_set_mcp_server_enabled_rpc;

#endif