8000 feat(mcp): support autoindex prefixes in xerj_search by Jarvis636431 · Pull Request #2137 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

feat(mcp): support autoindex prefixes in xerj_search - #2137

Merged
xerj-org merged 4 commits into
xerj-org:mainfrom
Jarvis636431:feature/mcp-search-prefix
Oct 22, 2026
Merged

xerj-org merged 4 commits into
xerj-org:mainfrom
Jarvis636431:feature/mcp-search-prefix

Conversation

@Jarvis636431
@Jarvis636431 Jarvis636431 commented Oct 22, 2026 •
Copy link
Copy Markdown
Contributor

Written by an AI coding agent (OpenAI Codex), run by @Jarvis636431.

xerj_search ignored the CLI-style prefix argument and searched the default ax-* corpus. It now accepts {"prefix":"project","query":"retry policy"} and searches project-*, using that same scope for mapping discovery and the final search. The expansion follows engine/crates/xerj-autoindex/src/search.rs:692.

Non-empty index and prefix are mutually exclusive. Empty or non-string prefixes return an MCP tool error before any HTTP request; surrounding whitespace is trimmed and null is treated as omitted. Existing explicit-index and default ax-* behavior is preserved. prefix is not forwarded into the ES request body. README, changelog, and the generated MCP schema document the argument.

Refs #2080 — prefix support only. The 8000 local xerj_def request remains unimplemented; this PR should not close the issue.

Verified

  • Before the production change, cargo test --locked -p xerj-mcp --lib search_prefix -- --nocapture failed all four new tests: the builder used /ax-*/_search, mapping discovery used GET /ax-*/_mapping, conflicting scope arguments were accepted, and invalid arguments attempted HTTP.
  • On the final rc.98 tree composed with upstream 28de5cfc, TMPDIR=/private/tmp cargo test --locked --offline -p xerj-mcp passed all 124 tests: 117 library tests and 7 integration/schema tests, with 0 failures. The new real-node test seeds both project-docs and ax-other with matching text and checks custom prefix, default scope, and explicit index for plain-string and DSL queries. The transport tests independently check both HTTP paths and zero requests on invalid scope arguments. A new combination regression proves prefix-scoped code searches retain upstream's test-path demotion.
  • TMPDIR=/private/tmp cargo test --locked --offline --profile ci-test -p xerj-mcp --lib search_prefix passed all 5 focused regressions on the composed tree in the optimized CI test profile.
  • cargo fmt --all, cargo fmt --all --check, and cargo clippy --locked --offline -p xerj-mcp --all-targets -- -D warnings passed.
  • cargo build --locked --offline --release -j 32 -p xerj-mcp passed on the composed tree.
  • cargo build --locked --offline --profile ci-test -j 8 -p xerj-server -p es-yaml-runner passed on the final rc.98 tree. Against the candidate server in a fresh temporary data directory, ./target/ci-test/es-yaml-runner --url <isolated-loopback-node> --dir tests/es-compat-yaml/yaml completed with 1438 passed, 0 failed, 10 skipped (exit 0), including 75 cases under the existing catch-lenient policy. The node stopped normally (exit 0).
  • scripts/mcp-schema-check.sh --write regenerated the schema from the candidate debug xerj-mcp; subsequent checks against both debug and release binaries passed with the same 20 tools. On this macOS host a temporary Python timeout wrapper supplied the script's missing timeout command; no repository script was changed.

Environment and site checks

The first library-test run with the host's default temporary directory failed the existing loopback_url_with_no_auth_picks_up_the_local_admin_key assertion because /var/... and /private/var/... were compared as strings. The complete crate suite passed with TMPDIR=/private/tmp; that unrelated test was not changed.

All applicable SEO workflow checks, factcheck fixture/self-tests and content checks, the critical-level site audit, and the landing constants guard passed. After the rc.98 merge was committed, gen_sitemap.py --check matched and seo_lint.py reported 0 gate violations. No additional website changes were needed beyond the generated tool schema.

Review and limits

Started independently from upstream main e1348b4d, then merged upstream search fixes and the rc.98 release, ending at base 28de5cfc. The mapping-read overlap preserves upstream's plain-query detection and ranking path while using the resolved prefix scope for the GET. The later description/schema overlap preserves the new upstream removal tool and deletion guidance. The prefix changelog entry stays under Unreleased, not the rc.98 release. The effective diff remains five files containing only the prefix feature, its tests, docs, and generated schema. No new dependencies or tool names. Scope resolution is shared by mapping discovery and request construction, and the request is read-only. Existing index selection, DSL forwarding, lexical query shaping, auth, token budgets, and recovery behavior are preserved.

No stored-state schema, journal, migration, publication lifecycle, telemetry, execution identity, optimization, feature gate, cluster behavior, or operational recipe changes. The durable-state/migration, optional-accelerator, identity, telemetry, feature-gate, performance, cluster, and operational-recipe audits are therefore not applicable. Tests use isolated temporary data directories and loopback endpoints; no external models or corpus downloads are required by the new coverage.

Not verified: Windows/Linux execution or external MCP clients. No performance claims; no claim that #2080's definition-lookup work is complete.

Agents using the CLI's --prefix vocabulary over MCP silently searched ax-*
because xerj_search only resolved its index argument. Resolve prefix as
<prefix>-* for both the mapping pre-read and the actual search, and refuse
ambiguous scope or malformed prefix arguments before HTTP. Preserve the
existing explicit-index and default behavior.

Four targeted regressions failed before the fix, including the observed
GET /ax-*/_mapping and POST /ax-*/_search requests for a custom prefix.
The complete MCP crate suite passes with 113 tests. A real-node regression
seeds two corpora and checks prefix/default/index isolation with both plain
and DSL queries; the transport fixture checks that invalid scope makes no
HTTP requests. Document the contract and regenerate the published schema
from the candidate release MCP binary. Formatting and scoped Clippy pass.
Full build and compatibility evidence is recorded in the pull request.

Written by an AI coding agent (OpenAI Codex), run by Jarvis636431.
Refs xerj-org#2080: prefix support only; local definition lookup remains open.
Upstream merged xerj-org#2123, xerj-org#2124, xerj-org#2125 and xerj-org#2128 while the prefix work was
being validated. xerj-org#2125 changes the same mapping pre-read in xerj_search.
Resolve that overlap by keeping upstream's plain-query detection and
response demotion, while passing the already-validated prefix scope to the
mapping read. Preserve the upstream authorship and history through a merge.

Add a custom-prefix/code-corpus regression proving the test-path penalty
still applies. On the composed tree the MCP crate suite passes 123 tests
(116 library and 7 integration/schema tests); scoped strict Clippy passes.
The effective diff against upstream still contains only prefix support,
its tests, README/changelog text, and the generated schema. Build and
conformance evidence is recorded in the pull request.

Written by an AI coding agent (OpenAI Codex), run by Jarvis636431.
Upstream published rc.98 and added the autoindex removal MCP tool during
prefix validation. Preserve that tool and the new index-deletion guidance
in the schema descriptions, and regenerate the schema from the composed
candidate's real tools/list. Keep the prefix feature under Unreleased:
it did not ship in rc.98.

Resolve only the changelog and search-index description overlap. The MCP
crate suite passes 124 tests (117 library and 7 integration/schema tests),
strict scoped Clippy passes, and the scoped release MCP build passes.
The generated schema is checked against both debug and release binaries;
all 20 upstream tools are retained. The full conformance run and explicit
environment limits are recorded in the PR. The effective contribution
remains five files and adds no tool names or dependencies.

Written by an AI coding agent (OpenAI Codex), run by Jarvis636431.
@Jarvis636431
Jarvis636431 marked this pull request as ready for review October 22, 2026 03:31
@cla-bot
cla-bot Bot commented Oct 22, 2026
Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Xerj Merger.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot Bot removed the cla-signed label Oct 22, 2026
@xerj-org
Copy link
Copy Markdown
Owner

Xerj Merger made the fix: I merged main into the branch (fast-forward, no force-push). The only conflict was CHANGELOG: your ### Added entry now sits above main's ### Fixed under [Unreleased]. No code changes.

Review: prefix is mutually exclusive with index. Empty or non-string prefixes are rejected before any HTTP call, and the default stays ax-*. This matches xerj search --prefix.

Local CI on main + #2137 + #2138 (same tree as this head): fmt, clippy --workspace --all-targets -D warnings, and cargo test --profile ci-test --workspace all passed. GitHub Build + Test also passed on the previous head. Thank you!

@xerj-org
xerj-org merged commit 3632638 into xerj-org:main Oct 22, 2026
8 of 9 checks passed
cursor Bot pushed a commit that referenced this pull request Oct 23, 2026
Motivation: issue #2080. Agents pass the --prefix they used with
xerj autoindex. MCP xerj_search grew a prefix argument in #2137, but
it built {prefix}-* from the raw string. Autoindex stores a sanitized
prefix (My_Proj becomes my-proj), so the typed characters search a
pattern that does not exist. xerj search and xerj def had the same gap.

Root cause: three copies of format!("{prefix}-*"), and none of them
called dataset::sanitize_prefix / index_prefix_error, which is how
xerj autoindex --prefix names indices.

Change: resolve_prefix in xerj-autoindex is the one function. xerj
search, xerj def, and MCP xerj_search call it. My_Proj searches
my-proj-*, and a trailing -* is not part of the prefix. A prefix that
cannot name an index is refused before any request. Passing both
index and prefix is still an error. Passing neither still searches
ax-*, the CLI default when --prefix is omitted. Refusing that case
would break every caller of the default corpus (#962). The tool
description says so.

Evidence (rustc 1.97.1, from engine/, cargo --locked -j 4):
- cargo test -p xerj-autoindex --lib: 1619 passed, 0 failed, 2 ignored
- cargo test -p xerj-mcp: 117 lib tests, hub_tools, published_schema_drift
  (4), search_exact_phrase, and search_prefix, 0 failed
- cargo clippy -p xerj-autoindex --lib -- -D warnings: exit 0
- cargo clippy -p xerj-mcp --all-targets -- -D warnings: exit 0
- cargo fmt --all with rustfmt 1.97.1

Not run: a release build, and the ES-YAML suite. This does not change
the engine wire protocol; the client requests a different index pattern.

Refs #2080. The xerj_def MCP tool is #2166.

Co-authored-by: xerj-org <xerj-org@users.noreply.github.com>
xerj-team pushed a commit that referenced this pull request Oct 23, 2026
MCP agents can scope xerj_search by prefix after #2137, but still cannot
call the local definition workflow: xerj_def returns unknown tool.
The existing xerj_hub_def instead requires a named Hub pack.

Extract the CLI query/candidate-window and response-finalization helpers
in xerj-autoindex/src/def.rs. The new xerj-mcp/src/def.rs adapter uses them
after validating symbol, scope, filters, k and token budget before HTTP.
It preserves mapping guards, local kind/visibility ranking and location
deduplication, returning declarations and locators in the ES envelope.
HTTP errors remain tool errors, malformed successes are refused, and
empty hits remain success. No persistent schema or mutation path changes.

Add real-node and HTTP-fixture regressions plus a CLI/MCP parity smoke in
CI. Generate the published schema from the release binary and document
the local-vs-Hub distinction and output/filter semantics.

Before implementation, the local_def regression failed with
"unknown tool: xerj_def". Afterward, all 129 MCP tests pass, including the
five new regressions. Three real-entrypoint parity comparisons pass.
Scoped release builds, strict Clippy, rustfmt, schema drift, SEO and
workflow-timeout gates pass. ES-YAML: 1438 passed, 0 failed, 10 skipped
(75 catch-lenient), using an isolated ci-test node.

Full autoindex tests: 1621 passed, 10 failed, 5 ignored. All ten failures
also reproduce with the unmodified upstream autoindex source at b64d9cb;
they concern non-UTF8 filenames and PDF worker/spool fixtures on macOS.
No claim of a green full autoindex suite or performance improvement.

Implemented and verified with JoyCode, an AI coding agent.
85B9
@Jarvis636431
Jarvis636431 deleted the feature/mcp-search-prefix branch November 3, 2026 03:10
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

0