Derive Macro McpBackend

Source
#[derive(McpBackend)]
{
    // Attributes available to this derive:
    #[mcp_backend]
}
Expand description

Derive macro for McpBackend

This macro generates implementations for:

  • Custom error type with automatic conversions
  • Backend trait delegation to reduce boilerplate
  • Automatic error mapping and handling
  • Integration with the MCP server framework

§Attributes

§Type-level attributes:

  • #[mcp_backend(error = "CustomError")] - Use custom error type
  • #[mcp_backend(config = "CustomConfig")] - Use custom config type
  • #[mcp_backend(simple)] - Implement SimpleBackend instead of full McpBackend

§Field-level attributes:

  • #[mcp_backend(delegate)] - Delegate method calls to this field
  • #[mcp_backend(error_from)] - Generate error conversion from this type

§Example

#[derive(McpBackend)]
#[mcp_backend(error = "MyBackendError", config = "MyConfig")]
struct MyBackend {
    #[mcp_backend(delegate)]
    inner: SomeInnerBackend,
    config: MyConfig,
}