pub struct DynamicServerManager { /* private fields */ }Available on non-WebAssembly only.
Expand description
Dynamic server manager for runtime configuration
§Examples
use pmcp::server::dynamic::DynamicServerManager;
use pmcp::server::Server;
use std::sync::Arc;
let server = Server::builder()
.name("dynamic-server")
.version("1.0.0")
.build()?;
let server = Arc::new(server);
let manager = DynamicServerManager::new(server.clone());
// Now you can add/remove tools, prompts, resources at runtimeImplementations§
Source§impl DynamicServerManager
impl DynamicServerManager
Sourcepub fn new(server: Arc<Server>) -> Self
pub fn new(server: Arc<Server>) -> Self
Create a new dynamic server manager
§Examples
use pmcp::server::dynamic::DynamicServerManager;
use pmcp::server::Server;
use std::sync::Arc;
let server = Server::builder()
.name("test-server")
.version("1.0.0")
.build()?;
let server_arc = Arc::new(server);
let manager = DynamicServerManager::new(server_arc);Sourcepub async fn add_tool(
&self,
name: impl Into<String>,
handler: Arc<dyn ToolHandler>,
_info: ToolInfo,
) -> Result<()>
pub async fn add_tool( &self, name: impl Into<String>, handler: Arc<dyn ToolHandler>, _info: ToolInfo, ) -> Result<()>
Add a tool at runtime
Adds a tool handler to the dynamic registry for runtime tool availability.
Sourcepub async fn remove_tool(&self, name: &str) -> Result<()>
pub async fn remove_tool(&self, name: &str) -> Result<()>
Remove a tool at runtime
Sourcepub async fn add_prompt(
&self,
name: impl Into<String>,
handler: Arc<dyn PromptHandler>,
_info: PromptInfo,
) -> Result<()>
pub async fn add_prompt( &self, name: impl Into<String>, handler: Arc<dyn PromptHandler>, _info: PromptInfo, ) -> Result<()>
Add a prompt at runtime
Sourcepub async fn remove_prompt(&self, name: &str) -> Result<()>
pub async fn remove_prompt(&self, name: &str) -> Result<()>
Remove a prompt at runtime
Sourcepub async fn set_resource_handler(
&self,
handler: Arc<dyn ResourceHandler>,
) -> Result<()>
pub async fn set_resource_handler( &self, handler: Arc<dyn ResourceHandler>, ) -> Result<()>
Set resource handler at runtime
Sourcepub async fn remove_resource_handler(&self) -> Result<()>
pub async fn remove_resource_handler(&self) -> Result<()>
Remove resource handler at runtime
Sourcepub async fn set_sampling_handler(
&self,
handler: Arc<dyn SamplingHandler>,
) -> Result<()>
pub async fn set_sampling_handler( &self, handler: Arc<dyn SamplingHandler>, ) -> Result<()>
Set sampling handler at runtime
Sourcepub async fn remove_sampling_handler(&self) -> Result<()>
pub async fn remove_sampling_handler(&self) -> Result<()>
Remove sampling handler at runtime
Sourcepub async fn add_capability_listener<F>(&self, listener: F)
pub async fn add_capability_listener<F>(&self, listener: F)
Register a capability update listener
Sourcepub async fn get_dynamic_tools(&self) -> HashMap<String, Arc<dyn ToolHandler>>
pub async fn get_dynamic_tools(&self) -> HashMap<String, Arc<dyn ToolHandler>>
Get current dynamic tools
Sourcepub async fn get_dynamic_prompts(
&self,
) -> HashMap<String, Arc<dyn PromptHandler>>
pub async fn get_dynamic_prompts( &self, ) -> HashMap<String, Arc<dyn PromptHandler>>
Get current dynamic prompts
Sourcepub async fn has_tool(&self, name: &str) -> bool
pub async fn has_tool(&self, name: &str) -> bool
Check if a tool exists (either static or dynamic)
Sourcepub async fn has_prompt(&self, name: &str) -> bool
pub async fn has_prompt(&self, name: &str) -> bool
Check if a prompt exists (either static or dynamic)
Sourcepub async fn reload_configuration(&self, config: DynamicConfig) -> Result<()>
pub async fn reload_configuration(&self, config: DynamicConfig) -> Result<()>
Reload configuration from a source
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DynamicServerManager
impl !UnwindSafe for DynamicServerManager
impl Freeze for DynamicServerManager
impl Send for DynamicServerManager
impl Sync for DynamicServerManager
impl Unpin for DynamicServerManager
impl UnsafeUnpin for DynamicServerManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more