Loading...
Searching...
No Matches
BinaryNinja::MCP Namespace Reference

Classes

struct  ToolDefinition
class  ToolCall
 One invocation of a tool, as seen by the tool. More...
class  ToolResult
class  Tool
struct  ToolSpec
 A complete tool that has not been registered or created, as ToolBuilder::Build returns it. More...
class  ConvertedArguments
 The unsigned integer arguments converted so far in a call, in declaration order, for parameters evaluated relative to an earlier one. More...
class  Param
 Parameters for MakeTool. More...
class  OptionalParam
 The handler receives std::optional<Value>, empty when the argument is absent or null. More...
class  DefaultParam
 The handler receives the default when the argument is absent or null. More...
class  ValueParam
 A parameter kind that can be made optional or given a default. More...
class  String
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts a JSON string. More...
class  Choice
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts one of a fixed set of strings. More...
class  Bool
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts a JSON boolean. More...
class  UInt
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts a JSON unsigned integer. More...
class  Int
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts a JSON integer, which may be negative. More...
class  Number
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts a JSON number. More...
class  Address
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts an address expression string, evaluated against the call's binary view. More...
class  IntegerExpression
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts an unsigned integer, or an expression string evaluated against the call's binary view. More...
class  List
 A parameter for ToolBuilder::Param, or an item kind for another List, that accepts a JSON array. More...
class  Enum
 A parameter for ToolBuilder::Param, or an item kind for List, that accepts a core enum value by its enumerator name. More...
class  JsonValue
 A parameter for ToolBuilder::Param that accepts any JSON value matching a caller-supplied schema fragment, which carries its own description. More...
class  GroupParam
 A Group that has a parse function, a lookup function or both, created by Group::Parse or Group::Lookup. More...
class  Group
 Parameters that are declared separately but passed to the handler as one value, such as a function named by an address and an architecture. More...
class  ToolBuilder
class  ToolCallHost
 The request state an MCP server supplies for one invocation of a tool. More...

Typedefs

template<class T>
using ArgumentResult = bn::base::expected<T, std::string>
 A converted argument, or the message explaining why the argument is invalid.
using ToolHandler = std::function<ToolResult(ToolCall& call, const rapidjson::Value& arguments)>

Enumerations

enum class  Scope : uint8_t { Global = GlobalScope , BinaryView = BinaryViewScope }

Functions

Ref< Tool > RegisterTool (const ToolDefinition &definition, const std::string &inputSchema, ToolHandler handler)
 Registers a tool for the life of the process.
template<detail::LookupFunction LookupFn>
auto Lookup (LookupFn lookup)
 Creates a Group with no parameters and the given lookup function.
ToolBuilder MakeTool (ToolDefinition definition)
Ref< Tool > CreateTool (ToolSpec spec)
 Creates a tool without registering it.
std::string InvokeTool (Tool &tool, ToolCallHost &host, const std::string &arguments, const ToolResult *error=nullptr)
 Runs the tool for an MCP server and returns an MCP CallToolResult as JSON.

Class Documentation

◆ BinaryNinja::MCP::ToolDefinition

struct BinaryNinja::MCP::ToolDefinition
Class Members
string name
string title
string description
Scope scope = Scope::BinaryView
uint32_t annotations = 0 BNMcpToolAnnotation flags.
string outputSchema Empty for no output schema.

◆ BinaryNinja::MCP::ToolSpec

struct BinaryNinja::MCP::ToolSpec

A complete tool that has not been registered or created, as ToolBuilder::Build returns it.

Class Members
ToolDefinition definition
string inputSchema A JSON Schema object with "type": "object".
ToolHandler handler

Typedef Documentation

◆ ArgumentResult

template<class T>
using BinaryNinja::MCP::ArgumentResult = bn::base::expected<T, std::string>

A converted argument, or the message explaining why the argument is invalid.

◆ ToolHandler

using BinaryNinja::MCP::ToolHandler = std::function<ToolResult(ToolCall& call, const rapidjson::Value& arguments)>

Enumeration Type Documentation

◆ Scope

enum class BinaryNinja::MCP::Scope : uint8_t
strong
Enumerator
Global 
BinaryView 

Function Documentation

◆ RegisterTool()

Ref< Tool > BinaryNinja::MCP::RegisterTool ( const ToolDefinition & definition,
const std::string & inputSchema,
ToolHandler handler )

Registers a tool for the life of the process.

Returns null when the definition is invalid or its name is already registered. inputSchema is a JSON Schema object with "type": "object". A handler that throws produces an internal_error result.

◆ Lookup()

template<detail::LookupFunction LookupFn>
auto BinaryNinja::MCP::Lookup ( LookupFn lookup)

Creates a Group with no parameters and the given lookup function.

◆ MakeTool()

ToolBuilder BinaryNinja::MCP::MakeTool ( ToolDefinition definition)
inline

◆ CreateTool()

Ref< Tool > BinaryNinja::MCP::CreateTool ( ToolSpec spec)

Creates a tool without registering it.

This can be used to expose a tool that is specific to one MCP server, such as one that manages that server's active binary view. Returns null when the definition is invalid.

◆ InvokeTool()

std::string BinaryNinja::MCP::InvokeTool ( Tool & tool,
ToolCallHost & host,
const std::string & arguments,
const ToolResult * error = nullptr )

Runs the tool for an MCP server and returns an MCP CallToolResult as JSON.

An error result, when given, is returned in place of running the tool, finished as the tool's own error would be. This lets a server give its own reason for refusing a call, such as why it has no binary view.