Skip to content

Commit b594690

Browse files
jonathanMLDevzho
andauthored
Core vs Alliance MCP instructions and suggest-flow gate (cppalliance#125)
* Core vs Alliance MCP instructions and suggest-flow gate * addressed ai review * Fix instruction numbering in constants.ts --------- Co-authored-by: zho <jornathanm910923@gmail.com>
1 parent eb467ba commit b594690

19 files changed

Lines changed: 164 additions & 38 deletions

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ PINECONE_READ_ONLY_MCP_LOG_FORMAT=text
2727
# Optional: Namespace + suggestion-flow cache TTL in seconds (default: 1800 = 30min)
2828
# PINECONE_CACHE_TTL_SECONDS=1800
2929

30-
# Optional: Disable the suggest_query_params flow gate (default: false).
31-
# WARNING: turning this on bypasses the safety guard. A WARN log fires at startup.
30+
# Optional: Suggest-flow gate (PINECONE_DISABLE_SUGGEST_FLOW).
31+
# Core resolveConfig default: true (gate off). Alliance CLI default: false (gate on).
3232
# PINECONE_DISABLE_SUGGEST_FLOW=false
3333

3434
# Optional: Request timeout for Pinecone calls, in milliseconds (default: 15000)

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Tagged releases are published to npm from GitHub Actions when a **GitHub Release
1111
### Changed
1212

1313
- **Breaking (core):** `resolveConfig` requires a Pinecone index name and no longer applies Alliance index/rerank defaults. Removed exported `DEFAULT_INDEX_NAME` and `DEFAULT_RERANK_MODEL` from the package root. Rerank is opt-in when `PINECONE_RERANK_MODEL` / `rerankModel` is unset.
14+
- **Breaking (core):** `setupCoreServer` MCP `instructions` use `CORE_SERVER_INSTRUCTIONS` (no `guided_query` / `suggest_query_params`). `resolveConfig` defaults `disableSuggestFlow` to `true` so `query` / `count` / `query_documents` work without Alliance tools. Alliance CLI / `resolveAllianceConfig` unchanged: gate on by default, `ALLIANCE_SERVER_INSTRUCTIONS`.
1415
- **Alliance CLI / `resolveAllianceConfig`:** When index or rerank env/CLI values are omitted, defaults remain `rag-hybrid` and `bge-reranker-v2-m3` (API-key-only MCP configs unchanged). See [examples/alliance/.env.example](examples/alliance/.env.example).
1516
### Added
1617

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Treat **`setupCoreServer()` / `setupAllianceServer()` as one logical server per
134134
- **Generic bridge only:** `import { setupCoreServer, teardownServer, ... } from '@will-cppa/pinecone-read-only-mcp'`
135135
- **Full Alliance surface (CLI parity):** `import { setupAllianceServer, resolveAllianceConfig } from '@will-cppa/pinecone-read-only-mcp/alliance'`
136136

137-
For the **generic bridge only**, see [examples/quickstart/mcp-demo.ts](examples/quickstart/mcp-demo.ts) (`setupCoreServer` + `resolveConfig` with required `indexName`). For the **full Alliance surface**, use `resolveAllianceConfig({ apiKey, ... })` (Alliance index/rerank defaults when omitted, same as the CLI) → `setPineconeClient(new PineconeClient(...))``await setupAllianceServer(config)` → connect one MCP transport. See [examples/alliance/library-embedding-demo.ts](examples/alliance/library-embedding-demo.ts) and [docs/TOOLS.md](docs/TOOLS.md#suggest-flow-gate).
137+
For the **generic bridge only**, see [examples/quickstart/mcp-demo.ts](examples/quickstart/mcp-demo.ts) (`setupCoreServer` + `resolveConfig` with required `indexName`; suggest-flow gate **off** by default). For the **full Alliance surface**, use `resolveAllianceConfig({ apiKey, ... })` (Alliance index/rerank defaults when omitted, suggest-flow gate **on** by default, same as the CLI) → `setPineconeClient(new PineconeClient(...))``await setupAllianceServer(config)` → connect one MCP transport. See [examples/alliance/library-embedding-demo.ts](examples/alliance/library-embedding-demo.ts) and [docs/TOOLS.md](docs/TOOLS.md#suggest-flow-gate).
138138

139139
### Custom URL generators
140140

docs/CONFIGURATION.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Configuration is built from **CLI flags** (when using the binary), **environment
2323
| `logFormat` | `logFormat` / `PINECONE_READ_ONLY_MCP_LOG_FORMAT` | `text` or `json` |
2424
| `cacheTtlMs` | `cacheTtlSeconds` / `PINECONE_CACHE_TTL_SECONDS` | `1800` seconds → ms |
2525
| `requestTimeoutMs` | `requestTimeoutMs` / `PINECONE_REQUEST_TIMEOUT_MS` | `15000` |
26-
| `disableSuggestFlow` | `disableSuggestFlow` / `PINECONE_DISABLE_SUGGEST_FLOW` | `false` (bool parsing: true/1/yes/on) |
26+
| `disableSuggestFlow` | `disableSuggestFlow` / `PINECONE_DISABLE_SUGGEST_FLOW` | **Core `resolveConfig`:** `true` (gate off). **Alliance `resolveAllianceConfig` / CLI:** `false` (gate on). Bool parsing: true/1/yes/on |
2727
| `checkIndexes` | `checkIndexes` / `PINECONE_CHECK_INDEXES` | `false` |
2828

2929
**Throws** if `apiKey` or `indexName` is missing after trim.
@@ -32,10 +32,10 @@ For the full Alliance tool surface (including `suggest_query_params`, `guided_qu
3232

3333
### Core vs Alliance resolvers
3434

35-
| Resolver | When to use | Index when unset | Rerank when unset |
36-
| -------- | ------------- | ---------------- | ----------------- |
37-
| `resolveConfig` | Package root, `setupCoreServer`, quickstart | **Throws** | Omitted (no rerank) |
38-
| `resolveAllianceConfig` | Published CLI, `setupAllianceServer` | `rag-hybrid` | `bge-reranker-v2-m3` |
35+
| Resolver | When to use | Index when unset | Rerank when unset | Suggest gate when unset |
36+
| -------- | ------------- | ---------------- | ----------------- | ----------------------- |
37+
| `resolveConfig` | Package root, `setupCoreServer`, quickstart | **Throws** | Omitted (no rerank) | Off (`disableSuggestFlow: true`) |
38+
| `resolveAllianceConfig` | Published CLI, `setupAllianceServer` | `rag-hybrid` | `bge-reranker-v2-m3` | On (`disableSuggestFlow: false`) |
3939

4040
C++ Alliance deployers can copy [examples/alliance/.env.example](../examples/alliance/.env.example). Constants: `ALLIANCE_DEFAULT_INDEX_NAME` / `ALLIANCE_DEFAULT_RERANK_MODEL` from `@will-cppa/pinecone-read-only-mcp/alliance`.
4141

docs/FAQ.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Why does `query` return `FLOW_GATE`?
44

5-
Call **`suggest_query_params`** for that namespace first (within the cache TTL). Or use **`guided_query`**, which performs suggestion internally.
5+
On **Alliance** setups (`resolveAllianceConfig` / CLI), call **`suggest_query_params`** for that namespace first (within the cache TTL), or use **`guided_query`**, which performs suggestion internally. On **core** `setupCoreServer` / `resolveConfig`, the gate is **off** by default; if you enabled it (`PINECONE_DISABLE_SUGGEST_FLOW=false`), you need `suggest_query_params` or must switch to Alliance tools.
66

77
## Does `keyword_search` need `suggest_query_params`?
88

@@ -14,7 +14,7 @@ They are unified into **`query`** with `preset`: `fast`, `detailed`, or `full`.
1414

1515
## How do I disable the suggest gate for testing?
1616

17-
Set **`PINECONE_DISABLE_SUGGEST_FLOW=true`** or pass **`--disable-suggest-flow`**. Prefer fixing the client flow in production.
17+
**Core:** gate is already off via `resolveConfig` default. **Alliance:** set **`PINECONE_DISABLE_SUGGEST_FLOW=true`** or pass **`--disable-suggest-flow`**. Prefer fixing the client flow in production when using Alliance.
1818

1919
## Where are benchmarks?
2020

docs/TOOLS.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
# MCP tools reference
22

3-
The server registers **nine** tools. Unless noted, failures return MCP `isError: true` with JSON matching `ToolError` (see [MIGRATION.md](./MIGRATION.md) and [README error table](../README.md#error-responses)).
3+
Unless noted, failures return MCP `isError: true` with JSON matching `ToolError` (see [MIGRATION.md](./MIGRATION.md) and [README error table](../README.md#error-responses)).
4+
5+
## Core vs Alliance tool surface
6+
7+
| Setup | Tools | MCP instructions |
8+
| ----- | ----- | ------------------ |
9+
| `setupCoreServer` (package root) | **7:** `list_namespaces`, `namespace_router`, `count`, `query`, `keyword_search`, `query_documents`, `generate_urls` | `CORE_SERVER_INSTRUCTIONS` — no `guided_query` or `suggest_query_params` |
10+
| `setupAllianceServer` / published CLI | **9:** core tools plus `suggest_query_params`, `guided_query` | `ALLIANCE_SERVER_INSTRUCTIONS` — includes guided/suggest quickstart |
411

512
## Suggest-flow gate
613

7-
Tools **`query`**, **`count`**, and **`query_documents`** require a prior successful **`suggest_query_params`** call for the **same namespace string** within the cache TTL (see `PINECONE_CACHE_TTL_SECONDS`). The gate is in-process memory (`requireSuggested`).
14+
When **`disableSuggestFlow`** is **`false`** (Alliance default via `resolveAllianceConfig` / CLI), tools **`query`**, **`count`**, and **`query_documents`** require a prior successful **`suggest_query_params`** call for the **same namespace string** within the cache TTL (see `PINECONE_CACHE_TTL_SECONDS`). The gate is in-process memory (`requireSuggested`).
15+
16+
When **`disableSuggestFlow`** is **`true`** (core default via `resolveConfig`), the gate is bypassed — suitable for `setupCoreServer` embedders that do not register `suggest_query_params`.
817

918
**Namespace consistency:** use the **exact same** `namespace` value (including trimming — avoid leading/trailing spaces in one call and not the other) for `suggest_query_params` and downstream gated tools. Mismatches yield `FLOW_GATE` with a suggestion to call `suggest_query_params` first.
1019

11-
**Bypass:** set `PINECONE_DISABLE_SUGGEST_FLOW=true` or CLI `--disable-suggest-flow` (not recommended for production).
20+
**Core:** gate off by default; set `PINECONE_DISABLE_SUGGEST_FLOW=false` or `disableSuggestFlow: false` to enable the gate. **Alliance:** gate on by default; set `PINECONE_DISABLE_SUGGEST_FLOW=true` or CLI `--disable-suggest-flow` to bypass (not recommended for production).
1221

1322
---
1423

examples/quickstart/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ PINECONE_INDEX_NAME=my-mcp-demo
66
# Optional; default is {PINECONE_INDEX_NAME}-sparse
77
# PINECONE_SPARSE_INDEX_NAME=my-mcp-demo-sparse
88

9-
# Required for core-only demos (no suggest_query_params tool on setupCoreServer)
10-
PINECONE_DISABLE_SUGGEST_FLOW=true
9+
# Optional: set PINECONE_DISABLE_SUGGEST_FLOW=false to enable the suggest-flow gate on core
10+
# (requires suggest_query_params — use setupAllianceServer / Alliance CLI instead)
1111

1212
# Optional rerank (omit if your Pinecone project does not support the model)
1313
# PINECONE_RERANK_MODEL=your-rerank-model-id

examples/quickstart/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Edit `.env`:
3838

3939
- `PINECONE_API_KEY` — your API key
4040
- `PINECONE_INDEX_NAME` — dense index name (e.g. `my-mcp-demo`)
41-
- `PINECONE_DISABLE_SUGGEST_FLOW=true` — required for `setupCoreServer` (no `suggest_query_params` tool)
4241

4342
Optional: `PINECONE_SPARSE_INDEX_NAME` if the sparse index is not `{dense}-sparse`.
4443

@@ -68,12 +67,11 @@ npx tsx examples/quickstart/mcp-demo.ts
6867

6968
## 5. Optional: CLI (stdio MCP)
7069

71-
After seeding, you can run the published binary with the same env (still disable the suggest-flow gate for ad-hoc `query` without Alliance tools):
70+
After seeding, you can run the published **Alliance** CLI with the same index (suggest-flow gate on by default; use `suggest_query_params` or `guided_query`):
7271

7372
```bash
7473
export PINECONE_API_KEY=...
7574
export PINECONE_INDEX_NAME=my-mcp-demo
76-
export PINECONE_DISABLE_SUGGEST_FLOW=true
7775
npx @will-cppa/pinecone-read-only-mcp
7876
```
7977

@@ -83,7 +81,7 @@ For the **full** Alliance tool surface (`suggest_query_params`, `guided_query`,
8381

8482
| Symptom | Check |
8583
| ------- | ----- |
86-
| `FLOW_GATE` on `query` / `count` | Set `PINECONE_DISABLE_SUGGEST_FLOW=true` or use Alliance server + `suggest_query_params` |
84+
| `FLOW_GATE` on `query` / `count` | Core: gate is off by default via `resolveConfig`. If you set `PINECONE_DISABLE_SUGGEST_FLOW=false`, call `suggest_query_params` first or use Alliance server + `guided_query` |
8785
| Empty `list_namespaces` | Run `seed-data.ts`; confirm namespace `quickstart` and index names in `.env` |
8886
| Upsert / search errors | Indexes must support integrated embedding and `chunk_text` as the text field |
8987
| Hybrid partial results | Both dense and sparse indexes must contain the same record IDs in the same namespace |

examples/quickstart/mcp-demo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Generic quickstart: embed setupCoreServer and call core MCP tools in-process.
33
*
44
* Flow: list_namespaces → count → query (preset fast, no rerank).
5-
* Requires seeded data (seed-data.ts) and PINECONE_DISABLE_SUGGEST_FLOW=true.
5+
* Requires seeded data (seed-data.ts). Core resolveConfig disables the suggest-flow gate by default.
66
*/
77

88
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
@@ -46,7 +46,6 @@ async function main(): Promise<void> {
4646
const config = resolveConfig({
4747
apiKey,
4848
indexName,
49-
disableSuggestFlow: true,
5049
});
5150

5251
setPineconeClient(

src/alliance/config.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ describe('resolveAllianceConfig', () => {
1313
expect(cfg.rerankModel).toBe(ALLIANCE_DEFAULT_RERANK_MODEL);
1414
});
1515

16+
it('defaults disableSuggestFlow to false (suggest gate on for Alliance)', () => {
17+
const cfg = resolveAllianceConfig({ apiKey: 'sk-test' }, { PINECONE_API_KEY: 'sk-test' });
18+
expect(cfg.disableSuggestFlow).toBe(false);
19+
});
20+
1621
it('applies Alliance rerank default when env and overrides omit rerankModel but index is set', () => {
1722
const cfg = resolveAllianceConfig(
1823
{ apiKey: 'sk-test', indexName: 'my-index' },

0 commit comments

Comments
 (0)