Improve MCP validation efficiency and annotate public APIs with nodiscard
Ready to merge
HA
13h ago+223+223+012345678901234567890123456789-262-262-012345678901234567890123456789
Summary
Combines MCP validation performance and API safety improvements:
- Validation Efficiency & Reduced Allocations:
- Replaced the ad-hoc strings() array-checking loop in src/core/mcp/validation.h with native member function is_array_of_strings() across udience, sizes, stopSequences, and task environment object values.
- Eliminated redundant string copies on dispatch (const auto &name{...to_string()}) in sampling_block(), sampling_message_block(), alid_content(), and alid_input_requests().
- Reused bound string references across nnotations() and icons() loops.
- Retained exact JSON number comparisons for annotation priority bounds (*priority < JSON{0} || *priority > JSON{1}) to preserve Decimal precision without rounding or overflow.
- Annotate Public MCP Functions with [[nodiscard]]:
- Added [[nodiscard]] to all public query, validation, parsing, and factory functions across mcp_protocol.h, mcp_headers.h, mcp_results.h, mcp_capabilities.h, mcp_error.h, and mcp_logging.h to prevent callers from silently ignoring validation results or responses (excluding void-returning mcp_write_result).
- Updated est/mcp/mcp_helpers.h (EXPECT_MCP_REJECTS) and est/mcp/mcp_error_test.cc to cast discarded expressions to oid for -Werror=unused-result compliance.
Testing
- Full MSYS2 UCRT64 GCC 14.2 & Ninja build cleanly passing.
- 100% pass on all test suites:
- core.mcp: all 1,409 tests passed, 0 failed.
- core.json: passed.
- core.jsonrpc: passed.
- Code formatted with repository's clang-format configuration.