# Plan: Tree-Sitter C/C++ MCP Tools

## Overview
Add tree-sitter-based C and C++ parsing to mcp_client with skeleton and outline tools.

## Phase 1: Dependencies
Focus: Add tree-sitter C/C++ grammars

- [ ] Task 1.1: Add tree-sitter-c and tree-sitter-cpp to pyproject.toml
  - WHERE: pyproject.toml:16-17
  - WHAT: Add `"tree-sitter-c>=0.23.0", "tree-sitter-cpp>=0.3.0"` to dependencies
  - HOW: Edit dependencies array
  - SAFETY: No breaking changes

## Phase 2: ASTParser Extensions
Focus: Extend ASTParser to support C/C++ languages

- [ ] Task 2.1: Modify ASTParser.__init__ to accept "c" and "cpp" languages
  - WHERE: src/file_cache.py:22-28
  - WHAT: Add language loading for tree-sitter-c and tree-sitter-cpp
  - HOW: Import tree_sitter_c, tree_sitter_cpp; load Language(tree_sitter_c.language()) etc.
  - SAFETY: Maintain existing Python support

- [ ] Task 2.2: Implement C skeleton extraction
  - WHERE: src/file_cache.py (new method or extend get_skeleton)
  - WHAT: Extract function_definition, struct_specifier, enum_specifier, typedef, union_specifier
  - HOW: Tree-sitter node traversal similar to Python pattern
  - SAFETY: New method, no modifications to existing

- [ ] Task 2.3: Implement C++ skeleton extraction
  - WHERE: src/file_cache.py
  - WHAT: Add class_specifier, template_declaration, access_specifier, namespace_specifier
  - HOW: Extend C skeleton logic with C++ specific nodes
  - SAFETY: New method

- [ ] Task 2.4: Implement code outline for C and C++
  - WHERE: src/file_cache.py
  - WHAT: Return hierarchical structure with line ranges (matching py_get_code_outline format)
  - HOW: Similar to Python get_code_outline pattern
  - SAFETY: New method

## Phase 3: MCP Tool Integration
Focus: Add tools to mcp_client dispatch

- [ ] Task 3.1: Add ts_c_get_skeleton tool
  - WHERE: src/mcp_client.py (add function and register)
  - WHAT: Tool that calls file_cache ASTParser for C skeleton
  - HOW: Follow py_get_skeleton pattern
  - SAFETY: New tool, no modifications to existing

- [ ] Task 3.2: Add ts_cpp_get_skeleton tool
  - WHERE: src/mcp_client.py
  - WHAT: Tool that calls file_cache ASTParser for C++ skeleton
  - HOW: Same as above with cpp language
  - SAFETY: New tool

- [ ] Task 3.3: Add ts_c_get_code_outline tool
  - WHERE: src/mcp_client.py
  - WHAT: Tool that calls file_cache for C code outline
  - HOW: Follow py_get_code_outline pattern
  - SAFETY: New tool

- [ ] Task 3.4: Add ts_cpp_get_code_outline tool
  - WHERE: src/mcp_client.py
  - WHAT: Tool that calls file_cache for C++ code outline
  - HOW: Same as above with cpp language
  - SAFETY: New tool

- [ ] Task 3.5: Register tools in get_tool_schemas
  - WHERE: src/mcp_client.py:998-1000
  - WHAT: Add schemas for all 4 new tools
  - HOW: Append to MCP_TOOL_SPECS list
  - SAFETY: Append only

## Phase 4: Tests
Focus: Verify C/C++ tools work correctly

- [ ] Task 4.1: Write tests for ts_c_get_skeleton
  - WHERE: tests/test_ts_c_tools.py (new file)
  - WHAT: Test C skeleton extraction on sample C code
  - HOW: Use pytest with sample C file content
  - SAFETY: New test file

- [ ] Task 4.2: Write tests for ts_cpp_get_skeleton
  - WHERE: tests/test_ts_cpp_tools.py (new file)
  - WHAT: Test C++ skeleton extraction on sample C++ code
  - HOW: Use pytest with sample C++ code
  - SAFETY: New test file

- [ ] Task 4.3: Write tests for code outline tools
  - WHERE: tests/test_ts_c_tools.py / test_ts_cpp_tools.py
  - WHAT: Test line range extraction
  - HOW: Assert correct line numbers
  - SAFETY: New tests

- [ ] Task 4.4: Integration test - verify tools dispatch correctly
  - WHERE: tests/test_mcp_client.py
  - WHAT: Test dispatch of ts_c_* and ts_cpp_* tools
  - HOW: Mock file_cache, verify correct function called
  - SAFETY: Additive test
