14#ifndef LLDB_PROTOCOL_MCP_PROTOCOL_H
15#define LLDB_PROTOCOL_MCP_PROTOCOL_H
17#include "llvm/Support/JSON.h"
31using Id = std::variant<int64_t, std::string>;
40 std::optional<llvm::json::Value>
params;
69 std::optional<llvm::json::Value>
data = std::nullopt;
72bool fromJSON(
const llvm::json::Value &,
Error &, llvm::json::Path);
81 std::variant<Error, llvm::json::Value>
result;
92 std::optional<llvm::json::Value>
params;
99using Message = std::variant<Request, Response, Notification>;
102static_assert(std::is_convertible_v<Message, Message>,
103 "Message is not convertible to itself");
std::variant< Request, Response, Notification > Message
A general message as defined by the JSON-RPC 2.0 spec.
std::monostate Void
Special case parameter or result that has no value.
std::variant< int64_t, std::string > Id
A Request or Response 'id'.
std::variant< std::monostate, llvm::json::Value > ToolArguments
@ eErrorCodeMethodNotFound
The method does not exist / is not available.
@ eErrorCodeInvalidParams
Invalid method parameter(s).
@ eErrorCodeInvalidRequest
The JSON sent is not a valid Request object.
@ eErrorCodeInternalError
Internal JSON-RPC error.
@ eErrorCodeParseError
Invalid JSON was received by the server.
TextContent ContentBlock
Supported content types, currently only TextContent, but the spec includes additional content types.
llvm::json::Value toJSON(const Request &)
bool operator==(const Request &, const Request &)
static llvm::StringLiteral kProtocolVersion
bool fromJSON(const llvm::json::Value &, Request &, llvm::json::Path)
Capabilities a client may support.
std::string message
A short description of the error.
std::optional< llvm::json::Value > data
Additional information about the error.
int64_t code
The error type that occurred.
Describes the name and version of an MCP implementation, with an optional title for UI representation...
std::string title
Intended for UI and end-user contexts — optimized to be human-readable and easily understood,...
std::string name
Intended for programmatic or logical use, but used as a display name in past specs or fallback (if ti...
Implementation clientInfo
std::string protocolVersion
The latest version of the Model Context Protocol that the client supports.
ClientCapabilities capabilities
After receiving an initialize request from the client, the server sends this response.
std::string protocolVersion
The version of the Model Context Protocol that the server wants to use.
std::string instructions
Instructions describing how to use the server and its features.
ServerCapabilities capabilities
Implementation serverInfo
The server’s response to a resources/list request from the client.
std::vector< Resource > resources
A notification which does not expect a response.
std::optional< llvm::json::Value > params
The notification's params.
std::string method
The method to be invoked.
Sent from the client to the server, to read a specific resource URI.
std::string uri
The URI of the resource to read.
The server's response to a resources/read request from the client.
std::vector< TextResourceContents > contents
A request that expects a response.
std::optional< llvm::json::Value > params
The method's params.
std::string method
The method to be invoked.
A known resource that the server is capable of reading.
std::string description
A description of what this resource represents.
std::string uri
The URI of this resource.
std::string mimeType
The MIME type of this resource, if known.
std::string name
A human-readable name for this resource.
A response to a request, either an error or a result.
std::variant< Error, llvm::json::Value > result
The result of the request, either an Error or the JSON value of the response.
Capabilities that a server may support.
bool supportsCompletions
Utilities.
bool supportsResourcesList
bool supportsResourcesSubscribe
Text provided to or from an LLM.
std::string text
The text content of the message.
The contents of a specific resource or sub-resource.
std::string text
The text of the item.
std::string uri
The URI of this resource.
std::string mimeType
The MIME type of this resource, if known.