Commit 6bd9d30
feat(mcp): add list-indexes discovery tool (RAAE-1605) (#630)
> Stacked on #629 (RAAE-1604). Review/merge that first; this PR targets
the 1604 branch so the diff is scoped to the discovery tool.
## Motivation
Once a single MCP server can expose multiple logical indexes
([RAAE-1604](https://redislabs.atlassian.net/browse/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](https://redislabs.atlassian.net/browse/RAAE-1605)) adds an
always-registered, read-only `list-indexes` tool 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 logical `id`, an optional
`description`, an `upsert_available` flag, the shared filterable
`fields`, and — only when explicitly configured — a `limits` object.
`upsert_available` is simply `not effective_read_only`, so it already
reflects both the global `--read-only` flag and the per-index
`read_only` policy resolved at startup. The `fields` list is built from
the binding's effective (inspected + overridden) schema that already
lives on its `BindingRuntime`, 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's
`model_fields_set` — so defaults don't masquerade as deliberate
overrides; per the contract this covers `max_limit` and
`max_upsert_records`.
The tool is registered unconditionally during the server's tool
registration (alongside `search-records` and the
conditionally-registered `upsert-records`) and is gated by the same read
scope as search when auth is enabled, since it is read-only.
- Output is deterministic and ordered by configured binding.
- No new configuration surface or settings are required.
## Verification
- `mypy` clean; `black`/`isort` formatted.
- New unit coverage: field omission (vector + embed-source),
description/limits inclusion rules, `redis_name` secrecy, read-only
reflection, single- and multi-binding output, and tool registration.
- New integration test starts a real two-binding server (one vector, one
fulltext) and asserts the discovered fields come from the inspected
schema and follow the omission rules.
- Full MCP suite green: 178 unit + 45 integration (2 skipped on
Redis-version gates) against Redis 8.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
[RAAE-1604]:
https://redislabs.atlassian.net/browse/RAAE-1604?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[RAAE-1605]:
https://redislabs.atlassian.net/browse/RAAE-1605?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Read-only discovery metadata with no new config; behavior is additive
and gated like existing search tools when auth is enabled.
>
> **Overview**
> Adds a read-only **`list-indexes`** MCP tool so clients can discover
logical indexes on multi-binding servers before calling
**`search-records`** or **`upsert-records`**.
>
> The tool is **always registered** during `_register_tools` (alongside
search; upsert remains conditional). Each binding is returned in config
order with **`id`**, optional **`description`**, **`upsert_available`**
(`not effective_read_only`), filterable **`fields`** from the
startup-inspected schema (vector and default embed-source text omitted),
and **`limits`** only when **`max_limit`** / **`max_upsert_records`**
were explicitly set. **`redis_name`** is never exposed; empty bindings
raise **`RuntimeError`** like other pre-startup paths. When auth is on,
the tool uses the same **read scope** as search.
>
> Unit and integration tests cover payload rules, registration, and a
two-binding startup scenario.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
45ce686. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent f80e98f commit 6bd9d30
5 files changed
Lines changed: 409 additions & 0 deletions
File tree
- redisvl/mcp
- tools
- tests
- integration/test_mcp
- unit/test_mcp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| 250 | + | |
| 251 | + | |
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
730 | 731 | | |
731 | 732 | | |
732 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
0 commit comments