cMCP 0.4.1
Model Context Protocol library in pure C11
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
cmcp.h File Reference

Umbrella header: package + protocol version macros, library- wide error codes, and cmcp_errstr. More...

Go to the source code of this file.

Macros

#define CMCP_VERSION   "0.10.0"
 Package version of this cMCP build (e.g.
 
#define CMCP_PROTOCOL_VERSION   "2025-11-25"
 MCP wire-protocol revision this cMCP build speaks (e.g.
 

Enumerations

enum  cmcp_err_t {
  CMCP_OK = 0 , CMCP_EINVAL = -1 , CMCP_ENOMEM = -2 , CMCP_EIO = -3 ,
  CMCP_EPARSE = -4 , CMCP_ETRANSPORT = -5 , CMCP_EPROTOCOL = -6 , CMCP_ETIMEOUT = -7 ,
  CMCP_ECANCELLED = -8 , CMCP_EUNSUPPORTED = -9 , CMCP_ESCHEMA = -10 , CMCP_ENOTFOUND = -11 ,
  CMCP_EHANDLER = -12 , CMCP_EAGAIN = -13
}
 Library-wide error codes. More...
 

Functions

const char * cmcp_errstr (int err)
 Return a human-readable label for a cmcp_err_t value.
 

Detailed Description

Umbrella header: package + protocol version macros, library- wide error codes, and cmcp_errstr.

Every cMCP source file should include this header. The error codes declared here are returned by every public function whose return type is int (or cmcp_err_t) — negative values are errors, zero is success. See docs/SEMVER.md for the policy that governs additions and removals in this enum.

Definition in file cmcp.h.

Macro Definition Documentation

◆ CMCP_VERSION

#define CMCP_VERSION   "0.10.0"

Package version of this cMCP build (e.g.

"0.8.0"). Independent of CMCP_PROTOCOL_VERSION — see docs/SEMVER.md.

Definition at line 17 of file cmcp.h.

◆ CMCP_PROTOCOL_VERSION

#define CMCP_PROTOCOL_VERSION   "2025-11-25"

MCP wire-protocol revision this cMCP build speaks (e.g.

"2025-11-25"). Pinned per release; the handshake captures whatever the peer advertises and the host decides whether to continue.

Definition at line 22 of file cmcp.h.

Enumeration Type Documentation

◆ cmcp_err_t

enum cmcp_err_t

Library-wide error codes.

Negative on failure, zero on success.

Every public cMCP function returning int returns one of these (negative) on failure. Additions go at the end of the enum (so existing numeric encodings stay stable across MINOR bumps); see docs/SEMVER.md for the policy.

Enumerator
CMCP_OK 

Success.

CMCP_EINVAL 

Invalid argument from caller.

CMCP_ENOMEM 

Allocation failure.

CMCP_EIO 

I/O error on transport.

CMCP_EPARSE 

Malformed input (JSON or HTTP).

CMCP_ETRANSPORT 

Transport-layer failure.

CMCP_EPROTOCOL 

Peer violated the MCP spec.

CMCP_ETIMEOUT 

Operation timed out.

CMCP_ECANCELLED 

Operation cancelled (peer or host).

CMCP_EUNSUPPORTED 

Requested feature not implemented.

CMCP_ESCHEMA 

Tool input failed schema validation.

CMCP_ENOTFOUND 

Named primitive (tool/resource/prompt) not registered.

CMCP_EHANDLER 

Handler returned a non-success result.

CMCP_EAGAIN 

Capacity/rate cap reached; retry later.

Definition at line 32 of file cmcp.h.

Function Documentation

◆ cmcp_errstr()

const char * cmcp_errstr ( int  err)

Return a human-readable label for a cmcp_err_t value.

Unknown values map to "unknown". Returned pointer is to a static string — never NULL, never needs freeing.

Parameters
errA value of cmcp_err_t (or an int carrying one).
Returns
Borrowed static string.