Skip to content

Follow-up to #6762: full_text_search still has no upper bound on limit, and set_server_setting accepts a missing required value as "" #6837

Closed

Description

@ruispereira

Follow-up to #6762. Two MCP tool-input gaps that the #6762 hardening did not actually close.

1. full_text_search has no upper bound on limit

mcp/src/main/java/com/arcadedb/mcp/tools/FullTextSearchTool.java:79-82 declares the property with only default and description - no minimum, no maximum - and :96-98 enforces only the lower bound:

final int limit = args.getInt("limit", DEFAULT_LIMIT);
if (limit < 1)
  throw new IllegalArgumentException("'limit' must be at least 1, got " + limit);

Compare the sibling that #6762 did fix, QueryTool.java:39-44, :82-83:

private static final int MAX_LIMIT = 100_000;
...
if (limit < 1 || limit > MAX_LIMIT)

The value goes straight to FullTextSearch.search(typeIndex, queryText, limit) (:110), and LSMTreeFullTextIndex.buildScoredCursor bounds the per-bucket heap only when limit < scoreMap.size() (engine/src/main/java/com/arcadedb/index/fulltext/LSMTreeFullTextIndex.java:662), so a huge limit degenerates to "return every match". The result loop's only guard is if (results.length() >= limit) break; (:124), so every hit is loaded via database.lookupByRID, serialized, and accumulated into the reply's JSONArray.

Repro:

tools/call full_text_search {"database":"db","indexName":"Article[content]","queryText":"a","limit":2147483647}

returns all N matching documents, fully serialized, in one MCP text block: O(N) record loads and O(N) documents held in heap at once, from a read-only non-root MCP caller.

Note that #6762's description listed the full-text tool among the tools that "all cap their windows". FullTextSearchTool:97-98 only rejects < 1, so that part was inaccurate and the gap is still open. MCPServerPluginTest.fullTextSearchRejectsNonPositiveLimit (:2455-2476) covers only the lower bound, and Issue6762ToolInputBoundsTest.theDeclaredSchemaMatchesTheEnforcedWindow (:117-125) asserts that invariant for query only - which full_text_search violates, since its schema declares no window at all.

Fix: add a MAX_LIMIT (the sibling hybrid tool already caps its full-text leg at HybridSearchTool.MAX_LEG_CANDIDATES = 1_000 via legLimit(k)), reject limit > MAX_LIMIT next to the existing check, and declare minimum/maximum on the property so a client can pre-validate. Extending Issue6762ToolInputBoundsTest to every tool with a window would prevent the next one.

2. set_server_setting declares value required, then defaults it to ""

mcp/src/main/java/com/arcadedb/mcp/tools/SetServerSettingTool.java:50 marks both members required:

.put("required", new JSONArray().put("key").put("value"))

but :63-67 reads them with empty-string defaults and re-checks only the key:

final String key = args.getString("key", "");
final String value = args.getString("value", "");

if (key.isEmpty())
  throw new IllegalArgumentException("Setting key is required");

So an absent or empty value reaches server.getConfiguration().setValue(key, value) (:75), and ContextConfiguration.setValue stores it with no type validation (engine/src/main/java/com/arcadedb/ContextConfiguration.java:101-106).

Repro (as root):

tools/call set_server_setting {"key":"arcadedb.asyncWorkerThreads"}

returns isError:false with {"newValue":"","message":"Setting 'arcadedb.asyncWorkerThreads' updated successfully."}, leaving "" in the ContextConfiguration for a numeric key. The next read via getValueAsInteger/getValueAsLong does Integer.parseInt(v.toString().trim()) (ContextConfiguration.java:191-203) and throws NumberFormatException inside whatever component performs it - a failure surfacing far from the call that caused it. And because the model gets a success envelope for a call its own schema says was malformed, it has no reason to retry with a value.

The HTTP twin does refuse the value-less form (PostServerCommandHandler.setServerSetting, :904-917, raises "Expected "), so this is not a deliberate parity choice.

Fix: mirror the key check (if (value.isEmpty()) throw new IllegalArgumentException("'value' is required");), or route both members through MCPToolUtils.requireString as the newer tools do. ProfilerStartTool:67-68 already documents the principle: "The declared schema range is advisory ... so re-check it here".

Also checked, clean

For the record, since it narrows where to look next: metrics/ and tracing/ are symmetric on plugin stop (registry removed and closed, the tracing handler wrapped in DeactivatableObservationHandler because ObservationRegistry has no remove API, the LogManager trace-context supplier cleared), hold no per-database meter registration, use no user-derived meter tag, and do no unconditional string formatting on a hot path. MCP protocol framing/lifecycle and per-caller authorization on every server-scoped tool are present and test-asserted.

Activity

  1. added this to the 26.9.1 milestone on Aug 27, 2026
  2. added
    mcp
    on Aug 27, 2026
  3. self-assigned this
    on Aug 28, 2026
  4. added 4 commits that reference this issue on Aug 28, 2026
  5. robfrank commented on Aug 28, 2026

    @robfrank
    Collaborator

    Fixed in #6874 (merged).

    You were right that #6762 did not close this. full_text_search still accepted any limit, and since every hit it returns is loaded and serialized into one reply, a huge limit meant "return every matching document in a single message" — it is now capped at 1,000, and the tool's schema declares that window so a client can reject the call before sending it. The same half-bounded shape turned up in efSearch on vector_search and hybrid_search, which is now capped too.

    set_server_setting no longer treats a missing value as an empty string: an absent value is rejected, and an empty one is rejected for any setting that is not a string, so a numeric key can no longer be left holding "" for some later reader to trip over. An empty string still works for string settings, which is how you clear one.

    The regression test generalises this rather than covering only the two tools: every numeric input across the whole tool surface must now declare both ends of its window, so the next tool that forgets one fails CI instead of shipping. One gap is deliberately left open and tracked in #6875 — a non-empty but unparseable value is still stored, and fixing that first requires settling a disagreement between two config read paths about what parses.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugmcp

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions