Add MCP server and improve ignore pattern matching#248
Open
mohsen1 wants to merge 5 commits into
Open
Conversation
Fixes #241: Ignore patterns now correctly apply to files with node_modules/nodeModules in their paths within git submodules. Changes: - Fix .gitignore loading order in build_gitignore so custom patterns take precedence over .gitignore rules (last match wins in gitignore) - Fix should_ignore_file to match against relative paths and file names, not just absolute paths, and respect allowlist (!) patterns - Add **/node_modules/**, **/vendor/**, **/__pycache__/**, and **/.pytest_cache/** patterns to match at any directory depth - Add tests for node_modules ignore pattern behavior Addresses #232: Add basic MCP (Model Context Protocol) server as yek-mcp binary, exposing serialize_repo as an MCP tool for LLM integration. https://claude.ai/code/session_017tFkSVnv1WJED8xzNVJsbp
…e ignore matching - Extract apply_defaults() on YekConfig to deduplicate config merging between init_config() and MCP server - Remove redundant root-level ignore patterns (node_modules/**, vendor/**, etc.) subsumed by **/ variants - Consolidate double iteration in should_ignore_file into single pass over patterns - Remove unnecessary comment in build_gitignore https://claude.ai/code/session_017tFkSVnv1WJED8xzNVJsbp
- Fix extend_with_drain clippy lint: use append() instead of extend(drain(..)) - Remove unnecessary return in match arm (clippy::needless_return) - Apply cargo fmt formatting fixes https://claude.ai/code/session_017tFkSVnv1WJED8xzNVJsbp
- Fix gitignore allowlist: config patterns now load before .gitignore so .gitignore negation patterns (e.g. !LICENSE) can override defaults - Skip permission-based tests when running as root (euid == 0) - Update README: add missing --update flag, add MCP server documentation https://claude.ai/code/session_017tFkSVnv1WJED8xzNVJsbp
- Fix module listing: parallel_fixed.rs -> parallel.rs, add mcp.rs and category.rs - Fix CLI examples: remove non-existent --input, --output, --stream, --memory-limit flags - Remove reference to config.rs as "legacy" https://claude.ai/code/session_017tFkSVnv1WJED8xzNVJsbp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a Model Context Protocol (MCP) server implementation for yek and improves the ignore pattern matching logic to handle patterns at any directory level.
Key Changes
MCP Server Implementation
src/mcp.rsbinary that implements a JSON-RPC 2.0 MCP serverserialize_repotool over stdio for LLM integrationinitialize,tools/list, andtools/callyek-mcpbinary target toCargo.tomlIgnore Pattern Matching Improvements
should_ignore_file()insrc/parallel.rsto check patterns against:!) to allowlist files.gitignorerules by being added after.gitignoreto the gitignore builderDefault Ignore Patterns
**/node_modules/**pattern to catch node_modules at any directory level**/vendor/**pattern for nested vendor directories**/.pytest_cache/**pattern for nested pytest cache directories**/__pycache__/**pattern for nested Python cache directoriesTests
test_ignore_patterns_with_node_modules_in_path()to verify patterns work with nested directory structures (addresses issue Ignore patterns fail for files containingnode_modulesin git submodule paths #241)test_node_modules_ignored_at_any_level()to ensure node_modules is ignored regardless of nesting depthImplementation Details
https://claude.ai/code/session_017tFkSVnv1WJED8xzNVJsbp