pub struct MCPServer { /* private fields */ }Expand description
Main MCP server implementation
Implementations§
Source§impl MCPServer
impl MCPServer
Sourcepub fn new(config: MCPServerConfig) -> Self
pub fn new(config: MCPServerConfig) -> Self
Create a new MCP server
Sourcepub async fn with_network_sender(self, sender: Arc<dyn NetworkSender>) -> Self
pub async fn with_network_sender(self, sender: Arc<dyn NetworkSender>) -> Self
Set the network sender for P2P communication
Sourcepub async fn set_network_sender(&self, sender: Arc<dyn NetworkSender>)
pub async fn set_network_sender(&self, sender: Arc<dyn NetworkSender>)
Set the network sender for P2P communication (async method for post-creation setup)
Sourcepub async fn register_tool(&self, tool: Tool) -> Result<()>
pub async fn register_tool(&self, tool: Tool) -> Result<()>
Register a tool
Sourcepub async fn call_tool(
&self,
tool_name: &str,
arguments: Value,
context: MCPCallContext,
) -> Result<Value>
pub async fn call_tool( &self, tool_name: &str, arguments: Value, context: MCPCallContext, ) -> Result<Value>
Call a tool by name
Sourcepub async fn list_tools(
&self,
_cursor: Option<String>,
) -> Result<(Vec<MCPTool>, Option<String>)>
pub async fn list_tools( &self, _cursor: Option<String>, ) -> Result<(Vec<MCPTool>, Option<String>)>
List available tools
Sourcepub async fn get_stats(&self) -> MCPServerStats
pub async fn get_stats(&self) -> MCPServerStats
Get server statistics
Sourcepub async fn handle_heartbeat(&self, heartbeat: Heartbeat) -> Result<()>
pub async fn handle_heartbeat(&self, heartbeat: Heartbeat) -> Result<()>
Handle incoming heartbeat from a remote service
Sourcepub async fn get_service_health(
&self,
service_id: &str,
) -> Option<ServiceHealth>
pub async fn get_service_health( &self, service_id: &str, ) -> Option<ServiceHealth>
Get health status of a specific service
Sourcepub async fn get_all_service_health(&self) -> HashMap<String, ServiceHealth>
pub async fn get_all_service_health(&self) -> HashMap<String, ServiceHealth>
Get health status of all services
Sourcepub async fn get_healthy_services(&self) -> Vec<String>
pub async fn get_healthy_services(&self) -> Vec<String>
Get healthy services only
Sourcepub async fn update_service_health(
&self,
service_id: String,
status: ServiceHealthStatus,
error_message: Option<String>,
)
pub async fn update_service_health( &self, service_id: String, status: ServiceHealthStatus, error_message: Option<String>, )
Update service health status manually
Sourcepub fn subscribe_health_events(&self) -> UnboundedReceiver<HealthEvent>
pub fn subscribe_health_events(&self) -> UnboundedReceiver<HealthEvent>
Subscribe to health events
Sourcepub async fn is_service_healthy(&self, service_id: &str) -> bool
pub async fn is_service_healthy(&self, service_id: &str) -> bool
Check if a service is healthy
Sourcepub async fn get_service_load_info(&self) -> HashMap<String, f32>
pub async fn get_service_load_info(&self) -> HashMap<String, f32>
Get service load balancing information
Sourcepub async fn call_remote_tool(
&self,
peer_id: &PeerId,
tool_name: &str,
arguments: Value,
context: MCPCallContext,
) -> Result<Value>
pub async fn call_remote_tool( &self, peer_id: &PeerId, tool_name: &str, arguments: Value, context: MCPCallContext, ) -> Result<Value>
Call a tool on a remote node
Sourcepub async fn handle_p2p_message(
&self,
message_data: &[u8],
source_peer: &PeerId,
) -> Result<Option<Vec<u8>>>
pub async fn handle_p2p_message( &self, message_data: &[u8], source_peer: &PeerId, ) -> Result<Option<Vec<u8>>>
Handle incoming P2P MCP message
Sourcepub async fn generate_auth_token(
&self,
peer_id: &PeerId,
permissions: Vec<MCPPermission>,
ttl: Duration,
) -> Result<String>
pub async fn generate_auth_token( &self, peer_id: &PeerId, permissions: Vec<MCPPermission>, ttl: Duration, ) -> Result<String>
Generate authentication token for peer
Sourcepub async fn verify_auth_token(&self, token: &str) -> Result<TokenPayload>
pub async fn verify_auth_token(&self, token: &str) -> Result<TokenPayload>
Verify authentication token
Sourcepub async fn check_permission(
&self,
peer_id: &PeerId,
permission: &MCPPermission,
) -> Result<bool>
pub async fn check_permission( &self, peer_id: &PeerId, permission: &MCPPermission, ) -> Result<bool>
Check if peer has permission for operation
Sourcepub async fn check_rate_limit(&self, peer_id: &PeerId) -> Result<bool>
pub async fn check_rate_limit(&self, peer_id: &PeerId) -> Result<bool>
Check rate limit for peer
Sourcepub async fn grant_permission(
&self,
peer_id: &PeerId,
permission: MCPPermission,
) -> Result<()>
pub async fn grant_permission( &self, peer_id: &PeerId, permission: MCPPermission, ) -> Result<()>
Grant permission to peer
Sourcepub async fn revoke_permission(
&self,
peer_id: &PeerId,
permission: &MCPPermission,
) -> Result<()>
pub async fn revoke_permission( &self, peer_id: &PeerId, permission: &MCPPermission, ) -> Result<()>
Revoke permission from peer
Sourcepub async fn add_trusted_peer(&self, peer_id: PeerId) -> Result<()>
pub async fn add_trusted_peer(&self, peer_id: PeerId) -> Result<()>
Add trusted peer
Sourcepub async fn is_trusted_peer(&self, peer_id: &PeerId) -> bool
pub async fn is_trusted_peer(&self, peer_id: &PeerId) -> bool
Check if peer is trusted
Sourcepub async fn set_tool_security_policy(
&self,
tool_name: String,
level: SecurityLevel,
) -> Result<()>
pub async fn set_tool_security_policy( &self, tool_name: String, level: SecurityLevel, ) -> Result<()>
Set security policy for tool
Sourcepub async fn get_tool_security_policy(&self, tool_name: &str) -> SecurityLevel
pub async fn get_tool_security_policy(&self, tool_name: &str) -> SecurityLevel
Get security policy for tool
Sourcepub async fn get_peer_security_stats(&self, peer_id: &PeerId) -> Option<PeerACL>
pub async fn get_peer_security_stats(&self, peer_id: &PeerId) -> Option<PeerACL>
Get peer security statistics
Sourcepub async fn get_security_audit(
&self,
limit: Option<usize>,
) -> Vec<SecurityAuditEntry>
pub async fn get_security_audit( &self, limit: Option<usize>, ) -> Vec<SecurityAuditEntry>
Get recent security audit entries
Sourcepub async fn security_cleanup(&self) -> Result<()>
pub async fn security_cleanup(&self) -> Result<()>
Perform security housekeeping
Sourcepub async fn announce_local_services(&self) -> Result<()>
pub async fn announce_local_services(&self) -> Result<()>
Announce local services to the network
Sourcepub async fn discover_remote_services(&self) -> Result<Vec<MCPService>>
pub async fn discover_remote_services(&self) -> Result<Vec<MCPService>>
Discover services from other peers
Sourcepub async fn refresh_service_discovery(&self) -> Result<()>
pub async fn refresh_service_discovery(&self) -> Result<()>
Refresh service discovery and update remote services cache
Sourcepub async fn get_all_services(&self) -> Result<Vec<MCPService>>
pub async fn get_all_services(&self) -> Result<Vec<MCPService>>
Get all known services (local + remote)
Sourcepub async fn find_services_with_tool(
&self,
tool_name: &str,
) -> Result<Vec<MCPService>>
pub async fn find_services_with_tool( &self, tool_name: &str, ) -> Result<Vec<MCPService>>
Find services that provide a specific tool
Sourcepub async fn handle_service_advertisement(
&self,
message: P2PMCPMessage,
) -> Result<()>
pub async fn handle_service_advertisement( &self, message: P2PMCPMessage, ) -> Result<()>
Handle service advertisement
Sourcepub async fn handle_service_discovery(
&self,
message: P2PMCPMessage,
) -> Result<Option<Vec<u8>>>
pub async fn handle_service_discovery( &self, message: P2PMCPMessage, ) -> Result<Option<Vec<u8>>>
Handle service discovery request
Auto Trait Implementations§
impl Freeze for MCPServer
impl !RefUnwindSafe for MCPServer
impl Send for MCPServer
impl Sync for MCPServer
impl Unpin for MCPServer
impl !UnwindSafe for MCPServer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.