iflow-mcp_alpadalar-active-directory-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/LICENSE +21 -0
  2. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/PKG-INFO +620 -0
  3. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/README.md +573 -0
  4. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/pyproject.toml +104 -0
  5. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/setup.cfg +4 -0
  6. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/setup.py +15 -0
  7. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/__init__.py +15 -0
  8. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/config/__init__.py +21 -0
  9. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/config/loader.py +101 -0
  10. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/config/models.py +101 -0
  11. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/core/__init__.py +6 -0
  12. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/core/ldap_manager.py +423 -0
  13. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/core/logging.py +103 -0
  14. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/server.py +508 -0
  15. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/server_http.py +461 -0
  16. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/__init__.py +17 -0
  17. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/base.py +198 -0
  18. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/computer.py +777 -0
  19. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/definitions.py +421 -0
  20. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/group.py +626 -0
  21. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/organizational_unit.py +813 -0
  22. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/security.py +888 -0
  23. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/active_directory_mcp/tools/user.py +650 -0
  24. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/iflow_mcp_alpadalar_active_directory_mcp.egg-info/PKG-INFO +620 -0
  25. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/iflow_mcp_alpadalar_active_directory_mcp.egg-info/SOURCES.txt +36 -0
  26. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/iflow_mcp_alpadalar_active_directory_mcp.egg-info/dependency_links.txt +1 -0
  27. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/iflow_mcp_alpadalar_active_directory_mcp.egg-info/entry_points.txt +2 -0
  28. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/iflow_mcp_alpadalar_active_directory_mcp.egg-info/requires.txt +22 -0
  29. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/src/iflow_mcp_alpadalar_active_directory_mcp.egg-info/top_level.txt +1 -0
  30. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_computer_tools.py +583 -0
  31. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_config.py +177 -0
  32. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_group_tools.py +576 -0
  33. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_integration.py +839 -0
  34. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_ldap_manager.py +278 -0
  35. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_organizational_unit_tools.py +621 -0
  36. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_performance.py +647 -0
  37. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_security_tools.py +594 -0
  38. iflow_mcp_alpadalar_active_directory_mcp-0.1.0/tests/test_user_tools.py +399 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Alperen Adalar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,620 @@
1
+ Metadata-Version: 2.4
2
+ Name: iflow-mcp_alpadalar-active-directory-mcp
3
+ Version: 0.1.0
4
+ Summary: A Model Context Protocol server for interacting with Active Directory
5
+ Author-email: Alperen Adalar <alp.adalar@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/alpadalar/ActiveDirectoryMCP
8
+ Project-URL: Documentation, https://github.com/alpadalar/ActiveDirectoryMCP#readme
9
+ Project-URL: Repository, https://github.com/alpadalar/ActiveDirectoryMCP.git
10
+ Project-URL: Issues, https://github.com/alpadalar/ActiveDirectoryMCP/issues
11
+ Keywords: active-directory,mcp,ldap,ad,authentication,directory-services
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Systems Administration
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: mcp>=0.9.0
26
+ Requires-Dist: ldap3<3.0.0,>=2.9.1
27
+ Requires-Dist: requests<3.0.0,>=2.31.0
28
+ Requires-Dist: pydantic<3.0.0,>=2.0.0
29
+ Requires-Dist: fastmcp>=0.2.0
30
+ Requires-Dist: asgiref>=3.7.0
31
+ Requires-Dist: cryptography<42.0.0,>=41.0.0
32
+ Requires-Dist: python-dateutil<3.0.0,>=2.8.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest<8.0.0,>=7.0.0; extra == "dev"
35
+ Requires-Dist: black<24.0.0,>=23.0.0; extra == "dev"
36
+ Requires-Dist: mypy<2.0.0,>=1.0.0; extra == "dev"
37
+ Requires-Dist: pytest-asyncio<0.22.0,>=0.21.0; extra == "dev"
38
+ Requires-Dist: ruff<0.2.0,>=0.1.0; extra == "dev"
39
+ Requires-Dist: types-requests<3.0.0,>=2.31.0; extra == "dev"
40
+ Requires-Dist: pytest-mock<4.0.0,>=3.11.0; extra == "dev"
41
+ Provides-Extra: django
42
+ Requires-Dist: django<5.0.0,>=4.0.0; extra == "django"
43
+ Requires-Dist: djangorestframework>=3.14.0; extra == "django"
44
+ Requires-Dist: pyjwt>=2.8.0; extra == "django"
45
+ Dynamic: license-file
46
+ Dynamic: requires-python
47
+
48
+ # ActiveDirectoryMCP - Enhanced Active Directory MCP Server
49
+
50
+ A comprehensive Python-based Model Context Protocol (MCP) server for managing Active Directory environments through LDAP. This project provides powerful tools for user management, group operations, computer account management, organizational unit administration, and security auditing.
51
+
52
+ ## 🚀 Features
53
+
54
+ ### 👥 **Complete User Management**
55
+ - Create, modify, and delete user accounts
56
+ - Password management and reset functionality
57
+ - Enable/disable user accounts
58
+ - Group membership analysis
59
+ - User permission auditing
60
+
61
+ ### 🔐 **Advanced Group Management**
62
+ - Create and manage security and distribution groups
63
+ - Group scope management (Global, DomainLocal, Universal)
64
+ - Member addition and removal
65
+ - Nested group analysis
66
+ - Group membership reporting
67
+
68
+ ### 💻 **Computer Account Management**
69
+ - Create and manage computer objects
70
+ - Computer account lifecycle management
71
+ - Stale computer detection
72
+ - Computer group memberships
73
+ - Service Principal Name management
74
+
75
+ ### 🏢 **Organizational Unit Operations**
76
+ - Create, modify, and delete OUs
77
+ - OU hierarchy management
78
+ - Move objects between OUs
79
+ - OU content analysis
80
+ - Group Policy link information
81
+
82
+ ### 🛡️ **Security and Audit Tools**
83
+ - Domain security policy analysis
84
+ - Privileged group monitoring
85
+ - Inactive user detection
86
+ - Password policy compliance checking
87
+ - Administrative account auditing
88
+ - Permission analysis and reporting
89
+
90
+ ### 🌐 **Multiple Transport Options**
91
+ - **Stdio Transport**: Traditional MCP communication
92
+ - **HTTP Transport**: FastMCP-based HTTP transport on port 8813
93
+ - **Docker Deployment**: Production-ready containerization
94
+ - **MCP Inspector**: Compatible with debugging tools
95
+
96
+ ### 🧪 **Quality Assurance**
97
+ - **129/129 Tests Passing**: 100% test success rate across all modules
98
+ - **Complete Test Coverage**: All 5 tool modules fully tested
99
+ - **LDAP3 Compatible**: Latest library compatibility ensured
100
+ - **Production Ready**: Thoroughly tested and validated
101
+ - **Enterprise Testing**: Unit, Integration, and Performance tests
102
+ - **Comprehensive Coverage**: Config, LDAP, tools, workflows, and performance
103
+ - **Samba AD Test Environment**: Real AD protocols for testing
104
+
105
+ ## 📋 Prerequisites
106
+
107
+ - Python 3.9 or higher
108
+ - UV package manager (recommended) or pip
109
+ - Access to Active Directory with appropriate permissions
110
+ - LDAP/LDAPS connectivity to domain controllers
111
+
112
+ ## 🛠️ Installation
113
+
114
+ ### Option 1: Quick Install (Recommended)
115
+
116
+ 1. **Clone and set up environment:**
117
+ ```bash
118
+ # Clone repository
119
+ git clone https://github.com/alpadalar/ActiveDirectoryMCP.git
120
+ cd ActiveDirectoryMCP
121
+
122
+ # Create and activate virtual environment
123
+ uv venv
124
+ source .venv/bin/activate # Linux/macOS
125
+ # OR
126
+ .\.venv\Scripts\Activate.ps1 # Windows
127
+ ```
128
+
129
+ 2. **Install dependencies:**
130
+ ```bash
131
+ # Install with development dependencies
132
+ uv pip install -e ".[dev]"
133
+ ```
134
+
135
+ 3. **Create configuration:**
136
+ ```bash
137
+ # Create config directory and copy template
138
+ mkdir -p ad-config
139
+ cp ad-config/config.example.json ad-config/config.json
140
+ ```
141
+
142
+ 4. **Configure Active Directory connection:**
143
+ ```json
144
+ {
145
+ "active_directory": {
146
+ "server": "ldap://dc.example.com:389",
147
+ "domain": "example.com",
148
+ "base_dn": "DC=example,DC=com",
149
+ "bind_dn": "CN=service-account,OU=Service Accounts,DC=example,DC=com",
150
+ "password": "your-service-account-password"
151
+ },
152
+ "organizational_units": {
153
+ "users_ou": "OU=Users,DC=example,DC=com",
154
+ "groups_ou": "OU=Groups,DC=example,DC=com",
155
+ "computers_ou": "OU=Computers,DC=example,DC=com",
156
+ "service_accounts_ou": "OU=Service Accounts,DC=example,DC=com"
157
+ }
158
+ }
159
+ ```
160
+
161
+ ### Verifying Installation
162
+
163
+ ```bash
164
+ # Test configuration
165
+ python -c "import active_directory_mcp; print('Installation OK')"
166
+
167
+ # Run tests
168
+ pytest
169
+
170
+ # Test LDAP connection
171
+ AD_MCP_CONFIG="ad-config/ad-config.json" python -m active_directory_mcp.server
172
+ ```
173
+
174
+ ## 🚀 Running the Server
175
+
176
+ ### 🏭 Production Deployment
177
+
178
+ Deploy to production with existing Active Directory:
179
+
180
+ ```bash
181
+ # 1. Configure for your AD environment
182
+ cp ad-config/production-config.example.json ad-config/ad-config.json
183
+ # Edit ad-config.json with your AD server details
184
+
185
+ # 2. Deploy ActiveDirectoryMCP
186
+ docker compose up -d
187
+
188
+ # 3. Verify deployment
189
+ docker compose ps
190
+ docker compose logs activedirectory-mcp
191
+ ```
192
+
193
+ **🌐 Production URL:** `http://localhost:8813/activedirectory-mcp`
194
+
195
+ **Production Features:**
196
+ - ✅ Connects to existing AD infrastructure
197
+ - ✅ SSL/TLS security
198
+ - ✅ Resource limits & health checks
199
+ - ✅ Production logging
200
+
201
+ ### 🧪 Development/Test Environment
202
+
203
+ For development with included test LDAP server:
204
+
205
+ ```bash
206
+ # 1. Start test environment
207
+ docker compose -f docker-compose-ad.yml up -d
208
+
209
+ # 2. Test the setup
210
+ python test_ad_environment.py
211
+
212
+ # 3. Access services
213
+ # - ActiveDirectoryMCP: http://localhost:8813/activedirectory-mcp
214
+ # - LDAP Admin: http://localhost:8080
215
+ ```
216
+
217
+ **Test Features:**
218
+ - ✅ Includes OpenLDAP test server
219
+ - ✅ Pre-configured test data
220
+ - ✅ Web-based LDAP management
221
+ - ✅ No external AD required
222
+
223
+ ### Development Mode (Stdio)
224
+
225
+ For testing and development with stdio transport:
226
+
227
+ ```bash
228
+ # Start stdio server
229
+ ./start_server.sh
230
+
231
+ # Or with custom config
232
+ AD_MCP_CONFIG="ad-config/ad-config.json" python -m active_directory_mcp.server
233
+ ```
234
+
235
+ ### HTTP Mode (Local Development)
236
+
237
+ For local HTTP transport development:
238
+
239
+ ```bash
240
+ # Start HTTP server
241
+ ./start_http_server.sh
242
+
243
+ # Or with custom settings
244
+ python -m active_directory_mcp.server_http --host 0.0.0.0 --port 8813 --path /activedirectory-mcp
245
+ ```
246
+
247
+ ## 🔧 Cursor/VS Code Integration
248
+
249
+ ### Option 1: Docker Compose (Recommended)
250
+
251
+ ```json
252
+ {
253
+ "mcpServers": {
254
+ "ActiveDirectoryMCP": {
255
+ "transport": {
256
+ "type": "http",
257
+ "url": "http://localhost:8813/activedirectory-mcp"
258
+ },
259
+ "description": "Active Directory Management with HTTP Transport"
260
+ }
261
+ }
262
+ }
263
+ ```
264
+
265
+ ### Option 2: Local HTTP Server
266
+
267
+ ```json
268
+ {
269
+ "mcpServers": {
270
+ "ActiveDirectoryMCP-Local": {
271
+ "transport": {
272
+ "type": "http",
273
+ "url": "http://localhost:8813/activedirectory-mcp"
274
+ },
275
+ "description": "ActiveDirectoryMCP Local Development"
276
+ }
277
+ }
278
+ }
279
+ ```
280
+
281
+ ### Option 3: Traditional Stdio (Legacy)
282
+
283
+ ```json
284
+ {
285
+ "mcpServers": {
286
+ "ActiveDirectoryMCP": {
287
+ "command": "/absolute/path/to/ActiveDirectoryMCP/.venv/bin/python",
288
+ "args": ["-m", "active_directory_mcp.server"],
289
+ "cwd": "/absolute/path/to/ActiveDirectoryMCP",
290
+ "env": {
291
+ "PYTHONPATH": "/absolute/path/to/ActiveDirectoryMCP/src",
292
+ "AD_MCP_CONFIG": "/absolute/path/to/ActiveDirectoryMCP/ad-config/ad-config.json"
293
+ },
294
+ "disabled": false
295
+ }
296
+ }
297
+ }
298
+ ```
299
+
300
+ ## 📚 Available Tools & Operations
301
+
302
+ ### 👥 User Management
303
+ - `list_users` - List users with filtering and attributes
304
+ - `get_user` - Get detailed user information
305
+ - `create_user` - Create new user accounts
306
+ - `modify_user` - Update user attributes
307
+ - `delete_user` - Remove user accounts
308
+ - `enable_user` / `disable_user` - Account status management
309
+ - `reset_user_password` - Password reset functionality
310
+ - `get_user_groups` - Group membership analysis
311
+
312
+ ### 🔐 Group Management
313
+ - `list_groups` - List groups with filtering
314
+ - `get_group` - Get detailed group information
315
+ - `create_group` - Create security/distribution groups
316
+ - `modify_group` - Update group attributes
317
+ - `delete_group` - Remove groups
318
+ - `add_group_member` / `remove_group_member` - Membership management
319
+ - `get_group_members` - Member listing with recursion
320
+
321
+ ### 💻 Computer Management
322
+ - `list_computers` - List computer accounts
323
+ - `get_computer` - Get computer details
324
+ - `create_computer` - Create computer objects
325
+ - `modify_computer` - Update computer attributes
326
+ - `delete_computer` - Remove computer accounts
327
+ - `enable_computer` / `disable_computer` - Account management
328
+ - `reset_computer_password` - Password reset
329
+ - `get_stale_computers` - Find inactive computers
330
+
331
+ ### 🏢 Organizational Unit Management
332
+ - `list_organizational_units` - List OUs with hierarchy
333
+ - `get_organizational_unit` - Get OU details
334
+ - `create_organizational_unit` - Create new OUs
335
+ - `modify_organizational_unit` - Update OU attributes
336
+ - `delete_organizational_unit` - Remove OUs
337
+ - `move_organizational_unit` - Move OUs
338
+ - `get_organizational_unit_contents` - List OU contents
339
+
340
+ ### 🛡️ Security & Audit
341
+ - `get_domain_info` - Domain security settings
342
+ - `get_privileged_groups` - Privileged group analysis
343
+ - `get_user_permissions` - User permission analysis
344
+ - `get_inactive_users` - Inactive user detection
345
+ - `get_password_policy_violations` - Policy compliance
346
+ - `audit_admin_accounts` - Administrative account audit
347
+
348
+ ### 🔧 System Tools
349
+ - `test_connection` - LDAP connectivity test
350
+ - `health` - Server health check
351
+ - `get_schema_info` - Tool schema information
352
+
353
+ > **⚠️ Note**: ActiveDirectoryMCP provides 42 tools total. Some LLM models may experience issues with this many tools.
354
+
355
+ ## 🔒 Security Configuration
356
+
357
+ ### Service Account Setup
358
+
359
+ 1. Create a dedicated service account in AD
360
+ 2. Grant minimum required permissions:
361
+ - Read access to domain
362
+ - User/Group/Computer management permissions
363
+ - Password reset permissions (if needed)
364
+
365
+ ### SSL/TLS Configuration
366
+
367
+ ```json
368
+ {
369
+ "active_directory": {
370
+ "server": "ldaps://dc.example.com:636",
371
+ "use_ssl": true
372
+ },
373
+ "security": {
374
+ "enable_tls": true,
375
+ "validate_certificate": true,
376
+ "ca_cert_file": "/path/to/ca-certificate.pem"
377
+ }
378
+ }
379
+ ```
380
+
381
+ ### Connection Pool Configuration
382
+
383
+ ```json
384
+ {
385
+ "performance": {
386
+ "connection_pool_size": 10,
387
+ "max_retries": 3,
388
+ "retry_delay": 1.0,
389
+ "page_size": 1000
390
+ }
391
+ }
392
+ ```
393
+
394
+ ## 🧪 Testing
395
+
396
+ **✅ All Tests Passing (129/129)** - Production Ready!
397
+
398
+ ### Quick Test Status
399
+ - **Configuration Tests**: 8/8 ✅
400
+ - **User Tools Tests**: 13/13 ✅
401
+ - **Group Tools Tests**: 17/17 ✅
402
+ - **Computer Tools Tests**: 18/18 ✅
403
+ - **Security Tools Tests**: 14/14 ✅
404
+ - **OU Tools Tests**: 18/18 ✅
405
+ - **LDAP Manager Tests**: 12/12 ✅
406
+ - **Integration Tests**: 20/20 ✅ (End-to-end workflows)
407
+ - **Performance Tests**: 9/9 ✅ (Load & stress testing)
408
+ - **Total**: 129/129 tests passing
409
+
410
+ ### Run Unit Tests
411
+ ```bash
412
+ # Run all tests with verbose output
413
+ pytest -v
414
+
415
+ # Run specific test categories
416
+ pytest tests/test_config.py -v # Configuration tests
417
+ pytest tests/test_ldap_manager.py -v # LDAP manager tests
418
+ pytest tests/test_user_tools.py -v # User management tests
419
+ pytest tests/test_group_tools.py -v # Group management tests
420
+ pytest tests/test_computer_tools.py -v # Computer management tests
421
+ pytest tests/test_security_tools.py -v # Security & audit tests
422
+ pytest tests/test_organizational_unit_tools.py -v # OU management tests
423
+ pytest tests/test_integration.py -v # End-to-end workflow tests
424
+ pytest tests/test_performance.py -v # Performance & load tests
425
+ ```
426
+
427
+ ### Test HTTP Server
428
+ ```bash
429
+ # Test HTTP endpoints directly
430
+ python test_scripts/test_http_server.py
431
+
432
+ # Custom server URL
433
+ python test_scripts/test_http_server.py http://your-server:8813/activedirectory-mcp
434
+ ```
435
+
436
+ ### Run Integration Tests
437
+ ```bash
438
+ # Test with real AD connection (requires config)
439
+ AD_MCP_CONFIG="ad-config/ad-config.json" pytest tests/test_integration.py -v
440
+ ```
441
+
442
+ ### Run Performance Tests
443
+ ```bash
444
+ # Run performance and load tests
445
+ pytest tests/test_performance.py -v
446
+
447
+ # Run specific performance categories
448
+ pytest tests/test_performance.py::TestLargeDatasetPerformance -v # Large dataset handling
449
+ pytest tests/test_performance.py::TestConcurrentOperations -v # Concurrent operations
450
+ pytest tests/test_performance.py::TestMemoryAndResourceUsage -v # Memory usage tests
451
+ pytest tests/test_performance.py::TestStressScenarios -v # Stress testing
452
+
453
+ # Performance test features:
454
+ # - Large dataset performance (10K+ users/groups)
455
+ # - Concurrent operation testing (50+ simultaneous queries)
456
+ # - Memory usage validation
457
+ # - Sustained load scenarios
458
+ # - Connection pooling efficiency
459
+ ```
460
+
461
+ ### 🏢 Test with LDAP/AD Environment (Recommended)
462
+ ```bash
463
+ # Start LDAP/AD test environment
464
+ docker-compose -f docker-compose-ad.yml up -d
465
+
466
+ # Wait for services to be ready (30 seconds)
467
+ docker logs -f openldap-ad-dc
468
+
469
+ # Test ActiveDirectoryMCP with test environment
470
+ python test_ad_environment.py
471
+
472
+ # Expected output:
473
+ # ✅ Connected to LDAP: 192.168.1.100:389
474
+ # ✅ MCP Config: SUCCESS
475
+ # ✅ HTTP API: SUCCESS
476
+ # 🎉 Test environment ready!
477
+ ```
478
+
479
+ **Test Environment Features:**
480
+ - 🔗 LDAP Directory Service with AD-style structure
481
+ - 👥 Test users: admin, jdoe, jsmith, mwilson, testadmin
482
+ - 🔐 Test groups: IT Department, Sales Team, Marketing, All Users
483
+ - 🖥️ Web Admin: http://localhost:8080 (cn=admin,dc=test,dc=local / Admin123!)
484
+ - 📚 Full testing guide: [TESTING_GUIDE.md](TESTING_GUIDE.md)
485
+
486
+ ### Test HTTP API
487
+ ```bash
488
+ # Health check
489
+ curl -X POST "http://localhost:8813/activedirectory-mcp" \
490
+ -H "Content-Type: application/json" \
491
+ -d '{"method": "health", "params": {}}'
492
+
493
+ # List users
494
+ curl -X POST "http://localhost:8813/activedirectory-mcp" \
495
+ -H "Content-Type: application/json" \
496
+ -d '{"method": "list_users", "params": {"ou": "OU=Users,DC=example,DC=com"}}'
497
+ ```
498
+
499
+ ## 📊 Project Structure
500
+
501
+ ```
502
+ ActiveDirectoryMCP/
503
+ ├── 📁 src/ # Source code
504
+ │ └── active_directory_mcp/
505
+ │ ├── server.py # Main MCP server (stdio)
506
+ │ ├── server_http.py # HTTP MCP server
507
+ │ ├── config/ # Configuration handling
508
+ │ ├── core/ # Core functionality
509
+ │ │ ├── ldap_manager.py # LDAP connection manager
510
+ │ │ └── logging.py # Logging configuration
511
+ │ └── tools/ # Tool implementations
512
+ │ ├── user.py # User management
513
+ │ ├── group.py # Group management
514
+ │ ├── computer.py # Computer management
515
+ │ ├── organizational_unit.py # OU management
516
+ │ └── security.py # Security & audit tools
517
+
518
+ ├── 📁 tests/ # Comprehensive test suite (129 tests)
519
+ │ ├── test_config.py # Configuration tests (8)
520
+ │ ├── test_ldap_manager.py # LDAP manager tests (12)
521
+ │ ├── test_user_tools.py # User management tests (13)
522
+ │ ├── test_group_tools.py # Group management tests (17)
523
+ │ ├── test_computer_tools.py # Computer management tests (18)
524
+ │ ├── test_security_tools.py # Security & audit tests (14)
525
+ │ ├── test_organizational_unit_tools.py # OU management tests (18)
526
+ │ ├── test_integration.py # End-to-end workflow tests (20)
527
+ │ └── test_performance.py # Performance & load tests (9)
528
+ ├── 📁 ad-config/ # Configuration files
529
+ │ ├── ad-config.json # Main server configuration
530
+ │ ├── config.example.json # Example configuration
531
+ │ └── production-config.example.json # Production example
532
+
533
+ ├── 📄 Configuration Files
534
+ │ ├── pyproject.toml # Project metadata
535
+ │ ├── docker-compose.yml # Production deployment
536
+ │ ├── docker-compose-ad.yml # Test environment with LDAP
537
+ │ ├── Dockerfile # Container definition
538
+ │ └── requirements.in # Dependencies
539
+
540
+ └── 📄 Scripts
541
+ ├── start_server.sh # Stdio server launcher
542
+ └── start_http_server.sh # HTTP server launcher
543
+ ```
544
+
545
+ ## 🔍 Troubleshooting
546
+
547
+ ### ✅ Recent Fixes (v0.1.0)
548
+ - **LDAP3 Compatibility**: Fixed TLS configuration compatibility with latest ldap3 library
549
+ - **Test Suite**: All 43 tests now passing successfully (100% success rate)
550
+ - **Mock Issues**: Resolved integration test mocking for error scenarios
551
+ - **Security Config**: Removed deprecated LDAP parameters for better compatibility
552
+
553
+ ### Common Issues
554
+
555
+ 1. **LDAP Connection Failed**
556
+ ```bash
557
+ # Test connectivity
558
+ ldapsearch -H ldap://dc.example.com -D "CN=user,DC=example,DC=com" -W -b "DC=example,DC=com" "(objectClass=domain)"
559
+ ```
560
+
561
+ 2. **Permission Denied**
562
+ - Verify service account permissions
563
+ - Check OU access rights
564
+ - Ensure proper LDAP bind DN
565
+
566
+ 3. **SSL/TLS Issues**
567
+ ```bash
568
+ # Test SSL connection
569
+ openssl s_client -connect dc.example.com:636 -showcerts
570
+ ```
571
+
572
+ 4. **Port Already in Use**
573
+ ```bash
574
+ # Check port usage
575
+ netstat -tlnp | grep 8813
576
+ # Change port if needed
577
+ HTTP_PORT=8814 ./start_http_server.sh
578
+ ```
579
+
580
+ 5. **⚠️ LLM Tool Limit Warning**
581
+
582
+ Some LLM models may experience issues with 40+ tools in context.
583
+
584
+ ### View Logs
585
+ ```bash
586
+ # Container logs
587
+ docker logs activedirectory-mcp -f
588
+
589
+ # Local logs
590
+ tail -f active_directory_mcp.log
591
+ ```
592
+
593
+ ## 🤝 Contributing
594
+
595
+ 1. Fork the repository
596
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
597
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
598
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
599
+ 5. Open a Pull Request
600
+
601
+ ## 📄 License
602
+
603
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
604
+
605
+ ## 🙏 Acknowledgments
606
+
607
+ - Inspired by [ProxmoxMCP-Extended](https://github.com/alpadalar/ProxmoxMCP-Extended)
608
+ - Built with the Model Context Protocol (MCP) SDK
609
+ - LDAP integration powered by ldap3 library
610
+ - FastMCP for HTTP transport capabilities
611
+
612
+ ---
613
+
614
+ **✅ Production Ready!** 🎉 Your comprehensive Active Directory MCP service is fully tested (129/129 tests passing) and ready for production deployment with complete HTTP transport support, performance validation, and enterprise-grade reliability.
615
+
616
+ ## 🔗 Related Projects
617
+
618
+ - [ProxmoxMCP-Extended](https://github.com/alpadalar/ProxmoxMCP-Extended) - Proxmox virtualization management
619
+ - [Model Context Protocol](https://github.com/modelcontextprotocol) - Official MCP documentation
620
+ - [FastMCP](https://github.com/modelcontextprotocol/fastmcp) - FastMCP for HTTP transport