This moves all the generic MCP code into the new ProtocolMCP library so it can be shared between the MCP implementation in LLDB (built on the private API) and lldb-mcp (built on the public API). This PR doesn't include the actual MCP server. The reason is that the transport mechanism will be different between the LLDB implementation (using sockets) and the lldb-mcp implementation (using stdio). The goal s to abstract away that difference by making the server use JSONTransport (again) but I'm saving that for a separate PR.
44 lines
1.6 KiB
C++
44 lines
1.6 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLDB_PLUGINS_PROTOCOL_MCP_RESOURCE_H
|
|
#define LLDB_PLUGINS_PROTOCOL_MCP_RESOURCE_H
|
|
|
|
#include "lldb/Protocol/MCP/Protocol.h"
|
|
#include "lldb/Protocol/MCP/Resource.h"
|
|
#include "lldb/lldb-private.h"
|
|
#include <vector>
|
|
|
|
namespace lldb_private::mcp {
|
|
|
|
class DebuggerResourceProvider : public lldb_protocol::mcp::ResourceProvider {
|
|
public:
|
|
using ResourceProvider::ResourceProvider;
|
|
virtual ~DebuggerResourceProvider() = default;
|
|
|
|
virtual std::vector<lldb_protocol::mcp::Resource>
|
|
GetResources() const override;
|
|
virtual llvm::Expected<lldb_protocol::mcp::ResourceResult>
|
|
ReadResource(llvm::StringRef uri) const override;
|
|
|
|
private:
|
|
static lldb_protocol::mcp::Resource GetDebuggerResource(Debugger &debugger);
|
|
static lldb_protocol::mcp::Resource GetTargetResource(size_t target_idx,
|
|
Target &target);
|
|
|
|
static llvm::Expected<lldb_protocol::mcp::ResourceResult>
|
|
ReadDebuggerResource(llvm::StringRef uri, lldb::user_id_t debugger_id);
|
|
static llvm::Expected<lldb_protocol::mcp::ResourceResult>
|
|
ReadTargetResource(llvm::StringRef uri, lldb::user_id_t debugger_id,
|
|
size_t target_idx);
|
|
};
|
|
|
|
} // namespace lldb_private::mcp
|
|
|
|
#endif
|