feat(mcp): add list-indexes discovery tool (RAAE-1605)#630
Open
vishal-bala wants to merge 2 commits into
Open
Conversation
Add an always-registered, read-only `list-indexes` MCP tool so clients can enumerate the logical indexes a multi-index server exposes and choose the right one before calling search-records or upsert-records. For each configured binding the tool returns the logical id, an optional description, whether upsert is available (reflecting both the global --read-only flag and the per-index read_only policy), the shared filterable fields, and any explicitly configured runtime limits. Fields are derived from the binding's already-inspected effective schema rather than user-declared metadata; the vector field and the configured default embed-source text field are omitted because they are implementation inputs, not things a client filters on. The Redis index name (redis_name) is never exposed. Limits are surfaced only when explicitly set in config (detected via the runtime model's model_fields_set), so the output reflects deliberate overrides rather than defaults. - New redisvl/mcp/tools/list_indexes.py with list_indexes() + register_list_indexes_tool(). - Registered unconditionally in the server's tool registration, alongside search/upsert. - Output is deterministic and ordered by configured binding. - TDD: unit coverage for field omission, description/limits inclusion rules, redis_name secrecy, read-only reflection, and registration; integration test verifying fields are derived from the inspected schema across a vector and a fulltext binding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Collaborator
Author
|
CI tests are failing due to flaky issues being fixed by redis-developer/sql-redis#39 |
Replace the opaque `rt: Any` parameters in list_indexes.py with the concrete `BindingRuntime` type and the clearer name `binding_runtime`, and type the `server` parameters as `RedisVLMCPServer` (via a TYPE_CHECKING import to avoid the server<->tools import cycle). No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Motivation
Once a single MCP server can expose multiple logical indexes (RAAE-1604), clients need a lightweight way to discover what's available so they can pick the right index instead of guessing. This PR (RAAE-1605) adds an always-registered, read-only
list-indexestool for exactly that, and it grounds discovery in the schema the server already inspected at startup rather than asking users to re-declare field metadata in config.Implementation
The new tool (
redisvl/mcp/tools/list_indexes.py) returns one entry per configured binding, in configured order: the logicalid, an optionaldescription, anupsert_availableflag, the shared filterablefields, and — only when explicitly configured — alimitsobject.upsert_availableis simplynot effective_read_only, so it already reflects both the global--read-onlyflag and the per-indexread_onlypolicy resolved at startup. Thefieldslist is built from the binding's effective (inspected + overridden) schema that already lives on itsBindingRuntime, so the output stays consistent with what the index actually contains; the vector field and the configured default embed-source text field are omitted because they are implementation inputs rather than fields a client would filter on. The Redis index name (redis_name) is deliberately never exposed. Limits are included only when the operator set them explicitly — detected via the runtime model'smodel_fields_set— so defaults don't masquerade as deliberate overrides; per the contract this coversmax_limitandmax_upsert_records.The tool is registered unconditionally during the server's tool registration (alongside
search-recordsand the conditionally-registeredupsert-records) and is gated by the same read scope as search when auth is enabled, since it is read-only.Verification
mypyclean;black/isortformatted.redis_namesecrecy, read-only reflection, single- and multi-binding output, and tool registration.🤖 Generated with Claude Code
Note
Low Risk
Read-only metadata from in-memory binding state; no new config or data mutations beyond existing MCP tool registration.
Overview
Adds a read-only
list-indexesMCP tool so clients can discover logical indexes on multi-binding servers before callingsearch-recordsorupsert-records.Each entry includes the binding
id, optionaldescription,upsert_available(fromeffective_read_only), filterablefieldsderived from the startup-inspected schema (vector and default embed-source text fields omitted), andlimitsonly whenmax_limit/max_upsert_recordswere explicitly set.redis_nameis never returned. The tool is always registered at startup and uses the same read scope as search when auth is enabled.Reviewed by Cursor Bugbot for commit 74ce2e3. Bugbot is set up for automated code reviews on this repo. Configure here.