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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//! Core MCP integration infrastructure
//!
//! This module contains the foundational types and constructors for MCP integration.
//! It provides the basic building blocks that other MCP modules depend on.
use crate::;
use Value;
/// Information about the MCP server for AI agent discovery
///
/// This structure provides metadata that AI agents use to understand
/// the capabilities and context of the SCIM server.
///
/// # Examples
///
/// ```rust
/// # #[cfg(feature = "mcp")]
/// use scim_server::mcp_integration::McpServerInfo;
///
/// # #[cfg(feature = "mcp")]
/// let server_info = McpServerInfo {
/// name: "Enterprise SCIM Server".to_string(),
/// version: "2.0.0".to_string(),
/// description: "Production SCIM server for HR systems".to_string(),
/// supported_resource_types: vec!["User".to_string(), "Group".to_string()],
/// };
/// ```
/// Tool execution result for MCP clients
///
/// Represents the outcome of an AI agent's tool execution request.
/// Provides structured feedback that AI agents can use for decision making.
///
/// # Examples
///
/// ```rust
/// # #[cfg(feature = "mcp")]
/// use scim_server::mcp_integration::ScimToolResult;
/// use serde_json::{json, Value};
///
/// # #[cfg(feature = "mcp")]
/// // Successful operation result
/// let success_result = ScimToolResult {
/// success: true,
/// content: json!({"id": "123", "userName": "john.doe"}),
/// metadata: Some(json!({"operation": "create", "resource_type": "User"}))
/// };
///
/// # #[cfg(feature = "mcp")]
/// // Error result
/// let error_result = ScimToolResult {
/// success: false,
/// content: json!({"error": "User not found"}),
/// metadata: Some(json!({"error_code": "404"}))
/// };
/// ```
/// MCP server wrapper for SCIM operations
///
/// This is the main entry point for MCP integration. It wraps a SCIM server
/// and exposes its operations as MCP tools that AI agents can discover and execute.
///
/// # Type Parameters
///
/// * `P` - The resource provider implementation that handles data persistence
///
/// # Examples
///
/// ```rust,no_run
/// # #[cfg(feature = "mcp")]
/// use scim_server::{ScimServer, mcp_integration::ScimMcpServer, providers::StandardResourceProvider};
/// use scim_server::storage::InMemoryStorage;
///
/// # #[cfg(feature = "mcp")]
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let storage = InMemoryStorage::new();
/// let provider = StandardResourceProvider::new(storage);
/// let scim_server = ScimServer::new(provider)?;
/// let mcp_server = ScimMcpServer::new(scim_server);
///
/// // Get available tools
/// let tools = mcp_server.get_tools();
/// println!("Available tools: {}", tools.len());
///
/// // Run MCP server
/// mcp_server.run_stdio().await.unwrap();
/// Ok(())
/// }
/// ```