XcodeBuildMCP icon indicating copy to clipboard operation
XcodeBuildMCP copied to clipboard

[Feature]: WordSearch

Open Lanadya opened this issue 7 months ago • 5 comments

Feature Description

I am not that experienced (maybe dumb suggestion) - could you make the search for a certain word in Xcode possible? Sometimes in my huge project, I use oversight and have the same files/commands/etc. in different locations in Xcode and the mcp does not notice and can‘t search itself after the doubled up words.

Use Cases

No response

Example Interactions

No response

Lanadya avatar Apr 30 '25 10:04 Lanadya

@Lanadya Thanks for the feedback. I'm not sure I fully understand what you're asking. Could you provide an example of the problem you're facing and what the expected behaviour is?

cameroncooke avatar Apr 30 '25 11:04 cameroncooke

Hi Cameron,I had a threat safe cash issue and couldn’t fix it until I put it in the search in Xcode in the navigator and then I’ve been shown all places where threat save cash has been used in my project.That helped to find a solution for my build problems. The MCP couldn’t do it itself so I had to do it manually if this subscription is still not clear please get back to me. I will try better. Attached I Send the photos.Thank you for your marvelous work!!!!NinaAm 30.04.2025 um 13:34 schrieb Cameron Cooke @.***>: cameroncooke left a comment (cameroncooke/XcodeBuildMCP#16) @Lanadya Thanks for the feedback. I'm not sure I fully understand what you're asking. Could you provide an example of the problem you're facing and what the expected behaviour is?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

Lanadya avatar Apr 30 '25 11:04 Lanadya

Hi Cameron, I had a ThreadSafeCache issue and couldn’t fix it until I put the word in the search in Xcode in the navigator and then I’ve been shown all places where ThreadSafeCache has been used in my project. That helped to find a solution for my build problems. The MCP cannot look how often and in what file a certain command (or whatever else) is. it if this description is still not clear please get back to me. I will try better. Attached I Send the photos. Thank you for your marvelous work!!!! Nina image0.jpegimage1.jpeg

Image Image

Lanadya avatar Apr 30 '25 11:04 Lanadya

@claude please review this issue

cameroncooke avatar Aug 08 '25 08:08 cameroncooke

Claude finished @cameroncooke's task —— View job


Analysis of WordSearch Feature Request

I'll analyze this feature request for adding text/word search functionality to XcodeBuildMCP.

Todo List:

  • [x] Review the feature request details and user needs
  • [x] Examine current XcodeBuildMCP architecture and existing search tools
  • [x] Look at images provided by the user showing Xcode's search functionality
  • [x] Assess technical feasibility and implementation approaches
  • [x] Provide recommendations and next steps

Understanding the Request

Based on @Lanadya's description and the screenshots provided, they want the ability to search for specific text/code across their Xcode project files through the MCP server. The specific use case mentioned was searching for "ThreadSafeCache" to identify all locations where this class/pattern was used in the codebase, which helped debug build issues.

The screenshots show Xcode's built-in search functionality that displays:

  • Multiple Swift files containing the search term
  • Line-by-line matches with context
  • File paths and specific code locations
  • Highlighted search terms within the code

Current XcodeBuildMCP Architecture Analysis

Existing Capabilities:

  • 15 workflow groups with 84+ specialized tools
  • Project Discovery: discover_projs tool for finding .xcodeproj and .xcworkspace files
  • Command Infrastructure: Robust CommandExecutor interface for running shell commands
  • File System Access: FileSystemExecutor interface for file operations
  • Plugin Architecture: Auto-discovery system that would easily accommodate new search tools

Missing Capabilities:

  • No existing text/content search functionality
  • No grep, ripgrep, or similar search utilities exposed as MCP tools
  • No source code indexing or search capabilities

Technical Feasibility Assessment

✅ Highly Feasible - This feature aligns perfectly with XcodeBuildMCP's architecture:

Implementation Approaches

1. Command-Line Based Search (Recommended)

// New workflow group: `text-search`
- `search_code` - Search for text/patterns across project files
- `search_files` - Find files by name pattern
- `search_regex` - Advanced regex-based code search

Benefits:

  • Leverages existing CommandExecutor infrastructure
  • Uses proven tools (grep, ripgrep, find)
  • Fast and reliable
  • Works with all file types (Swift, Objective-C, C++, etc.)
  • Supports regex patterns for advanced searching

2. Xcode Integration Approach
Could potentially use xcodebuild with specific flags, but this would be limited compared to general text search.

3. File System + Parser Approach Custom implementation using FileSystemExecutor, but this would be more complex and slower.

Recommended Implementation

New Workflow Group: text-search Location: src/mcp/tools/text-search/

Core Tools:

  1. search_code - Primary text search across project files

    • Parameters: searchTerm, projectPath, fileTypes?, caseSensitive?, regex?
    • Uses ripgrep (faster) or grep fallback
    • Returns: File paths, line numbers, matched content with context
  2. search_files - Find files by name/path patterns

    • Parameters: pattern, projectPath, maxDepth?
    • Uses find command
    • Returns: Matching file paths
  3. search_replace - Search and replace text (advanced feature)

    • Parameters: searchTerm, replacement, projectPath, dryRun?
    • Interactive confirmation for safety

Example Usage:

// Find all uses of "ThreadSafeCache" in Swift files
search_code({
  searchTerm: "ThreadSafeCache",
  projectPath: "/path/to/project", 
  fileTypes: ["swift"],
  caseSensitive: true
})

// Returns:
// AssetManagerTypes.swift:97: guard let url = Bundle(for: CoreCommon.ThreadSafeCache...
// ThreadSafeAssetManager.swift:216: private var imageCache = CoreCommon.ThreadSafeCache...
// ThreadSafeCache.swift:489: // ThreadSafeCache.swift

Integration Strategy

  1. Plugin Auto-Discovery: Follows existing patterns, tools automatically registered
  2. Dependency Injection: Uses CommandExecutor for testability
  3. Error Handling: Consistent with existing tool response patterns
  4. Dynamic Loading: Compatible with XCODEBUILDMCP_DYNAMIC_TOOLS=true mode
  5. Cross-Platform: Works with all supported project types (iOS, macOS)

Development Effort

Estimated Effort: Medium (1-2 weeks)

  • Tool implementation: ~3-5 days
  • Testing: ~2-3 days
  • Documentation: ~1 day

Prerequisites:

  • ripgrep available on system (fallback to grep)
  • Basic command-line tools (find, grep)

Recommendation

✅ APPROVE - This is an excellent feature request that:

  1. Addresses Real Need: Solves actual debugging/development workflow issues
  2. Fits Architecture: Perfect match for XcodeBuildMCP's plugin system
  3. High Value: Would be useful for many developers working with large codebases
  4. Straightforward Implementation: Leverages existing infrastructure
  5. Future-Proof: Can be extended with more advanced features

Next Steps:

  1. Create new text-search workflow group
  2. Implement search_code as primary tool
  3. Add comprehensive test coverage
  4. Update documentation
  5. Consider additional tools (search_files, search_replace) in future iterations

This feature would make XcodeBuildMCP significantly more useful for code exploration and debugging workflows, directly addressing @Lanadya's use case and many similar scenarios.


claude[bot] avatar Aug 08 '25 08:08 claude[bot]