feat(mcp): implement SearchAdapter with token-efficient formatters (Issue #28)#38
Merged
Conversation
Implements Issue #28 - First Adapter + Formatters ## Features ### Formatters - **CompactFormatter**: Token-efficient summaries (score, type, name, path) - **VerboseFormatter**: Full details with signatures and metadata - **Token Estimation**: ~4 chars/token heuristic for GPT-4 ### SearchAdapter - Implements `dev_search` MCP tool - Semantic code search via RepositoryIndexer - Configurable format modes (compact/verbose) - Input validation with structured errors - Token-aware result formatting ### API - Format modes: `compact` (default) | `verbose` - Configurable limits: 1-50 results (default: 10) - Score threshold: 0-1 (default: 0) - Token budgets: 1K (compact) | 5K (verbose) ## Benefits - ✅ Token-efficient by default (compact mode) - ✅ Opt-in verbosity for detailed exploration - ✅ Type-safe metadata access - ✅ Structured error handling - ✅ Extensible formatter framework ## Next Steps - Add comprehensive tests (unit + integration) - Test with real MCP clients - Measure token estimation accuracy
Implements Issue #28 - First Adapter + Formatters (Tests) ## Test Coverage ### Formatters (30 tests) - **formatters.test.ts**: CompactFormatter + VerboseFormatter - Single/multiple result formatting - Token estimation - Empty result handling - Signature inclusion/exclusion - maxResults option - **utils.test.ts**: Token estimation utilities - Text/JSON token estimation - Truncation to token budgets - Whitespace normalization - Accuracy validation (~50% of actual) ### SearchAdapter (25 tests) - Tool definition validation - Query validation (empty, non-string) - Format validation (compact/verbose/invalid) - Limit validation (1-50 range) - Score threshold validation (0-1 range) - Search execution with mocked indexer - Token estimation comparison - Empty result handling ### Restructuring - ✅ Moved ALL tests from `tests/` to co-located `__tests__/` - ✅ Updated all import paths (simpler, cleaner) - ✅ Consistent with `packages/core` and `packages/subagents` - ✅ Works with root vitest.config.ts out of the box - ✅ 135 total tests pass (7 test files) ## Benefits - 🎯 Consistency across entire monorepo - 📁 Tests co-located with source code - 🔍 Easier discoverability - 🚀 Simpler import paths - ✅ Test discovery works automatically
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.
Implements Issue #28 - First Adapter + Formatters (SearchAdapter)
Overview
Adds the first concrete MCP adapter: SearchAdapter with token-efficient formatters for semantic code search.
What's New
🎯 SearchAdapter
dev_searchMCP tool for semantic code searchRepositoryIndexerfor vector search📊 Formatters
[score%] type: name (path:line)✅ Comprehensive Tests (135 passing)
🔧 Test Restructuring
tests/to co-located__tests__/packages/coreandpackages/subagents../modulevs../../../src/module)API
Tool:
dev_searchResponse
Benefits
Testing
Next Steps
Closes #28