Skip to content

Conversation

@PiotrTrzpil
Copy link

Summary

This PR adds optional include_context and context_lines parameters to location-returning tools. When enabled, results include surrounding source code lines with the target line marked, reducing the need for separate file reads when Claude Code uses cclsp.

Tools updated:

  • find_definition
  • find_references
  • find_workspace_symbols
  • find_implementation
  • get_incoming_calls
  • get_outgoing_calls

New parameters:

  • include_context (boolean, default: false) - Whether to include source code context
  • context_lines (number, default: 2) - Lines of context before and after target

Example output with context:

/path/to/file.ts:42:5
  40 | function foo() {
  41 |   const x = 1;
> 42 |   return x;
  43 | }

Motivation

When Claude Code uses cclsp to find definitions or references, it typically needs to make a follow-up Read call to see the actual code at each location. By including context directly in the response, we can eliminate these extra round-trips, making code navigation faster and more efficient.

Test plan

  • Added unit tests for getCodeContext() and formatLocationWithContext() in src/utils.test.ts
  • All existing tests pass
  • TypeScript compiles without errors

🤖 Generated with Claude Code

Adds optional `include_context` and `context_lines` parameters to the following tools:
- find_definition
- find_references
- find_workspace_symbols
- find_implementation
- get_incoming_calls
- get_outgoing_calls

When `include_context` is true, results include surrounding source code lines
with the target line marked, reducing the need for separate file reads.

Example output with context:
```
/path/to/file.ts:42:5
  40 | function foo() {
  41 |   const x = 1;
> 42 |   return x;
  43 | }
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant