mcp-code-indexer 1.9.1__tar.gz → 2.0.1__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 (46) hide show
  1. {mcp_code_indexer-1.9.1/src/mcp_code_indexer.egg-info → mcp_code_indexer-2.0.1}/PKG-INFO +68 -15
  2. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/README.md +67 -14
  3. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/docs/api-reference.md +131 -0
  4. mcp_code_indexer-2.0.1/docs/database-resilience.md +397 -0
  5. mcp_code_indexer-2.0.1/docs/monitoring.md +738 -0
  6. mcp_code_indexer-2.0.1/docs/performance-tuning.md +554 -0
  7. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/pyproject.toml +1 -1
  8. mcp_code_indexer-2.0.1/src/mcp_code_indexer/database/connection_health.py +441 -0
  9. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/database/database.py +361 -26
  10. mcp_code_indexer-2.0.1/src/mcp_code_indexer/database/retry_handler.py +344 -0
  11. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/logging_config.py +29 -0
  12. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/middleware/error_middleware.py +41 -0
  13. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/server/mcp_server.py +56 -2
  14. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1/src/mcp_code_indexer.egg-info}/PKG-INFO +68 -15
  15. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer.egg-info/SOURCES.txt +5 -0
  16. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/LICENSE +0 -0
  17. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/MANIFEST.in +0 -0
  18. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/docs/architecture.md +0 -0
  19. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/docs/configuration.md +0 -0
  20. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/docs/contributing.md +0 -0
  21. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/docs/git-hook-setup.md +0 -0
  22. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/migrations/001_initial.sql +0 -0
  23. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/migrations/002_performance_indexes.sql +0 -0
  24. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/migrations/003_project_overviews.sql +0 -0
  25. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/requirements.txt +0 -0
  26. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/setup.cfg +0 -0
  27. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/setup.py +0 -0
  28. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/__init__.py +0 -0
  29. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/__main__.py +0 -0
  30. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/data/stop_words_english.txt +0 -0
  31. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/database/__init__.py +0 -0
  32. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/database/models.py +0 -0
  33. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/error_handler.py +0 -0
  34. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/file_scanner.py +0 -0
  35. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/git_hook_handler.py +0 -0
  36. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/main.py +0 -0
  37. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/merge_handler.py +0 -0
  38. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/middleware/__init__.py +0 -0
  39. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/server/__init__.py +0 -0
  40. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 +0 -0
  41. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/token_counter.py +0 -0
  42. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer/tools/__init__.py +0 -0
  43. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer.egg-info/dependency_links.txt +0 -0
  44. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer.egg-info/entry_points.txt +0 -0
  45. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer.egg-info/requires.txt +0 -0
  46. {mcp_code_indexer-1.9.1 → mcp_code_indexer-2.0.1}/src/mcp_code_indexer.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-code-indexer
3
- Version: 1.9.1
3
+ Version: 2.0.1
4
4
  Summary: MCP server that tracks file descriptions across codebases, enabling AI agents to efficiently navigate and understand code through searchable summaries and token-aware overviews.
5
5
  Author: MCP Code Indexer Contributors
6
6
  Maintainer: MCP Code Indexer Contributors
@@ -59,11 +59,11 @@ Dynamic: requires-python
59
59
 
60
60
  # MCP Code Indexer 🚀
61
61
 
62
- [![PyPI version](https://badge.fury.io/py/mcp-code-indexer.svg?10)](https://badge.fury.io/py/mcp-code-indexer)
63
- [![Python](https://img.shields.io/pypi/pyversions/mcp-code-indexer.svg?10)](https://pypi.org/project/mcp-code-indexer/)
62
+ [![PyPI version](https://badge.fury.io/py/mcp-code-indexer.svg?12)](https://badge.fury.io/py/mcp-code-indexer)
63
+ [![Python](https://img.shields.io/pypi/pyversions/mcp-code-indexer.svg?12)](https://pypi.org/project/mcp-code-indexer/)
64
64
  [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
65
65
 
66
- A production-ready **Model Context Protocol (MCP) server** that revolutionizes how AI agents navigate and understand codebases. Instead of repeatedly scanning files, agents get instant access to intelligent descriptions, semantic search, and context-aware recommendations.
66
+ A production-ready **Model Context Protocol (MCP) server** that revolutionizes how AI agents navigate and understand codebases. Built for high-concurrency environments with advanced database resilience, the server provides instant access to intelligent descriptions, semantic search, and context-aware recommendations while maintaining 800+ writes/sec throughput.
67
67
 
68
68
  ## 🎯 What It Does
69
69
 
@@ -227,7 +227,7 @@ mypy src/
227
227
 
228
228
  ## 🛠️ MCP Tools Available
229
229
 
230
- The server provides **11 powerful MCP tools** for intelligent codebase management. Whether you're an AI agent or human developer, these tools make navigating code effortless.
230
+ The server provides **12 powerful MCP tools** for intelligent codebase management. Whether you're an AI agent or human developer, these tools make navigating code effortless.
231
231
 
232
232
  ### 🎯 For Everyone: Start Here
233
233
  - **`check_codebase_size`** - Get instant recommendations for how to navigate your codebase
@@ -246,6 +246,9 @@ The server provides **11 powerful MCP tools** for intelligent codebase managemen
246
246
  - **`merge_branch_descriptions`** - Two-phase merge with conflict resolution
247
247
  - **`update_codebase_overview`** - Create comprehensive codebase documentation
248
248
 
249
+ ### 🏥 For System Monitoring: Health & Performance
250
+ - **`check_database_health`** - Real-time database health monitoring and diagnostics
251
+
249
252
  💡 **Pro Tip**: Always start with `check_codebase_size` to get personalized recommendations for navigating your specific codebase.
250
253
 
251
254
  ## 🔗 Git Hook Integration
@@ -272,24 +275,29 @@ See the **[Git Hook Setup Guide](docs/git-hook-setup.md)** for complete installa
272
275
 
273
276
  ## 🏗️ Architecture Highlights
274
277
 
275
- ### Performance Optimized
276
- - **SQLite with WAL mode** for high-concurrency access
277
- - **Connection pooling** for efficient database operations
278
- - **FTS5 full-text search** with prefix indexing
278
+ ### 🚀 Performance Optimized
279
+ - **SQLite with WAL mode** for high-concurrency access (800+ writes/sec)
280
+ - **Smart connection pooling** with optimized pool size (3 connections default)
281
+ - **FTS5 full-text search** with prefix indexing for sub-100ms queries
279
282
  - **Token-aware caching** to minimize expensive operations
283
+ - **Write operation serialization** to eliminate database lock conflicts
280
284
 
281
- ### Production Ready
282
- - **Comprehensive error handling** with structured JSON logging
285
+ ### 🛡️ Production Ready
286
+ - **Database resilience features** with <2% error rate under high load
287
+ - **Exponential backoff retry logic** with intelligent failure recovery
288
+ - **Comprehensive health monitoring** with automatic pool refresh
289
+ - **Structured JSON logging** with performance metrics tracking
283
290
  - **Async-first design** with proper resource cleanup
284
291
  - **MCP protocol compliant** with clean stdio streams
285
292
  - **Upstream inheritance** for fork workflows
286
293
  - **Git integration** with .gitignore support
287
294
 
288
- ### Developer Friendly
289
- - **95%+ test coverage** with async support
290
- - **Integration tests** for complete workflows
291
- - **Performance benchmarks** for large codebases
295
+ ### 👨‍💻 Developer Friendly
296
+ - **95%+ test coverage** with async support and concurrent access tests
297
+ - **Integration tests** for complete workflows including database stress testing
298
+ - **Performance benchmarks** for large codebases with resilience validation
292
299
  - **Clear error messages** with MCP protocol compliance
300
+ - **Comprehensive configuration options** for production tuning
293
301
 
294
302
  ## 📖 Documentation
295
303
 
@@ -300,6 +308,11 @@ See the **[Git Hook Setup Guide](docs/git-hook-setup.md)** for complete installa
300
308
  ### 👨‍💻 For Developers
301
309
  - **[API Reference](docs/api-reference.md)** - Complete MCP tool documentation with examples
302
310
  - **[Architecture Overview](docs/architecture.md)** - Technical deep dive into system design
311
+ - **[Database Resilience Guide](docs/database-resilience.md)** - Advanced database optimization and monitoring
312
+
313
+ ### 🔧 For System Administrators
314
+ - **[Performance Tuning Guide](docs/performance-tuning.md)** - High-concurrency deployment optimization
315
+ - **[Monitoring & Diagnostics](docs/monitoring.md)** - Production monitoring setup and troubleshooting
303
316
 
304
317
  ### 🤝 For Contributors
305
318
  - **[Contributing Guide](docs/contributing.md)** - Development setup and workflow guidelines
@@ -321,6 +334,8 @@ Tested with codebases up to **10,000 files**:
321
334
 
322
335
  ## 🔧 Advanced Configuration
323
336
 
337
+ ### 👨‍💻 For Developers: Basic Configuration
338
+
324
339
  ```bash
325
340
  # Production setup with custom limits
326
341
  mcp-code-indexer \
@@ -334,6 +349,44 @@ export MCP_LOG_FORMAT=json
334
349
  mcp-code-indexer
335
350
  ```
336
351
 
352
+ ### 🔧 For System Administrators: Database Resilience Tuning
353
+
354
+ Configure advanced database resilience features for high-concurrency environments:
355
+
356
+ ```bash
357
+ # High-performance production deployment
358
+ mcp-code-indexer \
359
+ --token-limit 64000 \
360
+ --db-path /data/mcp-index.db \
361
+ --cache-dir /var/cache/mcp \
362
+ --log-level INFO \
363
+ --db-pool-size 5 \
364
+ --db-retry-count 7 \
365
+ --db-timeout 15.0 \
366
+ --enable-wal-mode \
367
+ --health-check-interval 20.0
368
+
369
+ # Environment variable configuration
370
+ export DB_POOL_SIZE=5
371
+ export DB_RETRY_COUNT=7
372
+ export DB_TIMEOUT=15.0
373
+ export DB_WAL_MODE=true
374
+ export DB_HEALTH_CHECK_INTERVAL=20.0
375
+ mcp-code-indexer --token-limit 64000
376
+ ```
377
+
378
+ #### Configuration Options
379
+
380
+ | Parameter | Default | Description | Use Case |
381
+ |-----------|---------|-------------|----------|
382
+ | `--db-pool-size` | 3 | Database connection pool size | Higher for more concurrent clients |
383
+ | `--db-retry-count` | 5 | Max retry attempts for failed operations | Increase for unstable environments |
384
+ | `--db-timeout` | 10.0 | Transaction timeout (seconds) | Increase for large operations |
385
+ | `--enable-wal-mode` | true | Enable WAL mode for concurrency | Always enable for production |
386
+ | `--health-check-interval` | 30.0 | Health monitoring interval (seconds) | Lower for faster issue detection |
387
+
388
+ 💡 **Performance Tip**: For environments with 10+ concurrent clients, use `--db-pool-size 5` and `--health-check-interval 15.0` for optimal throughput.
389
+
337
390
  ## 🤝 Integration Examples
338
391
 
339
392
  ### With AI Agents
@@ -1,10 +1,10 @@
1
1
  # MCP Code Indexer 🚀
2
2
 
3
- [![PyPI version](https://badge.fury.io/py/mcp-code-indexer.svg?10)](https://badge.fury.io/py/mcp-code-indexer)
4
- [![Python](https://img.shields.io/pypi/pyversions/mcp-code-indexer.svg?10)](https://pypi.org/project/mcp-code-indexer/)
3
+ [![PyPI version](https://badge.fury.io/py/mcp-code-indexer.svg?12)](https://badge.fury.io/py/mcp-code-indexer)
4
+ [![Python](https://img.shields.io/pypi/pyversions/mcp-code-indexer.svg?12)](https://pypi.org/project/mcp-code-indexer/)
5
5
  [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- A production-ready **Model Context Protocol (MCP) server** that revolutionizes how AI agents navigate and understand codebases. Instead of repeatedly scanning files, agents get instant access to intelligent descriptions, semantic search, and context-aware recommendations.
7
+ A production-ready **Model Context Protocol (MCP) server** that revolutionizes how AI agents navigate and understand codebases. Built for high-concurrency environments with advanced database resilience, the server provides instant access to intelligent descriptions, semantic search, and context-aware recommendations while maintaining 800+ writes/sec throughput.
8
8
 
9
9
  ## 🎯 What It Does
10
10
 
@@ -168,7 +168,7 @@ mypy src/
168
168
 
169
169
  ## 🛠️ MCP Tools Available
170
170
 
171
- The server provides **11 powerful MCP tools** for intelligent codebase management. Whether you're an AI agent or human developer, these tools make navigating code effortless.
171
+ The server provides **12 powerful MCP tools** for intelligent codebase management. Whether you're an AI agent or human developer, these tools make navigating code effortless.
172
172
 
173
173
  ### 🎯 For Everyone: Start Here
174
174
  - **`check_codebase_size`** - Get instant recommendations for how to navigate your codebase
@@ -187,6 +187,9 @@ The server provides **11 powerful MCP tools** for intelligent codebase managemen
187
187
  - **`merge_branch_descriptions`** - Two-phase merge with conflict resolution
188
188
  - **`update_codebase_overview`** - Create comprehensive codebase documentation
189
189
 
190
+ ### 🏥 For System Monitoring: Health & Performance
191
+ - **`check_database_health`** - Real-time database health monitoring and diagnostics
192
+
190
193
  💡 **Pro Tip**: Always start with `check_codebase_size` to get personalized recommendations for navigating your specific codebase.
191
194
 
192
195
  ## 🔗 Git Hook Integration
@@ -213,24 +216,29 @@ See the **[Git Hook Setup Guide](docs/git-hook-setup.md)** for complete installa
213
216
 
214
217
  ## 🏗️ Architecture Highlights
215
218
 
216
- ### Performance Optimized
217
- - **SQLite with WAL mode** for high-concurrency access
218
- - **Connection pooling** for efficient database operations
219
- - **FTS5 full-text search** with prefix indexing
219
+ ### 🚀 Performance Optimized
220
+ - **SQLite with WAL mode** for high-concurrency access (800+ writes/sec)
221
+ - **Smart connection pooling** with optimized pool size (3 connections default)
222
+ - **FTS5 full-text search** with prefix indexing for sub-100ms queries
220
223
  - **Token-aware caching** to minimize expensive operations
224
+ - **Write operation serialization** to eliminate database lock conflicts
221
225
 
222
- ### Production Ready
223
- - **Comprehensive error handling** with structured JSON logging
226
+ ### 🛡️ Production Ready
227
+ - **Database resilience features** with <2% error rate under high load
228
+ - **Exponential backoff retry logic** with intelligent failure recovery
229
+ - **Comprehensive health monitoring** with automatic pool refresh
230
+ - **Structured JSON logging** with performance metrics tracking
224
231
  - **Async-first design** with proper resource cleanup
225
232
  - **MCP protocol compliant** with clean stdio streams
226
233
  - **Upstream inheritance** for fork workflows
227
234
  - **Git integration** with .gitignore support
228
235
 
229
- ### Developer Friendly
230
- - **95%+ test coverage** with async support
231
- - **Integration tests** for complete workflows
232
- - **Performance benchmarks** for large codebases
236
+ ### 👨‍💻 Developer Friendly
237
+ - **95%+ test coverage** with async support and concurrent access tests
238
+ - **Integration tests** for complete workflows including database stress testing
239
+ - **Performance benchmarks** for large codebases with resilience validation
233
240
  - **Clear error messages** with MCP protocol compliance
241
+ - **Comprehensive configuration options** for production tuning
234
242
 
235
243
  ## 📖 Documentation
236
244
 
@@ -241,6 +249,11 @@ See the **[Git Hook Setup Guide](docs/git-hook-setup.md)** for complete installa
241
249
  ### 👨‍💻 For Developers
242
250
  - **[API Reference](docs/api-reference.md)** - Complete MCP tool documentation with examples
243
251
  - **[Architecture Overview](docs/architecture.md)** - Technical deep dive into system design
252
+ - **[Database Resilience Guide](docs/database-resilience.md)** - Advanced database optimization and monitoring
253
+
254
+ ### 🔧 For System Administrators
255
+ - **[Performance Tuning Guide](docs/performance-tuning.md)** - High-concurrency deployment optimization
256
+ - **[Monitoring & Diagnostics](docs/monitoring.md)** - Production monitoring setup and troubleshooting
244
257
 
245
258
  ### 🤝 For Contributors
246
259
  - **[Contributing Guide](docs/contributing.md)** - Development setup and workflow guidelines
@@ -262,6 +275,8 @@ Tested with codebases up to **10,000 files**:
262
275
 
263
276
  ## 🔧 Advanced Configuration
264
277
 
278
+ ### 👨‍💻 For Developers: Basic Configuration
279
+
265
280
  ```bash
266
281
  # Production setup with custom limits
267
282
  mcp-code-indexer \
@@ -275,6 +290,44 @@ export MCP_LOG_FORMAT=json
275
290
  mcp-code-indexer
276
291
  ```
277
292
 
293
+ ### 🔧 For System Administrators: Database Resilience Tuning
294
+
295
+ Configure advanced database resilience features for high-concurrency environments:
296
+
297
+ ```bash
298
+ # High-performance production deployment
299
+ mcp-code-indexer \
300
+ --token-limit 64000 \
301
+ --db-path /data/mcp-index.db \
302
+ --cache-dir /var/cache/mcp \
303
+ --log-level INFO \
304
+ --db-pool-size 5 \
305
+ --db-retry-count 7 \
306
+ --db-timeout 15.0 \
307
+ --enable-wal-mode \
308
+ --health-check-interval 20.0
309
+
310
+ # Environment variable configuration
311
+ export DB_POOL_SIZE=5
312
+ export DB_RETRY_COUNT=7
313
+ export DB_TIMEOUT=15.0
314
+ export DB_WAL_MODE=true
315
+ export DB_HEALTH_CHECK_INTERVAL=20.0
316
+ mcp-code-indexer --token-limit 64000
317
+ ```
318
+
319
+ #### Configuration Options
320
+
321
+ | Parameter | Default | Description | Use Case |
322
+ |-----------|---------|-------------|----------|
323
+ | `--db-pool-size` | 3 | Database connection pool size | Higher for more concurrent clients |
324
+ | `--db-retry-count` | 5 | Max retry attempts for failed operations | Increase for unstable environments |
325
+ | `--db-timeout` | 10.0 | Transaction timeout (seconds) | Increase for large operations |
326
+ | `--enable-wal-mode` | true | Enable WAL mode for concurrency | Always enable for production |
327
+ | `--health-check-interval` | 30.0 | Health monitoring interval (seconds) | Lower for faster issue detection |
328
+
329
+ 💡 **Performance Tip**: For environments with 10+ concurrent clients, use `--db-pool-size 5` and `--health-check-interval 15.0` for optimal throughput.
330
+
278
331
  ## 🤝 Integration Examples
279
332
 
280
333
  ### With AI Agents
@@ -21,6 +21,8 @@ Complete reference for all 11 MCP tools provided by the Code Indexer server. Whe
21
21
  - [Advanced Features](#advanced-features)
22
22
  - [merge_branch_descriptions](#merge_branch_descriptions)
23
23
  - [update_codebase_overview](#update_codebase_overview)
24
+ - [System Monitoring](#system-monitoring)
25
+ - [check_database_health](#check_database_health)
24
26
  - [Common Parameters](#common-parameters)
25
27
  - [Error Handling](#error-handling)
26
28
 
@@ -638,6 +640,135 @@ const result = await mcp.callTool("merge_branch_descriptions", {
638
640
 
639
641
  ---
640
642
 
643
+ ## System Monitoring
644
+
645
+ ### check_database_health
646
+
647
+ 🏥 **Real-time database health monitoring and diagnostics**
648
+
649
+ Monitor database performance, connection pool status, and system health in production environments. Essential for maintaining high-availability deployments and troubleshooting performance issues.
650
+
651
+ #### Parameters
652
+
653
+ ```typescript
654
+ interface CheckDatabaseHealthParams {
655
+ // No parameters required
656
+ }
657
+ ```
658
+
659
+ #### Response
660
+
661
+ ```typescript
662
+ interface CheckDatabaseHealthResponse {
663
+ health_status: {
664
+ overall_health: 'healthy' | 'degraded' | 'unhealthy';
665
+ database: {
666
+ pool_healthy: boolean;
667
+ active_connections: number;
668
+ total_connections: number;
669
+ failed_connections: number;
670
+ avg_response_time_ms: number;
671
+ wal_size_mb: number;
672
+ };
673
+ performance: {
674
+ current_throughput: number;
675
+ target_throughput: number;
676
+ p95_latency_ms: number;
677
+ error_rate: number;
678
+ operations_last_minute: number;
679
+ };
680
+ system: {
681
+ memory_usage_mb: number;
682
+ cpu_usage_percent: number;
683
+ disk_usage_percent: number;
684
+ uptime_seconds: number;
685
+ };
686
+ };
687
+ recommendations: string[];
688
+ last_check: string; // ISO timestamp
689
+ }
690
+ ```
691
+
692
+ #### Usage Examples
693
+
694
+ ##### 👨‍💻 Basic Health Check
695
+
696
+ ```python
697
+ # Check current system health
698
+ health_result = await mcp_client.call_tool("check_database_health", {})
699
+
700
+ if health_result["health_status"]["overall_health"] != "healthy":
701
+ print("⚠️ System health issue detected!")
702
+ for rec in health_result["recommendations"]:
703
+ print(f"💡 {rec}")
704
+ ```
705
+
706
+ ##### 🔧 Production Monitoring
707
+
708
+ ```python
709
+ # Automated health monitoring
710
+ async def monitor_health():
711
+ while True:
712
+ health = await mcp_client.call_tool("check_database_health", {})
713
+
714
+ # Check critical metrics
715
+ db_status = health["health_status"]["database"]
716
+ if db_status["failed_connections"] > 2:
717
+ send_alert("Database connection failures detected")
718
+
719
+ perf_status = health["health_status"]["performance"]
720
+ if perf_status["error_rate"] > 0.05:
721
+ send_alert(f"High error rate: {perf_status['error_rate']:.2%}")
722
+
723
+ await asyncio.sleep(30) # Check every 30 seconds
724
+ ```
725
+
726
+ ##### 📊 Performance Dashboard
727
+
728
+ ```python
729
+ # Gather metrics for dashboard
730
+ health_data = await mcp_client.call_tool("check_database_health", {})
731
+
732
+ metrics = {
733
+ 'throughput': health_data["health_status"]["performance"]["current_throughput"],
734
+ 'latency_p95': health_data["health_status"]["performance"]["p95_latency_ms"],
735
+ 'error_rate': health_data["health_status"]["performance"]["error_rate"],
736
+ 'pool_utilization': (
737
+ health_data["health_status"]["database"]["active_connections"] /
738
+ health_data["health_status"]["database"]["total_connections"]
739
+ )
740
+ }
741
+
742
+ # Send to monitoring system
743
+ await send_metrics_to_grafana(metrics)
744
+ ```
745
+
746
+ #### 🎯 Use Cases
747
+
748
+ - **Production Monitoring**: Continuous health checks in production deployments
749
+ - **Performance Debugging**: Identify bottlenecks and optimization opportunities
750
+ - **Capacity Planning**: Monitor resource utilization trends
751
+ - **Incident Response**: Quick diagnostics during performance issues
752
+ - **Load Testing**: Validate system behavior under stress
753
+
754
+ #### 🔍 Health Status Indicators
755
+
756
+ | Status | Database | Performance | System | Action Required |
757
+ |--------|----------|-------------|--------|-----------------|
758
+ | `healthy` | All connections working | <2% error rate | <80% resource usage | None |
759
+ | `degraded` | Some connection issues | 2-5% error rate | 80-90% resource usage | Monitor closely |
760
+ | `unhealthy` | Pool failures | >5% error rate | >90% resource usage | Immediate action |
761
+
762
+ #### 🚨 Common Issues & Recommendations
763
+
764
+ The tool provides intelligent recommendations based on current system state:
765
+
766
+ - **"Increase connection pool size"** - When pool utilization >90%
767
+ - **"Enable WAL mode for better concurrency"** - When lock contention detected
768
+ - **"Consider scaling resources"** - When system resources >85%
769
+ - **"Check for database corruption"** - When integrity issues found
770
+ - **"Review recent configuration changes"** - When performance regression detected
771
+
641
772
  ## Common Parameters
642
773
 
643
774
  All tools support these optional parameters for project identification: