|
LLDB mainline
|
An MCP client: the counterpart to Server. More...
#include <Client.h>
Public Types | |
| template<typename T> | |
| using | Reply = lldb_private::transport::Reply<T> |
Public Member Functions | |
| Client (std::unique_ptr< MCPTransport > transport, LogCallback log_callback={}) | |
| ~Client ()=default | |
| Client (const Client &)=delete | |
| Client & | operator= (const Client &)=delete |
| llvm::Error | Run () |
| Registers the client with the transport's MainLoop. | |
| 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. | |
| void | NotifyInitialized () |
| MCP notifications. | |
| 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 | ToolsList (Reply< ListToolsResult > reply) |
| void | ToolsCall (const CallToolParams ¶ms, Reply< CallToolResult > reply) |
| void | ResourcesList (Reply< ListResourcesResult > reply) |
| void | ResourcesRead (const ReadResourceParams ¶ms, Reply< ReadResourceResult > reply) |
Private Member Functions | |
| void | Log (llvm::StringRef message) |
| void | HandleDisconnect () |
| Trampolines registered with the binder, which forward to the move-only handlers below. | |
| void | HandleError (llvm::Error error) |
Private Attributes | |
| std::unique_ptr< MCPTransport > | m_transport |
| MCPBinderUP | m_binder |
| LogCallback | m_log_callback |
| llvm::unique_function< void()> | m_disconnect_handler |
| llvm::unique_function< void(llvm::Error)> | m_error_handler |
| lldb_private::transport::OutgoingRequest< InitializeResult, InitializeParams > | m_initialize |
| lldb_private::transport::OutgoingRequest< ListToolsResult, void > | m_tools_list |
| lldb_private::transport::OutgoingRequest< CallToolResult, CallToolParams > | m_tools_call |
| lldb_private::transport::OutgoingRequest< ListResourcesResult, void > | m_resources_list |
| lldb_private::transport::OutgoingRequest< ReadResourceResult, ReadResourceParams > | m_resources_read |
| lldb_private::transport::OutgoingEvent< void > | m_notify_initialized |
An MCP client: the counterpart to Server.
It speaks the MCP protocol to a remote server over a transport and exposes the protocol's requests as typed, asynchronous calls. Each request completes by invoking its Reply on the transport's MainLoop.
| using lldb_protocol::mcp::Client::Reply = lldb_private::transport::Reply<T> |
| Client::Client | ( | std::unique_ptr< MCPTransport > | transport, |
| LogCallback | log_callback = {} ) |
Definition at line 17 of file Client.cpp.
References m_binder, m_initialize, m_log_callback, m_notify_initialized, m_resources_list, m_resources_read, m_tools_call, m_tools_list, and m_transport.
Referenced by Client(), and operator=().
|
default |
| void Client::CancelPendingRequests | ( | llvm::StringRef | reason | ) |
Fails every request still awaiting a response, invoking its reply with an error.
Use before teardown so abandoned replies are satisfied rather than destroyed unanswered.
Definition at line 84 of file Client.cpp.
References m_binder.
|
private |
Trampolines registered with the binder, which forward to the move-only handlers below.
The binder requires copyable callables, so the handlers cannot be registered with it directly.
Definition at line 47 of file Client.cpp.
References m_disconnect_handler.
Referenced by Run().
|
private |
Definition at line 52 of file Client.cpp.
References error(), and m_error_handler.
Referenced by Run().
| void Client::Initialize | ( | const InitializeParams & | params, |
| Reply< InitializeResult > | reply ) |
Outgoing MCP requests to the server.
Each sends its request and invokes its Reply asynchronously when the response arrives.
Definition at line 59 of file Client.cpp.
References m_initialize.
|
private |
Definition at line 88 of file Client.cpp.
References m_log_callback.
| void Client::NotifyInitialized | ( | ) |
| void Client::ResourcesList | ( | Reply< ListResourcesResult > | reply | ) |
Definition at line 73 of file Client.cpp.
References m_resources_list.
| void Client::ResourcesRead | ( | const ReadResourceParams & | params, |
| Reply< ReadResourceResult > | reply ) |
Definition at line 77 of file Client.cpp.
References m_resources_read.
| llvm::Error Client::Run | ( | ) |
Registers the client with the transport's MainLoop.
Must be called before issuing any request.
Definition at line 33 of file Client.cpp.
References HandleDisconnect(), HandleError(), m_binder, and m_transport.
| void Client::SetDisconnectHandler | ( | llvm::unique_function< void()> | handler | ) |
Sets a handler invoked when the transport disconnects (EOF).
Definition at line 39 of file Client.cpp.
References m_disconnect_handler.
| void Client::SetErrorHandler | ( | llvm::unique_function< void(llvm::Error)> | handler | ) |
Sets a handler invoked on a transport-level error.
Definition at line 43 of file Client.cpp.
References m_error_handler.
| void Client::ToolsCall | ( | const CallToolParams & | params, |
| Reply< CallToolResult > | reply ) |
Definition at line 68 of file Client.cpp.
References m_tools_call.
| void Client::ToolsList | ( | Reply< ListToolsResult > | reply | ) |
Definition at line 64 of file Client.cpp.
References m_tools_list.
|
private |
Definition at line 77 of file Client.h.
Referenced by CancelPendingRequests(), Client(), and Run().
|
private |
Definition at line 80 of file Client.h.
Referenced by HandleDisconnect(), and SetDisconnectHandler().
|
private |
Definition at line 81 of file Client.h.
Referenced by HandleError(), and SetErrorHandler().
|
private |
Definition at line 84 of file Client.h.
Referenced by Client(), and Initialize().
|
private |
|
private |
Definition at line 93 of file Client.h.
Referenced by Client(), and NotifyInitialized().
|
private |
Definition at line 89 of file Client.h.
Referenced by Client(), and ResourcesList().
|
private |
Definition at line 92 of file Client.h.
Referenced by Client(), and ResourcesRead().
|
private |
Definition at line 87 of file Client.h.
Referenced by Client(), and ToolsCall().
|
private |
Definition at line 85 of file Client.h.
Referenced by Client(), and ToolsList().
|
private |