Skip to content

feat: expose analysis and indexing tools over MCP#151

Merged
ArtemisMucaj merged 2 commits into
mainfrom
claude/mcp-server-tools-DI9yj
Jun 6, 2026
Merged

feat: expose analysis and indexing tools over MCP#151
ArtemisMucaj merged 2 commits into
mainfrom
claude/mcp-server-tools-DI9yj

Conversation

@ArtemisMucaj

@ArtemisMucaj ArtemisMucaj commented Jun 5, 2026

Copy link
Copy Markdown
Owner

The MCP server previously exposed only search_code, analyze_impact,
get_symbol_context, and query_graph. Wire up the remaining read-only
analysis use cases plus repository indexing so AI clients can reach the
same capabilities as the CLI:

  • list_repositories (also serves as stats)
  • list_features / get_feature / get_impacted_features
  • file_uses (cross-repo / file dependency edges)
  • list_clusters / get_file_cluster / architecture_overview
  • index_repository

Each tool delegates to the existing container use cases and serialises
the domain result as JSON (architecture_overview returns Markdown).
Update the server instructions and README tool table to match.

Summary by CodeRabbit

  • Documentation

    • Extended MCP Server tool documentation with newly available capabilities.
  • New Features

    • Repository listing with file and language statistics.
    • Feature discovery, lookup, and change impact analysis.
    • Cross-repository file dependency analysis.
    • Architectural clustering and overview generation.
    • Repository indexing with re-indexing support.

The MCP server previously exposed only search_code, analyze_impact,
get_symbol_context, and query_graph. Wire up the remaining read-only
analysis use cases plus repository indexing so AI clients can reach the
same capabilities as the CLI:

- list_repositories (also serves as stats)
- list_features / get_feature / get_impacted_features
- file_uses (cross-repo / file dependency edges)
- list_clusters / get_file_cluster / architecture_overview
- index_repository

Each tool delegates to the existing container use cases and serialises
the domain result as JSON (architecture_overview returns Markdown).
Update the server instructions and README tool table to match.
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Linter diff in the way? Review this PR in Change Stack to focus on meaningful changes and expand context only when needed.

Review Change Stack

Warning

Review limit reached

@ArtemisMucaj, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 13 minutes and 8 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 046bb447-4fe2-4078-ba5f-a44bef7f7340

📥 Commits

Reviewing files that changed from the base of the PR and between 44e3196 and 83f231f.

📒 Files selected for processing (2)
  • README.md
  • src/connector/adapter/mcp/server.rs
📝 Walkthrough

Walkthrough

This PR extends the MCP server with nine new tools for repository analysis: listing repositories with language breakdowns, querying and filtering execution features, analyzing cross-repository file dependencies, inspecting code clusters, generating architecture overviews, and indexing repositories. Documentation and type contracts are added accordingly.

Changes

MCP Server Tool Extension

Layer / File(s) Summary
Input/output contracts and imports
src/connector/adapter/mcp/server.rs
Adds FileEdge to imports and defines input structs for all nine new tools (ListRepositoriesInput, ListFeaturesInput, GetFeatureInput, ImpactedFeaturesInput, FileUsesInput, ListClustersInput, GetFileClusterInput, ArchitectureOverviewInput, IndexRepositoryInput) plus output structs (FileUsesResult, IndexRepositoryResult), along with default_features_limit() helper.
MCP tool handler implementations
src/connector/adapter/mcp/server.rs
Implements all nine tool handlers: list_repositories returns file/chunk counts and language stats; list_features, get_feature, and get_impacted_features expose execution feature lookup and impact analysis; file_uses resolves repository identifiers, builds dependency graphs, filters edges, and returns sorted results with totals; list_clusters and get_file_cluster expose Leiden clustering membership; architecture_overview generates Markdown descriptions; index_repository indexes with configurable vector storage backend and returns stats.
Documentation, metadata, and supporting refactoring
README.md, src/connector/adapter/mcp/server.rs
Expands README "Exposed tools" table with new tool entries and argument details; updates get_info().instructions to enumerate new tools; minor formatting refactors in query_graph's InheritorsOf and ChildrenOf match arms to rewrap secondary query logic without changing behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ArtemisMucaj/codesearch#38: Both PRs modify the same MCP server implementation, with this PR extending the initial search_code tool by adding nine new query and analysis endpoints.

Poem

🐰 Nine new tools now grace the server's hand,
To search through repos scattered cross the land,
From features found to clusters bright and clear,
A rabbit's gift to make codebase shine here! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: exposing analysis and indexing tools over MCP, which aligns with adding multiple new MCP tools and endpoints as detailed in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/mcp-server-tools-DI9yj

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/connector/adapter/mcp/server.rs`:
- Around line 890-918: The index_repository handler currently passes arbitrary
input.path into use_case.execute; before calling execute, canonicalize the path
(std::fs::canonicalize) and verify it is contained within an allowlist of
trusted roots (e.g., a configured Vec<PathBuf> from
self.container.trusted_roots() or an admin-only gate like
self.container.admin_mode()); also reject paths that escape via symlinks by
comparing the canonicalized path with each allowed_root.canonicalize()? and
ensuring canonicalized_path.starts_with(allowed_root) — if validation fails
return an appropriate McpError (permission_denied or internal_error) instead of
calling use_case.execute, otherwise pass the canonicalized safe path to
use_case.execute.
- Around line 173-175: Clamp the incoming list_features.limit on the server to a
safe maximum instead of trusting the raw MCP param: introduce a
MAX_FEATURES_LIMIT constant and, where the request is handled (references: the
struct field with #[serde(default = "default_features_limit")] pub limit: usize
and the code paths that read list_features.limit), replace direct use of
input.limit with min(input.limit, MAX_FEATURES_LIMIT) and ensure
default_features_limit returns a sane default under that cap; apply the same
clamping change to the other occurrence mentioned (the second list_features
handling block around the other instance).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ef6583e-fef0-4e2a-90ec-faad572f5094

📥 Commits

Reviewing files that changed from the base of the PR and between a0ba43e and 44e3196.

📒 Files selected for processing (2)
  • README.md
  • src/connector/adapter/mcp/server.rs

Comment thread src/connector/adapter/mcp/server.rs
Comment thread src/connector/adapter/mcp/server.rs Outdated
Address PR review feedback:

- Clamp the caller-supplied list_features `limit` to a server-side
  MAX_FEATURES_LIMIT (100), mirroring search_code's MAX_LIMIT, so a huge
  value cannot trigger unbounded call-graph traversal and serialization.
- Remove the index_repository tool. Indexing an arbitrary filesystem path
  over MCP is a data-exfiltration risk in public HTTP deployments; keep
  indexing a CLI-only operation.
@ArtemisMucaj ArtemisMucaj merged commit 237b6da into main Jun 6, 2026
2 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