Skip to content

Add MCP server and improve ignore pattern matching#248

Open
mohsen1 wants to merge 5 commits into
mainfrom
claude/fix-open-issues-prs-u2Osh
Open

Add MCP server and improve ignore pattern matching#248
mohsen1 wants to merge 5 commits into
mainfrom
claude/fix-open-issues-prs-u2Osh

Conversation

@mohsen1

@mohsen1 mohsen1 commented Mar 21, 2026

Copy link
Copy Markdown
Owner

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

  • Added new src/mcp.rs binary that implements a JSON-RPC 2.0 MCP server
  • Exposes serialize_repo tool over stdio for LLM integration
  • Implements MCP protocol methods: initialize, tools/list, and tools/call
  • Supports all yek configuration options (path, max_size, tokens, ignore_patterns) as tool parameters
  • Added yek-mcp binary target to Cargo.toml

Ignore Pattern Matching Improvements

  • Enhanced should_ignore_file() in src/parallel.rs to check patterns against:
    • Absolute file paths
    • Relative paths
    • File names only
  • Added support for negation patterns (patterns starting with !) to allowlist files
  • Fixed pattern precedence: custom patterns now override .gitignore rules by being added after .gitignore to the gitignore builder

Default Ignore Patterns

  • Added **/node_modules/** pattern to catch node_modules at any directory level
  • Added **/vendor/** pattern for nested vendor directories
  • Added **/.pytest_cache/** pattern for nested pytest cache directories
  • Added **/__pycache__/** pattern for nested Python cache directories

Tests

Implementation Details

  • The MCP server reads JSON-RPC requests from stdin and writes responses to stdout
  • Notifications (requests without an id) are processed but don't generate responses
  • Repository serialization errors are properly caught and returned as MCP error responses
  • The implementation merges default ignore patterns and binary extensions with user-provided configuration

https://claude.ai/code/session_017tFkSVnv1WJED8xzNVJsbp

claude added 5 commits March 21, 2026 09:40
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants