Files
clang-p2996/lldb/source/Plugins/Protocol/MCP/MCPError.h
Jonas Devlieghere 9524bfb270 [lldb] Add Model Context Protocol (MCP) support to LLDB (#143628)
This PR adds an MCP (Model Context Protocol ) server to LLDB. For
motivation and background, please refer to the corresponding RFC:
https://discourse.llvm.org/t/rfc-adding-mcp-support-to-lldb/86798

I implemented this as a new kind of plugin. The idea is that we could
support multiple protocol servers (e.g. if we want to support DAP from
within LLDB). This also introduces a corresponding top-level command
(`protocol-server`) with two subcommands to `start` and `stop` the
server.

```
(lldb) protocol-server start MCP tcp://localhost:1234
MCP server started with connection listeners: connection://[::1]:1234, connection://[127.0.0.1]:1234
```

The MCP sever supports one tool (`lldb_command`) which executes a
command, but can easily be extended with more commands.
2025-06-20 10:48:04 -05:00

34 lines
914 B
C++

//===-- MCPError.h --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Protocol.h"
#include "llvm/Support/Error.h"
#include <string>
namespace lldb_private::mcp {
class MCPError : public llvm::ErrorInfo<MCPError> {
public:
static char ID;
MCPError(std::string message, int64_t error_code);
void log(llvm::raw_ostream &OS) const override;
std::error_code convertToErrorCode() const override;
const std::string &getMessage() const { return m_message; }
protocol::Error toProtcolError() const;
private:
std::string m_message;
int64_t m_error_code;
};
} // namespace lldb_private::mcp