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 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 discover_remote_services(&self) -> Result<Vec<MCPService>>
pub async fn discover_remote_services(&self) -> Result<Vec<MCPService>>
Discover remote services in the network
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
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<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