mcp-code-indexer 3.2.0__py3-none-any.whl → 3.2.2__py3-none-any.whl

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.
@@ -10,6 +10,7 @@ import html
10
10
  import json
11
11
  import logging
12
12
  import re
13
+ import time
13
14
  import uuid
14
15
  from datetime import datetime
15
16
  from pathlib import Path
@@ -958,7 +959,9 @@ class MCPCodeIndexServer:
958
959
  logger.info(f"Resolved project_id: {project_id}")
959
960
 
960
961
  # Run cleanup if needed (respects 30-minute cooldown)
961
- await self._run_cleanup_if_needed()
962
+ cleaned_up_count = await self._run_cleanup_if_needed(
963
+ project_id=project_id, project_root=folder_path
964
+ )
962
965
 
963
966
  # Get file descriptions for this project (after cleanup)
964
967
  logger.info("Retrieving file descriptions...")
@@ -998,15 +1001,13 @@ class MCPCodeIndexServer:
998
1001
  logger.info(f"Recommendation: {recommendation}")
999
1002
 
1000
1003
  return {
1001
- "totalTokens": total_tokens,
1002
- "descriptionsTokens": descriptions_tokens,
1004
+ "fileDescriptionTokens": descriptions_tokens,
1003
1005
  "overviewTokens": overview_tokens,
1004
1006
  "isLarge": is_large,
1005
1007
  "recommendation": recommendation,
1006
1008
  "tokenLimit": token_limit,
1007
1009
  "totalFiles": len(file_descriptions),
1008
- "cleanedUpFiles": cleaned_up_files,
1009
- "cleanedUpCount": len(cleaned_up_files),
1010
+ "cleanedUpCount": cleaned_up_count,
1010
1011
  }
1011
1012
 
1012
1013
  async def _handle_find_missing_descriptions(
@@ -1490,20 +1491,20 @@ class MCPCodeIndexServer:
1490
1491
  logger.error(f"Error in periodic cleanup: {e}")
1491
1492
  # Continue running despite errors
1492
1493
 
1493
- async def _run_cleanup_if_needed(self) -> None:
1494
+ async def _run_cleanup_if_needed(self, project_id: str = None, project_root: Path = None) -> int:
1494
1495
  """Run cleanup if conditions are met (not running, not run recently)."""
1495
1496
  current_time = time.time()
1496
1497
 
1497
1498
  # Check if cleanup is already running
1498
1499
  if self._cleanup_running:
1499
1500
  logger.debug("Cleanup already running, skipping")
1500
- return
1501
+ return 0
1501
1502
 
1502
1503
  # Check if cleanup was run in the last 30 minutes
1503
1504
  if (self._last_cleanup_time and
1504
1505
  current_time - self._last_cleanup_time < 30 * 60):
1505
1506
  logger.debug("Cleanup ran recently, skipping")
1506
- return
1507
+ return 0
1507
1508
 
1508
1509
  # Set running flag and update time
1509
1510
  self._cleanup_running = True
@@ -1511,37 +1512,66 @@ class MCPCodeIndexServer:
1511
1512
 
1512
1513
  try:
1513
1514
  logger.info("Starting cleanup")
1514
-
1515
- # Get all projects and run cleanup on each
1516
- projects = await self.db_manager.get_all_projects()
1517
1515
  total_cleaned = 0
1518
1516
 
1519
- for project in projects:
1517
+ if project_id and project_root:
1518
+ # Single project cleanup
1520
1519
  try:
1521
- # Cleanup missing files
1522
1520
  missing_files = await self.db_manager.cleanup_missing_files(
1523
- project_id=project.id,
1524
- project_root=Path(project.folder_path)
1521
+ project_id=project_id, project_root=project_root
1525
1522
  )
1526
- total_cleaned += len(missing_files)
1523
+ total_cleaned = len(missing_files)
1527
1524
 
1528
1525
  # Perform permanent cleanup (retention policy)
1529
1526
  deleted_count = await self.cleanup_manager.perform_cleanup(
1530
- project_id=project.id
1527
+ project_id=project_id
1531
1528
  )
1532
1529
 
1533
1530
  if missing_files or deleted_count:
1534
1531
  logger.info(
1535
- f"Cleanup for {project.name}: "
1536
- f"{len(missing_files)} marked, "
1532
+ f"Cleanup: {len(missing_files)} marked, "
1537
1533
  f"{deleted_count} permanently deleted"
1538
1534
  )
1539
1535
  except Exception as e:
1540
- logger.error(
1541
- f"Error during cleanup for project {project.name}: {e}"
1542
- )
1536
+ logger.error(f"Error during cleanup: {e}")
1537
+ else:
1538
+ # All projects cleanup (for periodic task)
1539
+ projects = await self.db_manager.get_all_projects()
1540
+
1541
+ for project in projects:
1542
+ try:
1543
+ # Skip projects without folder paths in aliases
1544
+ if not project.aliases:
1545
+ continue
1546
+
1547
+ # Use first alias as folder path
1548
+ folder_path = Path(project.aliases[0])
1549
+ if not folder_path.exists():
1550
+ continue
1551
+
1552
+ missing_files = await self.db_manager.cleanup_missing_files(
1553
+ project_id=project.id, project_root=folder_path
1554
+ )
1555
+ total_cleaned += len(missing_files)
1556
+
1557
+ # Perform permanent cleanup (retention policy)
1558
+ deleted_count = await self.cleanup_manager.perform_cleanup(
1559
+ project_id=project.id
1560
+ )
1561
+
1562
+ if missing_files or deleted_count:
1563
+ logger.info(
1564
+ f"Cleanup for {project.name}: "
1565
+ f"{len(missing_files)} marked, "
1566
+ f"{deleted_count} permanently deleted"
1567
+ )
1568
+ except Exception as e:
1569
+ logger.error(
1570
+ f"Error during cleanup for project {project.name}: {e}"
1571
+ )
1543
1572
 
1544
1573
  logger.info(f"Cleanup completed: {total_cleaned} files processed")
1574
+ return total_cleaned
1545
1575
 
1546
1576
  finally:
1547
1577
  self._cleanup_running = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mcp-code-indexer
3
- Version: 3.2.0
3
+ Version: 3.2.2
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
  License: MIT
6
6
  Keywords: mcp,model-context-protocol,code-indexer,ai-tools,codebase-navigation,file-descriptions,llm-tools
@@ -40,8 +40,8 @@ Description-Content-Type: text/markdown
40
40
 
41
41
  # MCP Code Indexer 🚀
42
42
 
43
- [![PyPI version](https://badge.fury.io/py/mcp-code-indexer.svg?27)](https://badge.fury.io/py/mcp-code-indexer)
44
- [![Python](https://img.shields.io/pypi/pyversions/mcp-code-indexer.svg?27)](https://pypi.org/project/mcp-code-indexer/)
43
+ [![PyPI version](https://badge.fury.io/py/mcp-code-indexer.svg?29)](https://badge.fury.io/py/mcp-code-indexer)
44
+ [![Python](https://img.shields.io/pypi/pyversions/mcp-code-indexer.svg?29)](https://pypi.org/project/mcp-code-indexer/)
45
45
  [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
46
46
 
47
47
  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.
@@ -25,12 +25,12 @@ mcp_code_indexer/migrations/004_remove_branch_dependency.sql,sha256=whZvj2qfba1-
25
25
  mcp_code_indexer/migrations/005_remove_git_remotes.sql,sha256=vT84AaV1hyN4zq5W67hR14TgAwhW7_RNtBHrCoksxA4,1299
26
26
  mcp_code_indexer/query_preprocessor.py,sha256=PLFR1T9mSn2Mkxw6-GB4GkxyfzjJ2ia3dgLPcziHfVA,5483
27
27
  mcp_code_indexer/server/__init__.py,sha256=16xMcuriUOBlawRqWNBk6niwrvtv_JD5xvI36X1Vsmk,41
28
- mcp_code_indexer/server/mcp_server.py,sha256=LdwuwXJch8UqvODi_UlYRiwNbyjs_2Xy8LW3eWyUaJw,69423
28
+ mcp_code_indexer/server/mcp_server.py,sha256=uKlHOXhHZITdrqiC-r5dPC0riO8teKySt_DxYGNHgfI,70931
29
29
  mcp_code_indexer/tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4,sha256=Ijkht27pm96ZW3_3OFE-7xAPtR0YyTWXoRO8_-hlsqc,1681126
30
30
  mcp_code_indexer/token_counter.py,sha256=e6WsyCEWMMSkMwLbcVtr5e8vEqh-kFqNmiJErCNdqHE,8220
31
31
  mcp_code_indexer/tools/__init__.py,sha256=m01mxML2UdD7y5rih_XNhNSCMzQTz7WQ_T1TeOcYlnE,49
32
- mcp_code_indexer-3.2.0.dist-info/LICENSE,sha256=JN9dyPPgYwH9C-UjYM7FLNZjQ6BF7kAzpF3_4PwY4rY,1086
33
- mcp_code_indexer-3.2.0.dist-info/METADATA,sha256=5xv50l_Rel6AZ9HaXnghtiXC6wySm86ulch8QsUZwCY,19191
34
- mcp_code_indexer-3.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
35
- mcp_code_indexer-3.2.0.dist-info/entry_points.txt,sha256=UABj7HZ0mC6rvF22gxaz2LLNLGQShTrFmp5u00iUtvo,67
36
- mcp_code_indexer-3.2.0.dist-info/RECORD,,
32
+ mcp_code_indexer-3.2.2.dist-info/LICENSE,sha256=JN9dyPPgYwH9C-UjYM7FLNZjQ6BF7kAzpF3_4PwY4rY,1086
33
+ mcp_code_indexer-3.2.2.dist-info/METADATA,sha256=0MrKrTAdCu-xPYjabRd_-V_-Oi7WevFQtwHuLDMjgGY,19191
34
+ mcp_code_indexer-3.2.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
35
+ mcp_code_indexer-3.2.2.dist-info/entry_points.txt,sha256=UABj7HZ0mC6rvF22gxaz2LLNLGQShTrFmp5u00iUtvo,67
36
+ mcp_code_indexer-3.2.2.dist-info/RECORD,,