Skip to content

Commit d2723d7

Browse files
jonathanMLDevzho
andauthored
updated descriptions (cppalliance#81)
* updated descriptions * fixed typecheck errors * addressed ai review results * fixed test error --------- Co-authored-by: zho <jornathanm910923@gmail.com>
1 parent 32c5ac1 commit d2723d7

5 files changed

Lines changed: 29 additions & 10 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ Discovers and lists all available namespaces in the configured Pinecone index, i
258258
}
259259
```
260260

261+
### Retrieval tool decision matrix
262+
263+
Use this when choosing among overlapping retrieval tools. **Semantic vs lexical:** use `query` / `query_fast` / `query_detailed` or `query_documents` for meaning-based search; use `keyword_search` for exact or keyword-style matches on the sparse index. **Chunks vs whole documents:** use `query` / `query_fast` / `query_detailed` for ranked chunks; use `query_documents` when you need merged full-document text. **One-shot vs manual flow:** use `guided_query` to run routing, suggestion, and execution in a single call; otherwise call `suggest_query_params` before gated tools.
264+
265+
- **`query` / `query_fast` / `query_detailed`** — Semantic chunk retrieval. Requires `suggest_query_params` to be called first for the target namespace.
266+
- **`query_documents`** — Semantic search with chunks reassembled into whole documents. Requires `suggest_query_params` to be called first for the target namespace.
267+
- **`keyword_search`** — Lexical (sparse-only) search. Does not require `suggest_query_params`.
268+
- **`guided_query`** — Combines namespace routing, suggestion, and query into a single call; no prerequisite tools needed.
269+
- **`count`** — “How many …?” style counts via semantic search. Requires `suggest_query_params` before use (same gate as `query` / `query_documents`).
270+
261271
### `suggest_query_params`
262272

263273
Suggests which **fields** to request and which path to use (`count`, or hybrid query presets **fast** / **detailed** / **full** — same vocabulary as the `query` tool `preset` argument), based on the namespace’s schema (from `list_namespaces`) and the user’s natural language query. This is a mandatory flow step before `count` / `query` tools.

src/server/tools/guided-query-tool.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ function resolveGuidedToolName(
2525
return 'full';
2626
}
2727

28-
/** Register the guided_query orchestrator tool on the MCP server. */
28+
/**
29+
* Registers `guided_query` (routing + suggestion + execution in one call).
30+
* See "Retrieval tool decision matrix" in README.md for tool-selection guidance.
31+
*/
2932
export function registerGuidedQueryTool(server: McpServer): void {
3033
server.registerTool(
3134
'guided_query',
3235
{
3336
description:
34-
'Single orchestrator that runs routing + suggestion + execution in one call. ' +
35-
'Flow: optional namespace_router logic -> suggest_query_params logic -> executes count or hybrid query (fast / detailed / full presets). ' +
37+
'Combines namespace routing, suggestion, and query into a single call — no prerequisite tools needed. ' +
38+
'Single orchestrator: optional namespace_router logic -> executes count or hybrid query (fast / detailed / full presets). ' +
3639
'Returns decision_trace so behavior stays transparent and debuggable.',
3740
inputSchema: {
3841
user_query: z.string().describe('User question or intent.'),

src/server/tools/keyword-search-tool.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,18 @@ async function executeKeywordSearch(params: {
9393
return response;
9494
}
9595

96-
/** Register the keyword_search tool on the MCP server. */
96+
/**
97+
* Registers `keyword_search` (lexical/sparse-only retrieval).
98+
* See "Retrieval tool decision matrix" in README.md for tool-selection guidance.
99+
*/
97100
export function registerKeywordSearchTool(server: McpServer): void {
98101
server.registerTool(
99102
'keyword_search',
100103
{
101104
description:
102105
'Keyword (lexical/sparse-only) search over the Pinecone sparse index (default: rag-hybrid-sparse). ' +
103106
'Use for exact or keyword-style queries. Does not use semantic reranking. ' +
104-
'Call list_namespaces first to discover namespaces; suggest_query_params is optional.',
107+
'Call list_namespaces first to discover namespaces. Does not require suggest_query_params.',
105108
inputSchema: {
106109
query_text: z.string().describe('Search query text (keyword/lexical match).'),
107110
namespace: z

src/server/tools/query-documents-tool.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import { jsonErrorResponse, jsonResponse } from '../tool-response.js';
2121
*/
2222
const CHUNKS_PER_DOCUMENT = 50;
2323

24-
/** Register the query_documents tool (reassemble chunks into full documents) on the MCP server. */
24+
/**
25+
* Registers `query_documents` (reassemble chunks into full documents).
26+
* See "Retrieval tool decision matrix" in README.md for tool-selection guidance.
27+
*/
2528
export function registerQueryDocumentsTool(server: McpServer): void {
2629
server.registerTool(
2730
'query_documents',
@@ -31,7 +34,7 @@ export function registerQueryDocumentsTool(server: McpServer): void {
3134
'Always uses semantic reranking for document-level relevance (higher latency/cost than chunk-only query). ' +
3235
'Use for content analysis, summarization, or when you need full-document context. ' +
3336
'Chunks are grouped by document_number/doc_id/url, ordered by chunk_index when present (e.g. from RecursiveCharacterTextSplitter), and merged into one content per document. ' +
34-
'Mandatory flow: call suggest_query_params first. Use list_namespaces to discover namespaces.',
37+
'Requires suggest_query_params to be called first for the target namespace. Use list_namespaces to discover namespaces.',
3538
inputSchema: {
3639
query_text: z.string().describe('Search query text. Be specific for better results.'),
3740
namespace: z

src/server/tools/query-tool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ const baseSchema = {
108108
};
109109

110110
/**
111-
* Single hybrid `query` tool (replaces separate `query_fast` / `query_detailed` MCP tools).
112-
* Presets mirror the old defaults.
111+
* Registers semantic chunk query via one preset-driven `query` tool.
112+
* See "Retrieval tool decision matrix" in README.md for tool-selection guidance.
113113
*/
114114
export function registerQueryTool(server: McpServer): void {
115115
server.registerTool(
116116
'query',
117117
{
118118
description:
119-
'Hybrid semantic search (dense + sparse) with optional reranking. Mandatory flow: call suggest_query_params first. ' +
119+
'Hybrid semantic search (dense + sparse) with optional reranking. Requires suggest_query_params to be called first for the target namespace. ' +
120120
'Use preset=`fast` for low-latency retrieval without reranking and lightweight fields; `detailed` for reranked, content-oriented retrieval; `full` to set use_reranking and fields explicitly.',
121121
inputSchema: {
122122
...baseSchema,

0 commit comments

Comments
 (0)