Skip to content

feat: expose all 10 MCP tools via CLI + document them#42

Merged
PatrickSys merged 8 commits intomasterfrom
feat/cli-all-tools
Feb 21, 2026
Merged

feat: expose all 10 MCP tools via CLI + document them#42
PatrickSys merged 8 commits intomasterfrom
feat/cli-all-tools

Conversation

@PatrickSys
Copy link
Owner

Summary

Implements CLI commands for all 10 MCP tools, enabling vendor-neutral access for scripting, debugging, and CI workflows.

  • Add 8 new subcommands: search, metadata, status, reindex, style-guide, patterns, refs, cycles
  • Each maps directly to existing tool handlers via dispatchTool()
  • Create initToolContext() that builds a ToolContext from the persisted on-disk index (no MCP server needed)
  • Support --json flag for JSON output (default: human-readable)
  • Validate required flags with stderr + exit code 1

Documentation

  • Updated README: "CLI Access" → "CLI Reference" with examples for all 9 commands (memory + 8 new)
  • Added "CLI Reference" section to docs/capabilities.md with command/flag/tool mapping table

Test Coverage

  • All 234 tests pass
  • Build is clean
  • Manual verification: --help, status, error cases, memory list

🤖 Generated with Claude Code

PatrickSys and others added 5 commits February 21, 2026 17:08
- Add handleCliCommand() in src/cli.ts with 8 new subcommands:
  search, metadata, status, reindex, style-guide, patterns, refs, cycles
- Each maps 1:1 to existing tool handlers via dispatchTool()
- Create initToolContext() that builds ToolContext from persisted index
- Add required-flag validation (--query for search, --symbol for refs)
- Support --json flag for scripting/piping
- Update src/index.ts routing to send CLI_SUBCOMMANDS to handleCliCommand
- Expand README "CLI Access" → "CLI Reference" with all 9 commands
- Add "CLI Reference" section to docs/capabilities.md with command table

CLI now enables vendor-neutral access for scripting, debugging, and CI.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@greptile-apps
Copy link

greptile-apps bot commented Feb 21, 2026

Greptile Summary

Exposes all 10 MCP tools as CLI commands for vendor-neutral scripting and debugging. Creates initToolContext() that builds a ToolContext from on-disk index, routing commands via dispatchTool().

Major changes:

  • Added 8 new CLI subcommands (search, metadata, status, reindex, style-guide, patterns, refs, cycles) to src/cli.ts
  • Each command maps to existing MCP tool handlers
  • Supports --json flag for raw output vs human-readable
  • Updated README and docs/capabilities.md with comprehensive examples and reference tables
  • Refactored src/index.ts to route all CLI commands through handleCliCommand()

Issues found:

  • Filter construction bug in search command (lines 205-207) - multiple filter flags will overwrite each other instead of merging

Confidence Score: 4/5

  • Safe to merge after fixing the filter construction bug - the logic error will break multi-filter searches but other functionality is solid
  • Score reflects one critical logic bug that breaks search when combining multiple filter flags (lang + framework + layer), but the rest of the implementation is clean with good separation of concerns. Tests pass and architecture is sound.
  • src/cli.ts lines 205-207 - fix filter merging logic before merge

Important Files Changed

Filename Overview
src/cli.ts Added 8 new CLI commands mapping to MCP tools with initToolContext() and dispatchTool() integration. Found one logic bug in filter construction for search command.
src/index.ts Updated CLI command routing to use handleCliCommand() instead of handleMemoryCli(), added CLI_SUBCOMMANDS array. Clean refactor with no issues.
README.md Expanded CLI documentation from memory-only to all 10 MCP tools with examples. Well-structured and clear.
docs/capabilities.md Added comprehensive CLI reference table mapping commands to MCP tools. Good technical documentation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Start[CLI Entry: npx codebase-context] --> Parse[handleCliCommand argv]
    Parse --> Memory{command === 'memory'?}
    Memory -->|Yes| MemoryCLI[handleMemoryCli]
    Memory -->|No| Init[initToolContext]
    
    Init --> CheckIndex{index exists?}
    CheckIndex -->|Yes| Ready[indexState: 'ready']
    CheckIndex -->|No| Idle[indexState: 'idle']
    
    Ready --> Route[Route by command]
    Idle --> Route
    
    Route --> Search[search → search_codebase]
    Route --> Metadata[metadata → get_codebase_metadata]
    Route --> Status[status → get_indexing_status]
    Route --> Reindex[reindex → refresh_index]
    Route --> StyleGuide[style-guide → get_style_guide]
    Route --> Patterns[patterns → get_team_patterns]
    Route --> Refs[refs → get_symbol_references]
    Route --> Cycles[cycles → detect_circular_dependencies]
    
    Search --> Dispatch[dispatchTool]
    Metadata --> Dispatch
    Status --> Dispatch
    StyleGuide --> Dispatch
    Patterns --> Dispatch
    Refs --> Dispatch
    Cycles --> Dispatch
    
    Reindex --> PerformIndex[ctx.performIndexing]
    PerformIndex --> Dispatch
    
    Dispatch --> Format{--json flag?}
    Format -->|Yes| JSON[console.log raw JSON]
    Format -->|No| Pretty[console.log formatted]
    
    JSON --> End[Exit]
    Pretty --> End
Loading

Last reviewed commit: 9a2d523

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

- Removed unused import of Memory from src/index.ts.
- Simplified error message construction in src/core/symbol-references.ts.
- Reorganized risk level calculation in src/tools/search-codebase.ts for clarity and consistency.
- Added a TODO comment for reviewing confidence calculation in src/tools/search-codebase.ts.
- Renamed riskLevel variable to _riskLevel for clarity.
- Added a TODO comment to review the risk level calculation logic.
- Adjusted risk level assignment based on cycle count and impact candidates.
@PatrickSys
Copy link
Owner Author

@copilot review

Copy link

Copilot AI commented Feb 21, 2026

@PatrickSys I've opened a new pull request, #43, to work on those changes. Once the pull request is ready, I'll request review from you.

…tting

- Consolidated console.log statements in src/cli.ts for better readability.
- Enhanced error message formatting in src/core/symbol-references.ts and src/tools/search-codebase.ts for consistency.
- Streamlined conditional object construction in src/tools/search-codebase.ts for clarity.
@PatrickSys PatrickSys merged commit 7581fba into master Feb 21, 2026
3 checks passed
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