MCP SDK Design

Finding the SDK

If you have installed the MBASE SDK, you can find the library using CMake find_package function with components specification.

In order to find the library using cmake, write the following:

find_package(mbase.libs REQUIRED COMPONENTS mcp)

Specify the include path and link the libraries:

target_include_directories(<your_target> PUBLIC mbase-mcp)
target_link_libraries(<your_target> PRIVATE mbase-mcp)

File Hierarchy

All header files are prefixed with mbase/mcp in the MCP SDK. Below are the MCP SDK headers:

Note

All headers include mcp_common.h by default.

File

Remarks

Used By

Includes

mcp_client_arguments.h

Contains the STDIO and HTTP init object which are used to initialize the respective clients.It also contains the feature argument typedefs for calling features with arguments.

Client

mcp_client_base.h

Contains the fundamental McpClientBase class. Client can extend the MCP client functionality by inheriting from this class. See: MCP Client Features in Detail.

Client

mcp_notifications.h, mcp_server_to_client_requests.h

mcp_client_callbacks.h

Client feature callback signatures are defined in this file.

Client

mcp_server_responses.h, mcp_server_descriptions.h

mcp_client_server_http.h

Contains the McpClientServerHttp class which is used to establish HTTP connection with the MCP server.

Client

mcp_client_server_state.h

mcp_client_server_stdio.h

Contains the McpClientServerStdio class which is used to create a MCP server subprocess and communicate it through STDIO.

Client

mcp_client_server_state.h

mcp_common.h

Contains error code macros, includes frequently used data structures such as unordered_map, vector etc.

Client/Server

mcp_notifications.h

Defines notification objects

Client/Server

mcp_packet_parsing.h

MCP parsing procedures. They can be used to build and parse an MCP packet.

Client/Server

mcp_server_arguments.h

Defines McpPromptArgument, McpToolArgument objects which are used to describe a feature containing arguments.

Server

mcp_server_base.h

Contains the fundamental McpServerBase class. Use shouldn’t extend directly from the base but should instead either from McpServerStdio, McpServerHttpStreamableStateful or McpServerHttpStreamableStateless. See: MCP Server Features in Detail

Server

mcp_server_features.h, mcp_server_client_state.h

mcp_server_client_http_streamable.h

Defines the McpServerClientHttpStreamable which is created for each HTTP client connection to the server. The creation and management of this class is being handled by either the McpServerHttpStreamableStateful or McpServerHttpStreamableStateles

Server

mcp_server_client_state.h

mcp_server_client_state.h

Defines the McpServerClient object which holds the state information about the current client connection. Since, this is managed by the server, user don’t have anything to do with this class.

Server

mcp_notifications.h, mcp_server_to_client_requests.h

mcp_server_client_stdio.h

Defines the McpServerStdioClient object which extends the McpServerClient objects. This is used to manage the STDIO transport layer with the client. User don’t have anything to do with this class.

Server

mcp_server_client_state.h

mcp_server_descriptions.h

Contains the description objects such as McpResourceDescription, McpPromptDescription and McpToolDescription which are used the describe and register a feature on the server.

Client/Server

mcp_server_arguments.h

mcp_server_features.h

Contains the feature objects and feature callback signatures.

Server

mcp_server_descriptions.h, mcp_server_responses.h

mcp_server_http_streamable.h

Contains both the McpServerHttpStreamableStateful and McpServerHttpStreamableStateless objects which are used to initialize an MCP HTTP server.

Server

mcp_server_base.h, mcp_server_client_http_streamable.h

mcp_server_responses.h

Defines the feature response objects and expose them as variant object such as McpResponseResource, McpResponsePrompt and McpResponseTool. This header is used to send and read responses.

Client/Server

mcp_server_stdio.h

Contains the McpServerStdio object which is used to initialize an MCP STDIO server.

Server

mcp_server_base.h, mcp_server_client_stdio.h

mcp_server_to_client_requests.h

Defines callbacks signatures and request objects for server to client roots/sampling requests. The objects defined under this file is used by both client and the server.

Client/Server

Object Hierarchy

Alternative text

Error Codes

Given error codes are declared under the mcp_common.h file:

Macro

Code

MBASE_MCP_SUCCESS

0

MBASE_MCP_PARSE_ERROR

-32700

MBASE_MCP_INVALID_REQUEST

-32600

MBASE_MCP_METHOD_NOT_FOUND

-32601

MBASE_MCP_INVALID_PARAMS

-32602

MBASE_MCP_INTERNAL_ERROR

-32603

MBASE_MCP_TIMEOUT

-32001

MBASE_MCP_RESOURCE_NOT_FOUND

-32002

Macros

Given macros are declared under the mcp_common.h file:

Macro

Value

Description

MBASE_MCP_TIMEOUT_DEFAULT

10

Default request timeout in seconds. Applies to both client and server.

MBASE_MCP_STDIO_BUFFER_LENGTH

65536

Default STDIO read/write buffer length. Applies to both client and server.