Skip to content

Commit eb467ba

Browse files
jonathanMLDevzho
andauthored
Remove Alliance defaults from core config (#123)
* fix: require PINECONE_INDEX_NAME in core config * addressed AI reviews * addressed William's reviews * fixed LF error --------- Co-authored-by: zho <jornathanm910923@gmail.com>
1 parent b166af8 commit eb467ba

21 files changed

Lines changed: 199 additions & 105 deletions

.env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
# Required: Your Pinecone API key
55
PINECONE_API_KEY=your-pinecone-api-key-here
66

7-
# Optional: Dense (hybrid) Pinecone index name (default: rag-hybrid when unset)
8-
# PINECONE_INDEX_NAME=rag-hybrid
7+
# Required: Dense (hybrid) Pinecone index name
8+
PINECONE_INDEX_NAME=your-index-name
99

10-
# Optional: Reranking model (CLI defaults to bge-reranker-v2-m3 when unset; see docs/CONFIGURATION.md)
11-
# PINECONE_RERANK_MODEL=bge-reranker-v2-m3
10+
# Optional: Reranking model (omit to disable rerank in core; Alliance CLI defaults when unset see docs/CONFIGURATION.md)
11+
# PINECONE_RERANK_MODEL=your-rerank-model
1212

1313
# Optional: Default number of results to return (default: 10)
1414
PINECONE_TOP_K=10

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Tagged releases are published to npm from GitHub Actions when a **GitHub Release
88

99
## [Unreleased]
1010

11+
### Changed
12+
13+
- **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+
- **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).
1115
### Added
1216

1317
- Formal deprecation policy ([docs/deprecation-policy.md](docs/deprecation-policy.md)) and breaking-change release notes template ([docs/templates/breaking-change-release-notes.md](docs/templates/breaking-change-release-notes.md)).

README.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ The codebase is split into two layers:
108108

109109
## Configuration
110110

111-
You need a **Pinecone API key**. **Index** uses `PINECONE_INDEX_NAME` when set, else defaults to `rag-hybrid`; sparse index defaults to `{index}-sparse`. **Reranking** uses `PINECONE_RERANK_MODEL` when set, else `bge-reranker-v2-m3`. MCP configs with only `PINECONE_API_KEY` keep prior Alliance defaults. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md) for every variable and CLI flag.
111+
You need a **Pinecone API key**. **Index** (`PINECONE_INDEX_NAME` or `--index-name`) is required for core/library use; the **published CLI** defaults to `rag-hybrid` when unset (Alliance deployment). Sparse index defaults to `{index}-sparse`. **Rerank:** set `PINECONE_RERANK_MODEL` to enable; the CLI defaults to `bge-reranker-v2-m3` when unset. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md) (core vs Alliance table).
112112

113-
Quick reference:
113+
Quick reference (published CLI / Alliance — core embedders require index, no index/rerank defaults):
114114

115-
| Variable | Required | Default |
115+
| Variable | Required | Default (Alliance CLI) |
116116
| ----------------------------------- | ----------------------- | --------------------------------- |
117117
| `PINECONE_API_KEY` | Yes (for live Pinecone) ||
118-
| `PINECONE_INDEX_NAME` | No | `rag-hybrid` when unset |
119-
| `PINECONE_RERANK_MODEL` | No | `bge-reranker-v2-m3` when unset |
118+
| `PINECONE_INDEX_NAME` | No (CLI) / Yes (core) | `rag-hybrid` (CLI only) |
119+
| `PINECONE_RERANK_MODEL` | No | `bge-reranker-v2-m3` (CLI only) |
120120
| `PINECONE_SPARSE_INDEX_NAME` | No | `{index}-sparse` |
121121
| `PINECONE_READ_ONLY_MCP_LOG_LEVEL` | No | `INFO` (`DEBUG``ERROR`) |
122122
| `PINECONE_READ_ONLY_MCP_LOG_FORMAT` | No | `text` (`json` for log pipelines) |
@@ -132,9 +132,9 @@ The server uses **process-global** memory for the suggest-flow gate (`suggest_qu
132132
Treat **`setupCoreServer()` / `setupAllianceServer()` as one logical server per Node process**: they mutate shared module singletons (suggest-flow map, namespaces cache, URL registry, config context, shared `PineconeClient` slot). A **second** setup call in the same process **throws** unless you call **`teardownServer()`** first.
133133

134134
- **Generic bridge only:** `import { setupCoreServer, teardownServer, ... } from '@will-cppa/pinecone-read-only-mcp'`
135-
- **Full Alliance surface (CLI parity):** `import { setupAllianceServer } from '@will-cppa/pinecone-read-only-mcp/alliance'`
135+
- **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`). For the **full Alliance surface**, use `resolveConfig({ apiKey, indexName, ... })``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`). 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).
138138

139139
### Custom URL generators
140140

@@ -146,15 +146,21 @@ Import `registerUrlGenerator` and types `UrlGeneratorFn` / `UrlGenerationResult`
146146
import {
147147
PineconeClient,
148148
registerUrlGenerator,
149-
resolveConfig,
150149
setPineconeClient,
151150
type UrlGenerationResult,
152151
type UrlGeneratorFn,
153152
} from '@will-cppa/pinecone-read-only-mcp';
154-
import { setupAllianceServer } from '@will-cppa/pinecone-read-only-mcp/alliance';
155-
156-
const config = resolveConfig({ apiKey: '...', indexName: 'your-index' });
157-
setPineconeClient(new PineconeClient({ apiKey: config.apiKey, indexName: config.indexName }));
153+
import { resolveAllianceConfig, setupAllianceServer } from '@will-cppa/pinecone-read-only-mcp/alliance';
154+
155+
const config = resolveAllianceConfig({ apiKey: '...' }); // optional: indexName, rerankModel
156+
setPineconeClient(
157+
new PineconeClient({
158+
apiKey: config.apiKey,
159+
indexName: config.indexName,
160+
sparseIndexName: config.sparseIndexName,
161+
rerankModel: config.rerankModel,
162+
})
163+
);
158164
const server = await setupAllianceServer(config);
159165

160166
const myDocs: UrlGeneratorFn = (metadata): UrlGenerationResult => {
@@ -233,7 +239,7 @@ For a global installation:
233239
"mcpServers": {
234240
"pinecone-search": {
235241
"command": "pinecone-read-only-mcp",
236-
"args": ["--api-key", "your-api-key-here"]
242+
"args": ["--api-key", "your-api-key-here", "--index-name", "your-index-name"]
237243
}
238244
}
239245
}
@@ -246,19 +252,19 @@ For a global installation:
246252
Run the server using npx (no installation required):
247253

248254
```bash
249-
npx @will-cppa/pinecone-read-only-mcp@0.2.0 --api-key YOUR_API_KEY
255+
npx @will-cppa/pinecone-read-only-mcp@0.2.0 --api-key YOUR_API_KEY --index-name YOUR_INDEX
250256
```
251257

252258
Or if installed globally:
253259

254260
```bash
255-
pinecone-read-only-mcp --api-key YOUR_API_KEY
261+
pinecone-read-only-mcp --api-key YOUR_API_KEY --index-name YOUR_INDEX
256262
```
257263

258264
Or if installed locally in your project:
259265

260266
```bash
261-
node node_modules/@will-cppa/pinecone-read-only-mcp/dist/index.js --api-key YOUR_API_KEY
267+
node node_modules/@will-cppa/pinecone-read-only-mcp/dist/index.js --api-key YOUR_API_KEY --index-name YOUR_INDEX
262268
```
263269

264270
### Available Options
@@ -741,11 +747,19 @@ Other benefits:
741747

742748
### API Key Issues
743749

744-
If you see "Pinecone API key is required" error:
750+
If you see "Missing Pinecone API key" at startup:
745751

746752
1. Ensure `PINECONE_API_KEY` environment variable is set, OR
747753
2. Pass `--api-key` option when running the server
748754

755+
### Missing Index Name
756+
757+
If you see "Missing Pinecone index name" at startup:
758+
759+
1. Set `PINECONE_INDEX_NAME` in your MCP config or `.env`, OR
760+
2. Pass `--index-name` when running the server
761+
3. Alliance deployers: see [examples/alliance/.env.example](examples/alliance/.env.example)
762+
749763
### Index Not Found
750764

751765
If you see index-related errors:

docs/CONFIGURATION.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration
22

3-
Configuration is built from **CLI flags** (when using the binary), **environment variables**, and **defaults**. Library callers use `resolveConfig(overrides)` with optional `ConfigOverrides`.
3+
Configuration is built from **CLI flags** (when using the binary), **environment variables**, and **defaults**. Library callers use `resolveConfig(overrides)` (core) or `resolveAllianceConfig(overrides)` (Alliance CLI / `setupAllianceServer`) with optional `ConfigOverrides`.
44

55
## Precedence
66

@@ -15,9 +15,9 @@ Configuration is built from **CLI flags** (when using the binary), **environment
1515
| Field | Source | Default / notes |
1616
| ----- | ------ | --------------- |
1717
| `apiKey` | `apiKey` / `PINECONE_API_KEY` | **Required** (non-empty after trim) |
18-
| `indexName` | `indexName` / `PINECONE_INDEX_NAME` | `rag-hybrid` when env and overrides omit it |
18+
| `indexName` | `indexName` / `PINECONE_INDEX_NAME` | **Required** (non-empty after trim) |
1919
| `sparseIndexName` | `sparseIndexName` / `PINECONE_SPARSE_INDEX_NAME` | `{indexName}-sparse` |
20-
| `rerankModel` | `rerankModel` / `PINECONE_RERANK_MODEL` | `bge-reranker-v2-m3` when env and overrides omit it |
20+
| `rerankModel` | `rerankModel` / `PINECONE_RERANK_MODEL` | **Core:** omitted when unset (rerank disabled). **Alliance CLI:** `bge-reranker-v2-m3` when unset |
2121
| `defaultTopK` | `defaultTopK` / `PINECONE_TOP_K` | `10` (positive int) |
2222
| `logLevel` | `logLevel` / `PINECONE_READ_ONLY_MCP_LOG_LEVEL` | `INFO` (`DEBUG``ERROR`) |
2323
| `logFormat` | `logFormat` / `PINECONE_READ_ONLY_MCP_LOG_FORMAT` | `text` or `json` |
@@ -26,13 +26,18 @@ Configuration is built from **CLI flags** (when using the binary), **environment
2626
| `disableSuggestFlow` | `disableSuggestFlow` / `PINECONE_DISABLE_SUGGEST_FLOW` | `false` (bool parsing: true/1/yes/on) |
2727
| `checkIndexes` | `checkIndexes` / `PINECONE_CHECK_INDEXES` | `false` |
2828

29-
**Throws** if `apiKey` is missing after trim.
29+
**Throws** if `apiKey` or `indexName` is missing after trim.
3030

3131
For the full Alliance tool surface (including `suggest_query_params`, `guided_query`, and built-in URL generators), import from `@will-cppa/pinecone-read-only-mcp/alliance` and call `setupAllianceServer(config)`.
3232

33-
### Rerank model
33+
### Core vs Alliance resolvers
3434

35-
`resolveConfig` uses `PINECONE_INDEX_NAME` / `PINECONE_RERANK_MODEL` when set; otherwise **`rag-hybrid`** and **`bge-reranker-v2-m3`**. MCP configs that only set `PINECONE_API_KEY` keep the same defaults as before.
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` |
39+
40+
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`.
3641

3742
---
3843

docs/MIGRATION.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ This guide is for **library and MCP client authors** upgrading from earlier **0.
66

77
Under [semver 0.y.z](https://semver.org/spec/v2.0.0.html#spec-item-4), **0.1.x → 0.2.0 is a breaking minor** — pin `@0.2.0` only after reading this guide.
88

9+
## Unreleased: core vs Alliance config defaults
10+
11+
**Rationale:** Generic npm consumers must not silently connect to Alliance infrastructure or inherit Alliance rerank settings when using `resolveConfig` from the package root.
12+
13+
**Migration (core / `setupCoreServer`):**
14+
15+
1. Add `PINECONE_INDEX_NAME` to MCP `env` blocks, `.env`, or Docker `-e`, or pass `indexName` in `ConfigOverrides`.
16+
2. Set `PINECONE_RERANK_MODEL` only when you want reranking; omit it to skip rerank (previously defaulted to `bge-reranker-v2-m3` in core).
17+
3. Code that imported `DEFAULT_INDEX_NAME` or `DEFAULT_RERANK_MODEL` from the package root should use your own constants or [examples/alliance/preset.ts](../examples/alliance/preset.ts) for Alliance values.
18+
19+
Core `resolveConfig` throws `Missing Pinecone index name: …` when the index is unset (same pattern as the API key error).
20+
21+
**Alliance CLI / `setupAllianceServer` (unchanged for typical MCP configs):**
22+
23+
- The binary uses `resolveAllianceConfig`; API-key-only configs still default to `rag-hybrid` and `bge-reranker-v2-m3`.
24+
- Explicit env overrides still win. Copy [examples/alliance/.env.example](../examples/alliance/.env.example) to document Alliance conventions.
25+
26+
---
27+
928
## Migrating to v0.2.0
1029

1130
### Namespace trimming and suggest-flow

examples/alliance/.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# C++ Alliance Pinecone deployment (examples/alliance)
2+
# Copy to .env and fill in your API key.
3+
# The published CLI (resolveAllianceConfig) applies these defaults when variables are omitted.
4+
5+
PINECONE_API_KEY=your-pinecone-api-key-here
6+
7+
# Alliance dense index (CLI default when unset: rag-hybrid)
8+
PINECONE_INDEX_NAME=rag-hybrid
9+
10+
# Optional: sparse index (default: {PINECONE_INDEX_NAME}-sparse)
11+
# PINECONE_SPARSE_INDEX_NAME=rag-hybrid-sparse
12+
13+
# Alliance rerank model (CLI default when unset: bge-reranker-v2-m3)
14+
# PINECONE_RERANK_MODEL=bge-reranker-v2-m3

examples/alliance/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ They assume a Pinecone index you control with compatible data (not necessarily t
1010

1111
## Required environment
1212

13+
Copy [`.env.example`](./.env.example) to `.env` and set your API key. For C++ Alliance infrastructure, use `PINECONE_INDEX_NAME=rag-hybrid` as documented there.
14+
1315
| Variable | Required | Notes |
1416
| -------- | -------- | ----- |
1517
| `PINECONE_API_KEY` | Yes | For live runs |
16-
| `PINECONE_INDEX_NAME` | Yes | Your dense index name |
18+
| `PINECONE_INDEX_NAME` | Yes | Dense index name (Alliance: `rag-hybrid`) |
1719

18-
Optional: `PINECONE_RERANK_MODEL`, `PINECONE_SPARSE_INDEX_NAME`, etc. See [docs/CONFIGURATION.md](../../docs/CONFIGURATION.md). CLI-only configs that set only `PINECONE_API_KEY` still use documented defaults (`rag-hybrid`, `bge-reranker-v2-m3`).
20+
Optional: `PINECONE_RERANK_MODEL`, `PINECONE_SPARSE_INDEX_NAME`, etc. See [docs/CONFIGURATION.md](../../docs/CONFIGURATION.md). The **published CLI** uses `resolveAllianceConfig` and defaults to `rag-hybrid` / `bge-reranker-v2-m3` when those env vars are omitted. Demo constants: [`preset.ts`](./preset.ts).
1921

2022
## Files
2123

examples/alliance/library-embedding-demo.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Library embedding: build the MCP server from a Node script (not the CLI).
33
*
44
* Pattern (mirrors `src/index.ts`):
5-
* 1. `resolveConfig({ apiKey, indexName, ... })` — env rerank model or default bge-reranker-v2-m3.
5+
* 1. `resolveAllianceConfig({ apiKey, indexName, ... })` — Alliance index/rerank defaults when unset.
66
* 2. `new PineconeClient({ ... })` + `setPineconeClient(client)`.
77
* 3. `await setupAllianceServer(config)` then `server.connect(transport)`.
88
*
@@ -12,12 +12,8 @@
1212
* (tests). For isolated tenants in production, prefer one server per Node process.
1313
*/
1414

15-
import {
16-
PineconeClient,
17-
resolveConfig,
18-
setPineconeClient,
19-
} from '@will-cppa/pinecone-read-only-mcp';
20-
import { setupAllianceServer } from '@will-cppa/pinecone-read-only-mcp/alliance';
15+
import { PineconeClient, setPineconeClient } from '@will-cppa/pinecone-read-only-mcp';
16+
import { resolveAllianceConfig, setupAllianceServer } from '@will-cppa/pinecone-read-only-mcp/alliance';
2117

2218
async function main(): Promise<void> {
2319
const apiKey = process.env['PINECONE_API_KEY']?.trim();
@@ -27,12 +23,7 @@ async function main(): Promise<void> {
2723
);
2824
return;
2925
}
30-
const indexName = process.env['PINECONE_INDEX_NAME']?.trim();
31-
if (!indexName) {
32-
console.log('Set PINECONE_INDEX_NAME to run this example. Skipping live setup in doc-only mode.');
33-
return;
34-
}
35-
const config = resolveConfig({ apiKey, indexName });
26+
const config = resolveAllianceConfig({ apiKey });
3627

3728
setPineconeClient(
3829
new PineconeClient({

examples/alliance/preset.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Alliance deployment constants for copy-paste in demos. Not imported by `src/`.
3+
*/
4+
export const ALLIANCE_INDEX_NAME = 'rag-hybrid';
5+
export const ALLIANCE_RERANK_MODEL = 'bge-reranker-v2-m3';

src/alliance/config.test.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
import { describe, expect, it } from 'vitest';
2-
import { DEFAULT_RERANK_MODEL } from '../core/config.js';
3-
import { resolveAllianceConfig } from './config.js';
2+
import {
3+
ALLIANCE_DEFAULT_INDEX_NAME,
4+
ALLIANCE_DEFAULT_RERANK_MODEL,
5+
resolveAllianceConfig,
6+
} from './config.js';
47

58
describe('resolveAllianceConfig', () => {
6-
it('applies Alliance rerank default when env and overrides omit rerankModel', () => {
9+
it('applies Alliance index and rerank defaults when env omits both', () => {
10+
const cfg = resolveAllianceConfig({ apiKey: 'sk-test' }, { PINECONE_API_KEY: 'sk-test' });
11+
expect(cfg.indexName).toBe(ALLIANCE_DEFAULT_INDEX_NAME);
12+
expect(cfg.sparseIndexName).toBe(`${ALLIANCE_DEFAULT_INDEX_NAME}-sparse`);
13+
expect(cfg.rerankModel).toBe(ALLIANCE_DEFAULT_RERANK_MODEL);
14+
});
15+
16+
it('applies Alliance rerank default when env and overrides omit rerankModel but index is set', () => {
717
const cfg = resolveAllianceConfig(
818
{ apiKey: 'sk-test', indexName: 'my-index' },
919
{ PINECONE_API_KEY: 'sk-test', PINECONE_INDEX_NAME: 'my-index' }
1020
);
11-
expect(cfg.rerankModel).toBe(DEFAULT_RERANK_MODEL);
21+
expect(cfg.indexName).toBe('my-index');
22+
expect(cfg.rerankModel).toBe(ALLIANCE_DEFAULT_RERANK_MODEL);
1223
});
1324

1425
it('preserves explicit rerankModel from overrides', () => {
@@ -31,4 +42,12 @@ describe('resolveAllianceConfig', () => {
3142
);
3243
expect(cfg.rerankModel).toBe('env-reranker');
3344
});
45+
46+
it('preserves explicit index from env over Alliance default', () => {
47+
const cfg = resolveAllianceConfig(
48+
{ apiKey: 'sk-test' },
49+
{ PINECONE_API_KEY: 'sk-test', PINECONE_INDEX_NAME: 'custom-index' }
50+
);
51+
expect(cfg.indexName).toBe('custom-index');
52+
});
3453
});

0 commit comments

Comments
 (0)