0.1.0 • Published 1 month ago

@team-jd/mcp-project-explorer v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

šŸ” Project Explorer MCP Server

A powerful Model Context Protocol server for exploring, analyzing, and managing project files with advanced search capabilities

Version Node.js TypeScript


šŸš€ Overview

The Project Explorer MCP Server provides comprehensive tools for analyzing project structures, searching through codebases, managing dependencies, and performing file operations. Perfect for developers who need intelligent project navigation and analysis capabilities.

šŸ“¦ Installation & Setup

# Install dependencies
npm install

# Build the project
npm run build

# Run the MCP inspector for testing
npm run inspector

šŸ› ļø Available Commands

šŸ“‚ explore_project

Analyzes project structure with detailed file information and import/export analysis

// Basic usage
explore_project({
  directory: "/path/to/project"
})

// Advanced usage
explore_project({
  directory: "/path/to/project",
  subDirectory: "src",           // Optional: focus on specific subdirectory
  includeHidden: false          // Optional: include hidden files (default: false)
})

✨ Features:

  • šŸ“Š File size analysis with human-readable formatting
  • šŸ” Import/export statement detection for JS/TS files
  • 🚫 Automatically excludes build directories (node_modules, .git, dist, etc.)
  • šŸ“ Recursive directory traversal
  • šŸŽÆ Support for subdirectory analysis

šŸ”Ž search_files

Advanced file and code search with comprehensive filtering capabilities

// Simple text search
search_files({
  pattern: "your search term",
  searchPath: "/path/to/search"
})

// Advanced search with filters
search_files({
  pattern: "function.*async",     // Regex pattern
  searchPath: "/path/to/search",
  regexMode: true,               // Enable regex
  caseSensitive: false,          // Case sensitivity
  extensions: [".js", ".ts"],    // File types to include
  excludeExtensions: [".min.js"], // File types to exclude
  excludeComments: true,         // Skip comments
  excludeStrings: true,          // Skip string literals
  maxResults: 50,                // Limit results
  sortBy: "relevance"            // Sort method
})

šŸŽ›ļø Search Options:

ParameterTypeDefaultDescription
patternstring".*"Search pattern (text or regex)
searchPathstringfirst allowed dirDirectory to search in
extensionsstring[]allInclude only these file types
excludeExtensionsstring[][]Exclude these file types
excludePatternsstring[][]Exclude filename patterns
regexModebooleanfalseTreat pattern as regex
caseSensitivebooleanfalseCase-sensitive search
wordBoundarybooleanfalseMatch whole words only
multilinebooleanfalseMultiline regex matching
maxDepthnumberunlimitedDirectory recursion depth
followSymlinksbooleanfalseFollow symbolic links
includeBinarybooleanfalseSearch in binary files
minSizenumbernoneMinimum file size (bytes)
maxSizenumbernoneMaximum file size (bytes)
modifiedAfterstringnoneFiles modified after date (ISO 8601)
modifiedBeforestringnoneFiles modified before date (ISO 8601)
snippetLengthnumber50Text snippet length around matches
maxResultsnumber100Maximum number of results
sortBystring"relevance"Sort by: relevance, file, lineNumber, modified, size
groupByFilebooleantrueGroup results by file
excludeCommentsbooleanfalseSkip comments (language-aware)
excludeStringsbooleanfalseSkip string literals
outputFormatstring"text"Output format: text, json, structured

šŸŽÆ Use Cases:

  • šŸ” Find all TODO comments: pattern: "TODO.*", excludeStrings: true
  • šŸ› Search for potential bugs: pattern: "console\\.log", regexMode: true
  • šŸ“¦ Find import statements: pattern: "import.*from", regexMode: true
  • šŸ”§ Recent changes: modifiedAfter: "2024-01-01", extensions: [".js", ".ts"]

šŸ“Š check_outdated

Checks for outdated npm packages with detailed analysis

// Basic check
check_outdated({
  projectPath: "/path/to/project"
})

// Detailed analysis
check_outdated({
  projectPath: "/path/to/project",
  includeDevDependencies: true,  // Include dev dependencies
  outputFormat: "detailed"       // detailed, summary, or raw
})

šŸ“‹ Output Formats:

  • detailed - Full package info with versions and update commands
  • summary - Count of outdated packages by type
  • raw - Raw npm outdated JSON output

šŸ”§ Requirements:

  • Node.js and npm must be installed
  • Valid package.json in the specified directory

šŸ—‘ļø delete_file

Safely delete files or directories with protection mechanisms

// Delete a file
delete_file({
  path: "/path/to/file.txt"
})

// Delete a directory (requires recursive flag)
delete_file({
  path: "/path/to/directory",
  recursive: true,              // Required for directories
  force: false                  // Force deletion of read-only files
})

āš ļø Safety Features:

  • šŸ”’ Only works within allowed directories
  • šŸ“ Requires recursive: true for non-empty directories
  • šŸ›”ļø Protection against accidental deletions
  • ⚔ Optional force deletion for read-only files

āœļø rename_file

Rename or move files and directories

// Simple rename
rename_file({
  oldPath: "/path/to/old-name.txt",
  newPath: "/path/to/new-name.txt"
})

// Move to different directory
rename_file({
  oldPath: "/path/to/file.txt",
  newPath: "/different/path/file.txt"
})

✨ Features:

  • šŸ“ Works with both files and directories
  • šŸ”„ Can move between directories
  • 🚫 Fails if destination already exists
  • šŸ”’ Both paths must be within allowed directories

šŸ“‹ list_allowed_directories

Shows which directories the server can access

list_allowed_directories()

šŸ”§ Use Cases:

  • šŸ” Check access permissions before operations
  • šŸ›”ļø Security validation
  • šŸ“‚ Directory discovery

šŸŽØ Usage Examples

šŸ“Š Project Analysis Workflow

// 1. Check what directories you can access
list_allowed_directories()

// 2. Explore the project structure
explore_project({
  directory: "/your/project/path",
  includeHidden: false
})

// 3. Search for specific patterns
search_files({
  pattern: "useState",
  searchPath: "/your/project/path",
  extensions: [".jsx", ".tsx"],
  excludeComments: true
})

// 4. Check for outdated dependencies
check_outdated({
  projectPath: "/your/project/path",
  outputFormat: "detailed"
})

šŸ” Advanced Search Scenarios

// Find all async functions
search_files({
  pattern: "async\\s+function",
  regexMode: true,
  extensions: [".js", ".ts"]
})

// Find large files modified recently
search_files({
  pattern: ".*",
  minSize: 1000000,  // 1MB+
  modifiedAfter: "2024-01-01",
  sortBy: "size"
})

// Find TODO comments excluding test files
search_files({
  pattern: "TODO|FIXME|BUG",
  regexMode: true,
  excludePatterns: ["*test*", "*spec*"],
  excludeStrings: true
})

šŸ›”ļø Security & Permissions

The server operates within allowed directories only, providing:

  • šŸ”’ Sandboxed access - Cannot access files outside allowed paths
  • šŸ›”ļø Safe operations - Built-in protections against dangerous operations
  • šŸ“‚ Path validation - All paths are normalized and validated
  • āš ļø Error handling - Clear error messages for permission issues

šŸ”§ Development

šŸ“ Project Structure

src/
ā”œā”€ā”€ index.ts              # Main server entry point
ā”œā”€ā”€ explore-project.ts    # Project analysis tool
ā”œā”€ā”€ search.ts            # Advanced search functionality
ā”œā”€ā”€ check-outdated.ts   # NPM dependency checker
ā”œā”€ā”€ delete-file.ts       # File deletion tool
ā”œā”€ā”€ rename-file.ts       # File rename/move tool
└── list-allowed.ts      # Directory permission checker

šŸ—ļø Build Commands

npm run build     # Compile TypeScript
npm run watch     # Watch mode for development
npm run inspector # Test with MCP inspector

šŸ¤ Contributing

  1. šŸ“ Fork the repository
  2. 🌟 Create a feature branch
  3. šŸ’» Make your changes
  4. āœ… Test thoroughly
  5. šŸš€ Submit a pull request

šŸ“„ License

See LICENSE file for details.


Happy coding! šŸŽ‰

Built with ā¤ļø using TypeScript and the Model Context Protocol