macro_rules! declare_config_schema {
($config_type:ty) => { ... };
}Expand description
Declare configuration schema export with automatic generation
This macro generates an extern "C" function that exports the plugin’s
configuration schema in JSON Schema format. It uses the schemars crate
to automatically generate the schema from your configuration struct.
The config type must derive JsonSchema from the schemars crate.
§Example
ⓘ
use mcp_plugin_api::*;
use serde::Deserialize;
use schemars::JsonSchema;
#[derive(Debug, Clone, Deserialize, JsonSchema)]
struct PluginConfig {
/// PostgreSQL connection URL
#[schemars(example = "example_db_url")]
database_url: String,
/// Maximum database connections
#[schemars(range(min = 1, max = 100))]
#[serde(default = "default_max_connections")]
max_connections: u32,
}
fn example_db_url() -> &'static str {
"postgresql://user:pass@localhost:5432/dbname"
}
declare_plugin_config!(PluginConfig);
declare_config_schema!(PluginConfig); // ← Generates plugin_get_config_schema
declare_plugin! {
list_tools: generated_list_tools,
execute_tool: generated_execute_tool,
free_string: utils::standard_free_string,
configure: plugin_configure,
get_config_schema: plugin_get_config_schema // ← Use generated function
}