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
//! MCP (Model Context Protocol) Integration for SCIM Server
//!
//! This module provides comprehensive MCP integration that exposes SCIM operations
//! as structured tools for AI agents. The integration enables AI systems to perform
//! identity management operations through a standardized protocol interface.
//!
//! ## Overview
//!
//! The MCP integration transforms SCIM server operations into discoverable tools
//! that AI agents can understand and execute. This enables:
//!
//! - **Automated Identity Management**: AI agents can provision/deprovision users
//! - **Schema-Driven Operations**: AI agents understand SCIM data structures
//! - **Multi-Tenant Support**: Tenant-aware operations for enterprise scenarios
//! - **Version-Based Concurrency Control**: Built-in optimistic locking prevents lost updates
//! - **Error Handling**: Structured error responses for AI decision making
//! - **Real-time Operations**: Async operations suitable for AI workflows
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
//! │ AI Agent │───▶│ MCP Protocol │───▶│ SCIM Server │
//! │ (Client) │ │ (This Module) │ │ (Operations) │
//! └─────────────────┘ └──────────────────┘ └─────────────────┘
//! │ │ │
//! ▼ ▼ ▼
//! Tool Discovery Tool Execution Resource Management
//! Schema Learning JSON Validation Provider Integration
//! Error Handling Tenant Context Multi-Tenant Isolation
//! ```
//!
//! ## Module Structure
//!
//! - `core` - Core types and infrastructure (McpServerInfo, ScimToolResult, ScimMcpServer)
//! - `protocol` - Tool discovery and dispatch functionality
//! - `tools/` - JSON schema definitions for MCP tool discovery
//! - `user_schemas` - User operation tool schemas
//! - `system_schemas` - System information tool schemas
//! - `handlers/` - Tool execution handlers
//! - `user_crud` - User CRUD operation handlers
//! - `user_queries` - User query and search handlers
//! - `system_info` - System metadata handlers
//!
//! ## Usage Example
//!
//! ```rust,no_run
//! # #[cfg(feature = "mcp")]
//! use scim_server::{ScimServer, mcp_integration::ScimMcpServer, providers::StandardResourceProvider};
//! use scim_server::storage::InMemoryStorage;
//! use serde_json::json;
//!
//! # #[cfg(feature = "mcp")]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create SCIM server
//! let storage = InMemoryStorage::new();
//! let provider = StandardResourceProvider::new(storage);
//! let scim_server = ScimServer::new(provider)?;
//!
//! // Create MCP server
//! let mcp_server = ScimMcpServer::new(scim_server);
//!
//! // Execute tool (simulating AI agent)
//! let result = mcp_server.execute_tool(
//! "scim_create_user",
//! json!({
//! "user_data": {
//! "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
//! "userName": "ai.agent@company.com",
//! "active": true
//! }
//! })
//! ).await;
//!
//! if result.success {
//! println!("User created successfully");
//! }
//! Ok(())
//! }
//! ```
// Re-export core types for convenience
pub use ;
// Protocol functions are accessed through ScimMcpServer methods
// No need to re-export protocol internals