75#define MCP_PARSE_ERROR (-32700)
78#define MCP_INVALID_REQUEST (-32600)
81#define MCP_METHOD_NOT_FOUND (-32601)
84#define MCP_INVALID_PARAMS (-32602)
87#define MCP_INTERNAL_ERROR (-32603)
90#define MCP_RESOURCE_NOT_FOUND (-32002)
167extern struct mcp_resource *
add_resource(
const char *uri,
const char *name,
168 const char *description,
const char *mime_type,
mcp_resource_fn callback);
213typedef int (*
mcp_tool_fn)(
int argc,
const char **returnMessage,
const char **args);
437 const char *description);
514 const char *description);
size_t mcp_resource_index_height(void)
Read the height of the resource-URI lookup index for diagnostics.
size_t mcp_tool_index_height(void)
Read the height of the tool-name lookup index for diagnostics.
size_t mcp_heap_allocations(void)
Count allocation attempts through the installed cJSON heap allocator.
size_t mcp_arena_high_water(void)
Read the arena's recorded high-water mark.
size_t mcp_arena_used(void)
Read current arena consumption, including alignment padding.
size_t mcp_resource_lookup_steps(void)
Read the comparison count of the latest resources/read lookup.
size_t mcp_tool_lookup_steps(void)
Read the comparison count of the latest tool-name lookup.
void(* mcp_send_fn)(const char *json, int fd)
Synchronous transport callback used by dispatch_with_sender().
Definition mcp.h:385
void dispatch_with_sender(const char *line, int fd, mcp_send_fn send)
Dispatch one JSON-RPC message through an application-provided sender.
void dispatch(const char *line, int fd)
Dispatch one JSON-RPC message through the default transport hook.
void * mcp_arena_alloc(size_t size)
Allocate aligned storage from the current request arena.
void free_tools(void)
Release tool/resource registries and cached responses; reopen registration.
int mcp_prepare(void)
Finish startup by caching discovery schemas and response templates.
char * mcp_arena_strdup(const char *text)
Copy a null-terminated string into the current request arena.
struct mcp_resource * add_resource(const char *uri, const char *name, const char *description, const char *mime_type, mcp_resource_fn callback)
Register an exact virtual URI and its read callback during startup.
int(* mcp_resource_fn)(const char **returnMessage)
Callback invoked when resources/read resolves a registered URI.
Definition mcp.h:113
type
JSON type used in a required argument's discovery schema.
Definition mcp.h:66
@ TYPE_STR
JSON string; callback receives decoded text.
Definition mcp.h:67
@ TYPE_FLOAT
Finite JSON number; callback receives numeric text.
Definition mcp.h:69
@ TYPE_BOOL
JSON boolean; callback receives "true" or "false".
Definition mcp.h:70
@ TYPE_INT
Finite integral JSON number; callback receives numeric text.
Definition mcp.h:68