OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Feature]: expose since/until/time_field in the MCP find and search tools

Open zuoanCo opened this issue 3 weeks ago • 3 comments

Summary

The REST retrieval endpoints already accept since / until / time_field:

  • POST /api/v1/search/find and POST /api/v1/search/search (FindRequest / SearchRequest)
  • the Python SDK through FindOptions / SearchOptions
  • the TypeScript SDK through FindOptions / SearchOptions

The MCP find and search tools do not. An MCP client therefore cannot express a time window as a filter and has to bake it into the query text instead.

That costs a model round-trip on every call, and it is not deterministic: the model may phrase the window loosely, and the result is then bounded by the semantic match rather than by the timestamp. It also means the same operation has a different contract depending on whether the caller speaks HTTP or MCP - the same divergence that #2990 reported for context_type and that was fixed for that field only.

Proposal

Add the three parameters to the MCP tools and compile them into the same metadata filter the REST route builds (openviking/utils/search_filters.py::merge_search_filter):

Tool New parameters Notes
find since, until, time_field Applies to the item-level retrieval path and to the context_type="skill" package path.
search since, until, time_field Applies to both mode="list" and mode="context".

time_field accepts updated_at (default) or created_at, matching the REST contract.

Why this shape

  • Deterministic. The window becomes a metadata predicate evaluated by the server instead of a phrase the model has to get right.
  • No extra model call. The filter is compiled into the existing retrieval filter, so the request still performs the same single embedding and the same retrieval. The window only narrows the candidate set, which makes the call cheaper rather than more expensive.
  • Same contract on every surface. REST, the SDKs, and MCP then describe the same operation the same way.

Acceptance

  • find(query="...", since="7d") returns only the entries inside the window.
  • find(query="...", since="7d", time_field="created_at") filters on the creation time instead.
  • search(query="...", mode="context", since="7d") applies the same window in context mode.
  • An inverted window and an unknown time_field are rejected with the tool's usual argument error.

zuoanCo avatar Nov 10 '26 02:11 zuoanCo

An existing implementation is open at #7167 (head c9ac4f100e301299ec1719291fe4c465dd493788).

Its current diff exposes since, until, and time_field, reuses merge_search_filter, and applies the result to general and skill-package find plus both search modes. It also includes native-index coverage for filtering before limit, invalid-window checks, and English/Chinese documentation.

I reviewed that diff and its current PR state; I have not rerun its tests.

r266-tech avatar Nov 10 '26 02:11 r266-tech

Implemented in https://github.com/volcengine/OpenViking/pull/7324 - the MCP find and search tools accept since / until / time_field and compile them into the same metadata filter the REST route builds.

zuoanCo avatar Nov 10 '26 03:11 zuoanCo

这个pr改动太多了,我预期应该就加个参数就ok,现在还不能合入

qin-ctx avatar Nov 12 '26 13:11 qin-ctx