-
Notifications
You must be signed in to change notification settings - Fork 188
Description
Problem Statement
I am experimenting with the Built-in MCP server for query-based search, following this blog post:
https://opensearch.org/blog/introducing-mcp-in-opensearch/
While basic search works, count-style queries do not work as expected when using SearchIndexTool, because the tool does not return search metadata, specifically hits.total.value.
Example query,
{
"size": 0,
"track_total_hits": true,
"query": {
"range": {
"product_id": {
"gt": 8
}
}
}
}
When using "track_total_hits": true directly with OpenSearch, the response includes total hit metadata like:
"hits": {
"total": {
"value": 17000,
"relation": "eq"
},
"max_score": null,
"hits": []
}
Actual behavior with Built-in MCP SearchIndexTool
But Built-in MCP SearchIndexTool only returns document-level results as described in the documentation: https://docs.opensearch.org/latest/ml-commons-plugin/agents-tools/tools/search-index-tool/
Example tool response shape:
{
"_index": "test",
"_source": {}
}
There is no hits.total.value or equivalent metadata, which makes it impossible to implement count queries using SearchIndexTool.
Implementation
I registered the SearchIndexTool using the zero-configuration example in MCP registration API described here:
https://docs.opensearch.org/latest/ml-commons-plugin/api/mcp-server-apis/register-mcp-tools/#example-request-zero-configuration-tools
It is unclear whether:
- the input_schema is missing required fields, or
- the Built-in MCP server intentionally strips search metadata from the response
There does not appear to be a documented way to request hits.total or other search metadata from SearchIndexTool.
How it worked before
Previously, I was using the Standalone MCP server instead of the Built-in MCP server.
Key differences:
- The Standalone MCP server provides a dedicated
CountTool, implemented using the_count API. - Also the Standalone MCP
SearchIndexToolreturns full search responses, including hits.total.value.
Summary / Issue
- Built-in MCP SearchIndexTool does not return hits.total.value
- Count-style queries (size: 0, track_total_hits: true) are not supported in practice
- There is no Built-in MCP equivalent of CountTool