feat(mcp): add code navigation tools (code_outline / code_search / code_expand)#2146
Merged
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
1d6754f to
262d13e
Compare
Adds three code-navigation MCP tools backed by tree-sitter AST parsing: - code_outline: show file symbol structure with line ranges - code_search: case-insensitive symbol search across files (≤200) - code_expand: return full source of a named symbol or qualified method All language extractors now populate line_start/line_end from node.start_point / end_point (was always 0 before). code_search matching: queries containing '.' match the full qualified name (e.g. 'Greeter.greet'); plain queries match leaf name only, avoiding false positives on class-prefixed symbols. _filter_code_uris: cap triggers only when a 201st entry exists; exactly 200 files no longer mis-reports capped=True. Tests: 27 pure-function unit tests + 31 MCP endpoint unit tests; tests/parse/run_code_tests.py provides a stub loader to run parse tests without the full openviking dependency stack. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mijamind719
approved these changes
May 21, 2026
r266-tech
added a commit
to r266-tech/OpenViking
that referenced
this pull request
May 21, 2026
r266-tech
added a commit
to r266-tech/OpenViking
that referenced
this pull request
May 21, 2026
qin-ctx
pushed a commit
that referenced
this pull request
May 22, 2026
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.
Three new MCP tools backed by the existing @mcp.tool() endpoint, letting agents navigate code via structural outlines, leaf-name symbol search, and targeted symbol expansion — all operating on viking:// URIs only.
New code_tools.py pure-formatter module turns CodeSkeleton into the three agent-facing text views.
All 9 language extractors (Python, JS/TS, Go, Rust, Java, C/C++, C#, PHP, Lua) now populate line_start / line_end on every class, method, and function via tree-sitter's start_point / end_point (1-indexed). Skeleton dataclasses default these fields to 0 for back-compat.
code_search caps at 200 files (warns the agent on overflow) and uses Semaphore(10) for fs.read concurrency, matching the existing read tool.
Extension filter is applied before any fs.read so unsupported files (e.g. *.md) never hit storage.
Full coverage: 18 pure-function tests in tests/parse/test_code_tools.py plus integration tests in tests/server/test_mcp_endpoint_code.py for URI validation, filtering, capping, and the three tool entry points.
Testing
Checklist
Screenshots (if applicable)
Additional Notes