LLDB mainline
lldb_protocol::mcp Namespace Reference

Classes

struct  CallToolParams
 Used by the client to invoke a tool provided by the server. More...
struct  CallToolResult
 The server’s response to a tool call. More...
struct  ClientCapabilities
 Capabilities a client may support. More...
struct  Error
struct  Implementation
 Describes the name and version of an MCP implementation, with an optional title for UI representation. More...
struct  InitializeParams
 Initialization. More...
struct  InitializeResult
 After receiving an initialize request from the client, the server sends this response. More...
struct  ListResourcesResult
 The server’s response to a resources/list request from the client. More...
struct  ListToolsResult
 The server's response to a tools/list request from the client. More...
class  MCPError
struct  Notification
 A notification which does not expect a response. More...
struct  ReadResourceParams
 Sent from the client to the server, to read a specific resource URI. More...
struct  ReadResourceResult
 The server's response to a resources/read request from the client. More...
struct  Request
 A request that expects a response. More...
struct  Resource
 A known resource that the server is capable of reading. More...
class  ResourceProvider
struct  Response
 A response to a request, either an error or a result. More...
class  Server
struct  ServerCapabilities
 Capabilities that a server may support. More...
struct  ServerInfo
 Information about this instance of lldb's MCP server for lldb-mcp to use to coordinate connecting an lldb-mcp client. More...
class  ServerInfoHandle
 A handle that tracks the server info on disk and cleans up the disk record once it is no longer referenced. More...
struct  TextContent
 Text provided to or from an LLM. More...
struct  TextResourceContents
 The contents of a specific resource or sub-resource. More...
class  Tool
struct  ToolDefinition
 Definition for a tool the client can call. More...
class  Transport
class  UnsupportedURI

Typedefs

using Id = std::variant<int64_t, std::string>
 A Request or Response 'id'.
using Message = std::variant<Request, Response, Notification>
 A general message as defined by the JSON-RPC 2.0 spec.
using ToolArguments = std::variant<std::monostate, llvm::json::Value>
using Void = std::monostate
 Special case parameter or result that has no value.
using ContentBlock = TextContent
 Supported content types, currently only TextContent, but the spec includes additional content types.
using MCPTransport = lldb_private::Transport<Request, Response, Notification>
 Generic transport that uses the MCP protocol.
using LogCallback = llvm::unique_function<void(llvm::StringRef message)>
 Generic logging callback, to allow the MCP server / client / transport layer to be independent of the lldb log implementation.

Enumerations

enum  ErrorCode : signed {
  eErrorCodeParseError = -32700 , eErrorCodeInvalidRequest = -32600 , eErrorCodeMethodNotFound = -32601 , eErrorCodeInvalidParams = -32602 ,
  eErrorCodeInternalError = -32603
}

Functions

llvm::json::Value toJSON (const Request &)
bool fromJSON (const llvm::json::Value &, Request &, llvm::json::Path)
bool operator== (const Request &, const Request &)
llvm::json::Value toJSON (const Error &)
bool fromJSON (const llvm::json::Value &, Error &, llvm::json::Path)
bool operator== (const Error &, const Error &)
llvm::json::Value toJSON (const Response &)
bool fromJSON (const llvm::json::Value &, Response &, llvm::json::Path)
bool operator== (const Response &, const Response &)
llvm::json::Value toJSON (const Notification &)
bool fromJSON (const llvm::json::Value &, Notification &, llvm::json::Path)
bool operator== (const Notification &, const Notification &)
bool fromJSON (const llvm::json::Value &, Message &, llvm::json::Path)
llvm::json::Value toJSON (const Message &)
llvm::json::Value toJSON (const Resource &)
bool fromJSON (const llvm::json::Value &, Resource &, llvm::json::Path)
llvm::json::Value toJSON (const ListResourcesResult &)
bool fromJSON (const llvm::json::Value &, ListResourcesResult &, llvm::json::Path)
llvm::json::Value toJSON (const TextResourceContents &)
bool fromJSON (const llvm::json::Value &, TextResourceContents &, llvm::json::Path)
llvm::json::Value toJSON (const ReadResourceParams &)
bool fromJSON (const llvm::json::Value &, ReadResourceParams &, llvm::json::Path)
llvm::json::Value toJSON (const ReadResourceResult &)
bool fromJSON (const llvm::json::Value &, ReadResourceResult &, llvm::json::Path)
llvm::json::Value toJSON (const TextContent &)
bool fromJSON (const llvm::json::Value &, TextContent &, llvm::json::Path)
llvm::json::Value toJSON (const ToolDefinition &)
bool fromJSON (const llvm::json::Value &, ToolDefinition &, llvm::json::Path)
llvm::json::Value toJSON (const Implementation &)
bool fromJSON (const llvm::json::Value &, Implementation &, llvm::json::Path)
llvm::json::Value toJSON (const ClientCapabilities &)
bool fromJSON (const llvm::json::Value &, ClientCapabilities &, llvm::json::Path)
llvm::json::Value toJSON (const ServerCapabilities &)
bool fromJSON (const llvm::json::Value &, ServerCapabilities &, llvm::json::Path)
llvm::json::Value toJSON (const InitializeParams &)
bool fromJSON (const llvm::json::Value &, InitializeParams &, llvm::json::Path)
llvm::json::Value toJSON (const InitializeResult &)
bool fromJSON (const llvm::json::Value &, InitializeResult &, llvm::json::Path)
llvm::json::Value toJSON (const Void &)
bool fromJSON (const llvm::json::Value &, Void &, llvm::json::Path)
llvm::json::Value toJSON (const ListToolsResult &)
bool fromJSON (const llvm::json::Value &, ListToolsResult &, llvm::json::Path)
llvm::json::Value toJSON (const CallToolParams &)
bool fromJSON (const llvm::json::Value &, CallToolParams &, llvm::json::Path)
llvm::json::Value toJSON (const CallToolResult &)
bool fromJSON (const llvm::json::Value &, CallToolResult &, llvm::json::Path)
llvm::json::Value toJSON (const ServerInfo &)
bool fromJSON (const llvm::json::Value &, ServerInfo &, llvm::json::Path)
static bool mapRaw (const json::Value &Params, StringLiteral Prop, std::optional< json::Value > &V, json::Path P)
static llvm::json::Value toJSON (const Id &Id)
static bool mapId (const llvm::json::Value &V, StringLiteral Prop, Id &Id, llvm::json::Path P)
bool fromJSON (const json::Value &V, Implementation &I, json::Path P)
bool fromJSON (const json::Value &, ClientCapabilities &, json::Path)
bool fromJSON (const json::Value &V, ServerCapabilities &C, json::Path P)
bool fromJSON (const json::Value &V, InitializeParams &I, json::Path P)
bool fromJSON (const json::Value &V, InitializeResult &R, json::Path P)
bool fromJSON (const json::Value &V, ListToolsResult &R, json::Path P)
bool fromJSON (const json::Value &V, CallToolResult &R, json::Path P)
bool fromJSON (const json::Value &V, CallToolParams &R, json::Path P)
bool fromJSON (const json::Value &V, ReadResourceParams &R, json::Path P)
bool fromJSON (const json::Value &V, ListResourcesResult &R, json::Path P)
bool fromJSON (const json::Value &V, Void &R, json::Path P)

Variables

static llvm::StringLiteral kProtocolVersion = "2024-11-05"

Typedef Documentation

◆ ContentBlock

Supported content types, currently only TextContent, but the spec includes additional content types.

Definition at line 288 of file Protocol.h.

◆ Id

using lldb_protocol::mcp::Id = std::variant<int64_t, std::string>

A Request or Response 'id'.

NOTE: This differs from the JSON-RPC 2.0 spec. The MCP spec says this must be a string or number, excluding a json 'null' as a valid id.

Definition at line 31 of file Protocol.h.

◆ LogCallback

using lldb_protocol::mcp::LogCallback = llvm::unique_function<void(llvm::StringRef message)>

Generic logging callback, to allow the MCP server / client / transport layer to be independent of the lldb log implementation.

Definition at line 25 of file Transport.h.

◆ MCPTransport

Generic transport that uses the MCP protocol.

Definition at line 21 of file Transport.h.

◆ Message

A general message as defined by the JSON-RPC 2.0 spec.

Definition at line 99 of file Protocol.h.

◆ ToolArguments

using lldb_protocol::mcp::ToolArguments = std::variant<std::monostate, llvm::json::Value>

Definition at line 190 of file Protocol.h.

◆ Void

using lldb_protocol::mcp::Void = std::monostate

Special case parameter or result that has no value.

Definition at line 275 of file Protocol.h.

Enumeration Type Documentation

◆ ErrorCode

Enumerator
eErrorCodeParseError 

Invalid JSON was received by the server.

An error occurred on the server while parsing the JSON text.

eErrorCodeInvalidRequest 

The JSON sent is not a valid Request object.

eErrorCodeMethodNotFound 

The method does not exist / is not available.

eErrorCodeInvalidParams 

Invalid method parameter(s).

eErrorCodeInternalError 

Internal JSON-RPC error.

Definition at line 46 of file Protocol.h.

Function Documentation

◆ fromJSON() [1/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & ,
ClientCapabilities & ,
json::Path  )

Definition at line 305 of file Protocol.cpp.

◆ fromJSON() [2/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
CallToolParams & R,
json::Path P )

◆ fromJSON() [3/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
CallToolResult & R,
json::Path P )

◆ fromJSON() [4/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
Implementation & I,
json::Path P )

◆ fromJSON() [5/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
InitializeParams & I,
json::Path P )

◆ fromJSON() [6/33]

◆ fromJSON() [7/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
ListResourcesResult & R,
json::Path P )

Definition at line 434 of file Protocol.cpp.

References lldb_protocol::mcp::ListResourcesResult::resources.

◆ fromJSON() [8/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
ListToolsResult & R,
json::Path P )

Definition at line 384 of file Protocol.cpp.

References lldb_protocol::mcp::ListToolsResult::tools.

◆ fromJSON() [9/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
ReadResourceParams & R,
json::Path P )

Definition at line 425 of file Protocol.cpp.

References lldb_protocol::mcp::ReadResourceParams::uri.

◆ fromJSON() [10/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
ServerCapabilities & C,
json::Path P )

◆ fromJSON() [11/33]

bool lldb_protocol::mcp::fromJSON ( const json::Value & V,
Void & R,
json::Path P )

Definition at line 441 of file Protocol.cpp.

◆ fromJSON() [12/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
CallToolParams & ,
llvm::json::Path  )

◆ fromJSON() [13/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
CallToolResult & ,
llvm::json::Path  )

◆ fromJSON() [14/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
ClientCapabilities & ,
llvm::json::Path  )

◆ fromJSON() [15/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
Error & E,
llvm::json::Path P )

◆ fromJSON() [16/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
Implementation & ,
llvm::json::Path  )

◆ fromJSON() [17/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
InitializeParams & ,
llvm::json::Path  )

◆ fromJSON() [18/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
InitializeResult & ,
llvm::json::Path  )

◆ fromJSON() [19/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
ListResourcesResult & ,
llvm::json::Path  )

◆ fromJSON() [20/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
ListToolsResult & ,
llvm::json::Path  )

◆ fromJSON() [21/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
Message & M,
llvm::json::Path P )

Definition at line 242 of file Protocol.cpp.

References fromJSON().

◆ fromJSON() [22/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
Notification & N,
llvm::json::Path P )

Definition at line 154 of file Protocol.cpp.

◆ fromJSON() [23/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
ReadResourceParams & ,
llvm::json::Path  )

◆ fromJSON() [24/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
ReadResourceResult & RR,
llvm::json::Path P )

Definition at line 204 of file Protocol.cpp.

References lldb_protocol::mcp::ReadResourceResult::contents.

◆ fromJSON() [25/33]

◆ fromJSON() [26/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
Resource & R,
llvm::json::Path P )

◆ fromJSON() [27/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
Response & R,
llvm::json::Path P )

◆ fromJSON() [28/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
ServerCapabilities & ,
llvm::json::Path  )

◆ fromJSON() [29/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
ServerInfo & ,
llvm::json::Path  )

◆ fromJSON() [30/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
TextContent & TC,
llvm::json::Path P )

Definition at line 214 of file Protocol.cpp.

References lldb_protocol::mcp::TextContent::text.

◆ fromJSON() [31/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
TextResourceContents & RC,
llvm::json::Path P )

◆ fromJSON() [32/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & V,
ToolDefinition & TD,
llvm::json::Path P )

◆ fromJSON() [33/33]

bool lldb_protocol::mcp::fromJSON ( const llvm::json::Value & ,
Void & ,
llvm::json::Path  )

◆ mapId()

bool lldb_protocol::mcp::mapId ( const llvm::json::Value & V,
StringLiteral Prop,
Id & Id,
llvm::json::Path P )
static

Definition at line 38 of file Protocol.cpp.

Referenced by fromJSON(), and fromJSON().

◆ mapRaw()

bool lldb_protocol::mcp::mapRaw ( const json::Value & Params,
StringLiteral Prop,
std::optional< json::Value > & V,
json::Path P )
static

Definition at line 17 of file Protocol.cpp.

Referenced by fromJSON(), fromJSON(), fromJSON(), fromJSON(), and fromJSON().

◆ operator==() [1/4]

bool lldb_protocol::mcp::operator== ( const Error & a,
const Error & b )

◆ operator==() [2/4]

bool lldb_protocol::mcp::operator== ( const Notification & a,
const Notification & b )

◆ operator==() [3/4]

bool lldb_protocol::mcp::operator== ( const Request & a,
const Request & b )

◆ operator==() [4/4]

bool lldb_protocol::mcp::operator== ( const Response & a,
const Response & b )

◆ toJSON() [1/23]

json::Value lldb_protocol::mcp::toJSON ( const CallToolParams & R)

◆ toJSON() [2/23]

◆ toJSON() [3/23]

json::Value lldb_protocol::mcp::toJSON ( const ClientCapabilities & C)

Definition at line 303 of file Protocol.cpp.

◆ toJSON() [4/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const Error & E)

◆ toJSON() [5/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const Id & Id)
static

Definition at line 30 of file Protocol.cpp.

◆ toJSON() [6/23]

json::Value lldb_protocol::mcp::toJSON ( const Implementation & I)

◆ toJSON() [7/23]

◆ toJSON() [8/23]

◆ toJSON() [9/23]

json::Value lldb_protocol::mcp::toJSON ( const ListResourcesResult & R)

Definition at line 430 of file Protocol.cpp.

References lldb_protocol::mcp::ListResourcesResult::resources.

◆ toJSON() [10/23]

json::Value lldb_protocol::mcp::toJSON ( const ListToolsResult & R)

Definition at line 380 of file Protocol.cpp.

References lldb_protocol::mcp::ListToolsResult::tools.

◆ toJSON() [11/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const Message & M)

Definition at line 238 of file Protocol.cpp.

References toJSON().

◆ toJSON() [12/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const Notification & N)

Definition at line 147 of file Protocol.cpp.

◆ toJSON() [13/23]

json::Value lldb_protocol::mcp::toJSON ( const ReadResourceParams & R)

Definition at line 421 of file Protocol.cpp.

References lldb_protocol::mcp::ReadResourceParams::uri.

◆ toJSON() [14/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const ReadResourceResult & RR)

Definition at line 200 of file Protocol.cpp.

References lldb_protocol::mcp::ReadResourceResult::contents.

◆ toJSON() [15/23]

◆ toJSON() [16/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const Resource & R)

◆ toJSON() [17/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const Response & R)

◆ toJSON() [18/23]

◆ toJSON() [19/23]

json::Value lldb_protocol::mcp::toJSON ( const ServerInfo & SM)

Definition at line 53 of file Server.cpp.

References lldb_protocol::mcp::ServerInfo::connection_uri.

◆ toJSON() [20/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const TextContent & TC)

Definition at line 210 of file Protocol.cpp.

References lldb_protocol::mcp::TextContent::text.

◆ toJSON() [21/23]

◆ toJSON() [22/23]

llvm::json::Value lldb_protocol::mcp::toJSON ( const ToolDefinition & TD)

◆ toJSON() [23/23]

json::Value lldb_protocol::mcp::toJSON ( const Void & R)

Definition at line 439 of file Protocol.cpp.

Variable Documentation

◆ kProtocolVersion

llvm::StringLiteral lldb_protocol::mcp::kProtocolVersion = "2024-11-05"
static

Definition at line 25 of file Protocol.h.

Referenced by lldb_protocol::mcp::Server::InitializeHandler().