9#ifndef LLDB_PROTOCOL_MCP_CLIENT_H
10#define LLDB_PROTOCOL_MCP_CLIENT_H
14#include "llvm/ADT/FunctionExtras.h"
15#include "llvm/Support/Error.h"
29 Client(std::unique_ptr<MCPTransport> transport,
66 void Log(llvm::StringRef message);
static llvm::raw_ostream & error(Stream &strm)
llvm::unique_function< void()> m_disconnect_handler
LogCallback m_log_callback
Client & operator=(const Client &)=delete
llvm::unique_function< void(llvm::Error)> m_error_handler
void CancelPendingRequests(llvm::StringRef reason)
Fails every request still awaiting a response, invoking its reply with an error.
void Initialize(const InitializeParams ¶ms, Reply< InitializeResult > reply)
Outgoing MCP requests to the server.
void ResourcesRead(const ReadResourceParams ¶ms, Reply< ReadResourceResult > reply)
void Log(llvm::StringRef message)
void ToolsList(Reply< ListToolsResult > reply)
Client(std::unique_ptr< MCPTransport > transport, LogCallback log_callback={})
lldb_private::transport::OutgoingRequest< ListToolsResult, void > m_tools_list
llvm::Error Run()
Registers the client with the transport's MainLoop.
lldb_private::transport::OutgoingRequest< ListResourcesResult, void > m_resources_list
void ToolsCall(const CallToolParams ¶ms, Reply< CallToolResult > reply)
std::unique_ptr< MCPTransport > m_transport
lldb_private::transport::Reply< T > Reply
void HandleDisconnect()
Trampolines registered with the binder, which forward to the move-only handlers below.
lldb_private::transport::OutgoingRequest< ReadResourceResult, ReadResourceParams > m_resources_read
void SetDisconnectHandler(llvm::unique_function< void()> handler)
Sets a handler invoked when the transport disconnects (EOF).
void SetErrorHandler(llvm::unique_function< void(llvm::Error)> handler)
Sets a handler invoked on a transport-level error.
lldb_private::transport::OutgoingRequest< InitializeResult, InitializeParams > m_initialize
void HandleError(llvm::Error error)
void ResourcesList(Reply< ListResourcesResult > reply)
lldb_private::transport::OutgoingEvent< void > m_notify_initialized
Client(const Client &)=delete
lldb_private::transport::OutgoingRequest< CallToolResult, CallToolParams > m_tools_call
void NotifyInitialized()
MCP notifications.
std::conditional_t< std::is_void_v< T >, llvm::unique_function< void(llvm::Error)>, llvm::unique_function< void(llvm::Expected< T >)> > Reply
A handler for the response to an outgoing request.
typename detail::event_t< P >::type OutgoingEvent
A function to send an outgoing event.
typename detail::request_t< R, P >::type OutgoingRequest
std::unique_ptr< MCPBinder > MCPBinderUP
llvm::unique_function< void(llvm::StringRef message)> LogCallback
Generic logging callback, to allow the MCP server / client / transport layer to be independent of the...
Sent from the client to the server, to read a specific resource URI.
The server's response to a resources/read request from the client.