Skip to main content

declare_plugin

Macro declare_plugin 

Source
macro_rules! declare_plugin {
    (
        list_tools: $list_fn:expr,
        execute_tool: $execute_fn:expr,
        free_string: $free_fn:expr
        $(, configure: $configure_fn:expr)?
        $(, init: $init_fn:expr)?
        $(, get_config_schema: $schema_fn:expr)?
        $(, list_resources: $list_resources_fn:expr)?
        $(, read_resource: $read_resource_fn:expr)?
    ) => { ... };
}
Expand description

Helper macro to declare a plugin with automatic version management

§Example

use mcp_plugin_api::*;

// Minimal (no configuration, no init)
declare_plugin! {
    list_tools: my_list_tools,
    execute_tool: my_execute_tool,
    free_string: my_free_string
}

// With configuration
declare_plugin! {
    list_tools: my_list_tools,
    execute_tool: my_execute_tool,
    free_string: my_free_string,
    configure: my_configure
}

// With configuration and init
declare_plugin! {
    list_tools: my_list_tools,
    execute_tool: my_execute_tool,
    free_string: my_free_string,
    configure: my_configure,
    init: my_init
}