CMSIS-MCP  Version 0.0.0
Embedded MCP server with serial transport
 
Loading...
Searching...
No Matches
Memory and index diagnostics

Read counters without allocating memory. More...

Functions

size_t mcp_resource_index_height (void)
 Read the height of the resource-URI lookup index for diagnostics.
 
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.
 
size_t mcp_tool_index_height (void)
 Read the height of the tool-name lookup index for diagnostics.
 
size_t mcp_arena_used (void)
 Read current arena consumption, including alignment padding.
 
size_t mcp_arena_high_water (void)
 Read the arena's recorded high-water mark.
 
size_t mcp_heap_allocations (void)
 Count allocation attempts through the installed cJSON heap allocator.
 

Description

Read counters without allocating memory.

Function Documentation

◆ mcp_arena_high_water()

size_t mcp_arena_high_water ( void )
extern

Read the arena's recorded high-water mark.

Returns
Peak recorded bytes for parsing, callback storage and serialized output. Exhaustion may record the whole configured capacity.

Persists across requests and free_tools(); no reset API.

Example
size_t peak = mcp_arena_high_water();
size_t mcp_arena_high_water(void)
Read the arena's recorded high-water mark.

◆ mcp_arena_used()

size_t mcp_arena_used ( void )
extern

Read current arena consumption, including alignment padding.

Returns
Bytes in use; zero after dispatch returns.
Example
size_t used = mcp_arena_used(); // Inspect inside a callback or sender.
size_t mcp_arena_used(void)
Read current arena consumption, including alignment padding.

◆ mcp_heap_allocations()

size_t mcp_heap_allocations ( void )
extern

Count allocation attempts through the installed cJSON heap allocator.

Returns
Cumulative cJSON heap-allocation attempts outside dispatch.

Not a byte count or a count of every allocation. Direct malloc calls for registry nodes are not included; failed cJSON allocations are counted. Requests should not increase this counter after mcp_prepare() succeeds.

Example
size_t before = mcp_heap_allocations(); // After successful mcp_prepare().
dispatch("{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"ping\"}", 0);
size_t after = mcp_heap_allocations(); // Expected to equal before.
size_t mcp_heap_allocations(void)
Count allocation attempts through the installed cJSON heap allocator.
void dispatch(const char *line, int fd)
Dispatch one JSON-RPC message through the default transport hook.

◆ mcp_resource_index_height()

size_t mcp_resource_index_height ( void )
extern

Read the height of the resource-URI lookup index for diagnostics.

Returns
Node levels; zero when empty or VFS is disabled.
Example
size_t height = mcp_resource_index_height();
size_t mcp_resource_index_height(void)
Read the height of the resource-URI lookup index for diagnostics.

◆ mcp_resource_lookup_steps()

size_t mcp_resource_lookup_steps ( void )
extern

Read the comparison count of the latest resources/read lookup.

Returns
Comparisons; zero before a read, after free_tools() or with VFS disabled.
Example
size_t comparisons = mcp_resource_lookup_steps(); // After a resource request.
size_t mcp_resource_lookup_steps(void)
Read the comparison count of the latest resources/read lookup.

◆ mcp_tool_index_height()

size_t mcp_tool_index_height ( void )
extern

Read the height of the tool-name lookup index for diagnostics.

Returns
Node levels; zero when empty, one for a single tool.
Example
size_t height = mcp_tool_index_height();
size_t mcp_tool_index_height(void)
Read the height of the tool-name lookup index for diagnostics.

◆ mcp_tool_lookup_steps()

size_t mcp_tool_lookup_steps ( void )
extern

Read the comparison count of the latest tool-name lookup.

Returns
Number of string comparisons; zero for a NULL lookup or empty index.

Registration and tools/call also perform lookups and can update it.

Example
struct tool *tool = find_tool("setIndicator");
size_t comparisons = mcp_tool_lookup_steps();
size_t mcp_tool_lookup_steps(void)
Read the comparison count of the latest tool-name lookup.
struct tool * find_tool(const char *name)
Look up a registered tool by exact, case-sensitive name.