1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Protocol extensions (MCP 2026-07-28 RC).
//!
//! The RC reclassifies several former core features (starting with Tasks) as
//! *extensions*: each is identified by a reverse-DNS id, advertises a
//! capability value under `capabilities.extensions[id]`, and brings its own
//! request handlers. This module defines the [`Extension`] trait that wires
//! such a feature into an [`App`]; concrete extensions live in submodules
//! (e.g. the built-in [`TasksExtension`]).
use App;
pub use TasksExtension;
/// A protocol extension (MCP 2026-07-28 RC).
///
/// An extension contributes a capability value (surfaced in `server/discover`
/// under `capabilities.extensions`) and registers its request handlers.
/// Register one with [`App::with_extension`].
///
/// # Example
///
/// ```rust,ignore
/// use neva::App;
/// use neva::app::extension::Extension;
///
/// struct Echo;
/// impl Extension for Echo {
/// fn id(&self) -> &'static str { "com.example/echo" }
/// fn capability(&self) -> serde_json::Value { serde_json::json!({}) }
/// fn register(self, app: &mut App) {
/// app.map_handler("com.example/echo", |msg: String| async move { msg });
/// }
/// }
///
/// let app = App::new().with_extension(Echo);
/// ```