cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
client.hpp File Reference

Core client compatibility API and transport interface for MCP clients. More...

#include <atomic>
#include <chrono>
#include <condition_variable>
#include <cstdint>
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <vector>
#include "cxxmcp/core/result.hpp"
#include "cxxmcp/protocol/capabilities.hpp"
#include "cxxmcp/protocol/completion.hpp"
#include "cxxmcp/protocol/elicitation.hpp"
#include "cxxmcp/protocol/logging.hpp"
#include "cxxmcp/protocol/prompt.hpp"
#include "cxxmcp/protocol/resource.hpp"
#include "cxxmcp/protocol/roots.hpp"
#include "cxxmcp/protocol/sampling.hpp"
#include "cxxmcp/protocol/serialization.hpp"
#include "cxxmcp/protocol/tool.hpp"
#include "cxxmcp/protocol/types.hpp"
#include "cxxmcp/request.hpp"
#include "cxxmcp/client/handler.hpp"

Go to the source code of this file.

Classes

struct  mcp::client::ClientOptions
 Basic options for endpoint-oriented client construction. More...
 
class  mcp::client::Transport
 Abstract client transport used by Client to exchange JSON-RPC messages. More...
 
class  mcp::client::Client
 High-level MCP client compatibility API. More...
 
struct  mcp::client::Client::StdioEndpoint
 Endpoint options for launching a child process over stdio. More...
 

Typedefs

using mcp::client::HttpAuthRefreshHandler = std::function< std::optional< std::string >(const HttpAuthChallenge &)>
 
using mcp::client::TransportRequestHandler = std::function< core::Result< protocol::JsonRpcResponse >(const protocol::JsonRpcRequest &)>
 Handles JSON-RPC requests sent by the server to this client.
 
using mcp::client::TransportNotificationHandler = std::function< core::Result< core::Unit >(const protocol::JsonRpcNotification &)>
 Handles JSON-RPC notifications sent by the server to this client.
 

Detailed Description

Core client compatibility API and transport interface for MCP clients.

The client API is synchronous at the call site: methods return core::Result<T> with either a protocol value or an error. Inbound requests and notifications are delivered through registered callbacks, which may be invoked by the transport thread that received the message.

Typedef Documentation

◆ TransportNotificationHandler

using mcp::client::TransportNotificationHandler = typedef std::function<core::Result<core::Unit>( const protocol::JsonRpcNotification&)>

Handles JSON-RPC notifications sent by the server to this client.

Parameters
notificationIncoming JSON-RPC notification.
Returns
Unit on success, or an error describing why the notification could not be handled.

◆ TransportRequestHandler

using mcp::client::TransportRequestHandler = typedef std::function<core::Result<protocol::JsonRpcResponse>( const protocol::JsonRpcRequest&)>

Handles JSON-RPC requests sent by the server to this client.

Parameters
requestIncoming JSON-RPC request.
Returns
A JSON-RPC response or an error converted to a JSON-RPC error response.