Skip to content

Commit d087a5e

Browse files
jonathanMLDevzho
andauthored
refactor: trim MCP instructions and fix Alliance appendix numbering (#197)
* refactor: trim MCP instructions and fix Alliance appendix numbering * addressed ai reviews --------- Co-authored-by: zho <jornathanm910923@gmail.com>
1 parent dbfab6d commit d087a5e

4 files changed

Lines changed: 39 additions & 13 deletions

File tree

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+
- **Instructions:** Trimmed operator/install/deploy content (env-var setup, misconfiguration note, Alliance CLI index/rerank defaults, stderr logging config) from `CORE_SERVER_INSTRUCTIONS` and `ALLIANCE_INSTRUCTIONS_APPENDIX` — reduces per-session token cost; no behavior change. Replaced colliding Alliance appendix steps 4–5 with unnumbered "Manual Alliance flow" bullets (includes `PINECONE_DISABLE_SUGGEST_FLOW=true` escape clause). Full detail remains in [docs/CONFIGURATION.md](docs/CONFIGURATION.md).
14+
1115
## [0.4.0] - 2026-06-24
1216

1317
### Added

docs/CONFIGURATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Configuration is built from **CLI flags** (when using the binary), **environment
2828
| `sources` | `sources` / `PINECONE_SOURCES` or JSON config file | Omitted in single-key mode; see [Multi-source mode](#multi-source-mode) |
2929
| `defaultSource` | JSON config `defaultSource` only | First source when using inline `PINECONE_SOURCES` |
3030

31-
**Throws** if `apiKey` or `indexName` is missing after trim (single-key mode). In multi-source mode, `PINECONE_API_KEY` is ignored when `PINECONE_SOURCES` or a config file is set; credentials come from each source entry.
31+
**Throws** if `apiKey` or `indexName` is missing after trim (single-key mode) — this happens at server startup, not as an MCP tool error. In multi-source mode, `PINECONE_API_KEY` is ignored when `PINECONE_SOURCES` or a config file is set; credentials come from each source entry.
3232

3333
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 use the three-step instance-first recipe at [Library embedding](#library-embedding) below.
3434

src/constants.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,37 @@ describe('server instructions', () => {
2121
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).not.toMatch(
2222
/Alliance quickstart: for most user questions, call `guided_query`/
2323
);
24-
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).toMatch(/rag-hybrid/);
2524
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).toMatch(/suggest_query_params/);
2625
});
2726

27+
it('CORE_SERVER_INSTRUCTIONS omits operator/install/deploy content', () => {
28+
expect(CORE_SERVER_INSTRUCTIONS).not.toMatch(/PINECONE_INDEX_NAME/);
29+
expect(CORE_SERVER_INSTRUCTIONS).not.toMatch(/Misconfiguration surfaces/);
30+
expect(CORE_SERVER_INSTRUCTIONS).not.toMatch(/PINECONE_RERANK_MODEL/);
31+
expect(CORE_SERVER_INSTRUCTIONS).not.toMatch(/PINECONE_READ_ONLY_MCP_LOG_FORMAT/);
32+
});
33+
34+
it('ALLIANCE_INSTRUCTIONS_APPENDIX omits operator/deploy defaults', () => {
35+
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).not.toMatch(/rag-hybrid/);
36+
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).not.toMatch(/bge-reranker/);
37+
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).not.toMatch(/resolveAllianceConfig/);
38+
});
39+
40+
it('ALLIANCE_INSTRUCTIONS_APPENDIX uses unnumbered manual flow without duplicate step numbering', () => {
41+
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).not.toMatch(/Alliance usage/);
42+
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).not.toMatch(/^[45]\. /m);
43+
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).toMatch(/Manual Alliance flow/);
44+
expect((ALLIANCE_SERVER_INSTRUCTIONS.match(/Usage:/g) ?? []).length).toBe(1);
45+
});
46+
47+
it('ALLIANCE_INSTRUCTIONS_APPENDIX documents suggest-flow escape clause in manual flow', () => {
48+
expect(ALLIANCE_INSTRUCTIONS_APPENDIX).toMatch(/PINECONE_DISABLE_SUGGEST_FLOW=true/);
49+
const manualFlowSection = ALLIANCE_INSTRUCTIONS_APPENDIX.slice(
50+
ALLIANCE_INSTRUCTIONS_APPENDIX.indexOf('Manual Alliance flow')
51+
);
52+
expect(manualFlowSection).toMatch(/PINECONE_DISABLE_SUGGEST_FLOW=true/);
53+
});
54+
2855
it('SERVER_INSTRUCTIONS aliases Alliance instructions', () => {
2956
expect(SERVER_INSTRUCTIONS).toBe(ALLIANCE_SERVER_INSTRUCTIONS);
3057
});

src/constants.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const SERVER_FEATURES_AND_NOTES = `A semantic search server that provides hybrid
3636
3737
Features:
3838
- Hybrid Search: Combines dense and sparse embeddings for superior recall
39-
- Semantic Reranking: Uses a configurable reranker model when PINECONE_RERANK_MODEL is set; disabled when unset
39+
- Semantic Reranking: Applied when a rerank model is configured; skipped when none is configured
4040
- Dynamic Namespace Discovery: Automatically discovers available namespaces
4141
- Metadata Filtering: Supports optional metadata filters for refined searches
4242
- Namespace Router: Suggests likely namespace(s) from natural-language intent
@@ -47,11 +47,10 @@ Features:
4747
- Multi-Source: When PINECONE_SOURCES or a config file is set, multiple Pinecone projects are available in one server. Use list_sources and pass source on tools; list_namespaces tags each namespace with its source.
4848
4949
Notes:
50-
- Result rows include both \`document_id\` (canonical) and \`paper_number\` (deprecated alias kept for one minor cycle; will be removed in the next major release). Prefer \`document_id\` in new code.
51-
- The server emits structured logs to stderr (text by default, set PINECONE_READ_ONLY_MCP_LOG_FORMAT=json for log aggregation).`;
50+
- Result rows include both \`document_id\` (canonical) and \`paper_number\` (deprecated alias kept for one minor cycle; will be removed in the next major release). Prefer \`document_id\` in new code.`;
5251

5352
/** MCP instructions for {@link setupCoreServer} (eight core tools including guided_query). */
54-
export const CORE_SERVER_INSTRUCTIONS = `Quickstart for AI clients: for most user questions, call \`guided_query\` with the user's question — it does namespace routing, suggestion, and execution in one shot and returns \`experimental.decision_trace\` you can show the user. Alternatively call \`list_namespaces\` to discover namespaces, optionally \`namespace_router\` to rank candidates from user intent, then \`query\` (preset fast/detailed/full), \`count\`, \`query_documents\`, \`keyword_search\`, or \`generate_urls\` as needed. For \`setupCoreServer\` / package-root \`resolveConfig\`, \`PINECONE_INDEX_NAME\` (or \`--index-name\`) is required in addition to \`PINECONE_API_KEY\`. Misconfiguration surfaces at startup, not as tool errors.
53+
export const CORE_SERVER_INSTRUCTIONS = `Quickstart for AI clients: for most user questions, call \`guided_query\` with the user's question — it does namespace routing, suggestion, and execution in one shot and returns \`experimental.decision_trace\` you can show the user. Alternatively call \`list_namespaces\` to discover namespaces, optionally \`namespace_router\` to rank candidates from user intent, then \`query\` (preset fast/detailed/full), \`count\`, \`query_documents\`, \`keyword_search\`, or \`generate_urls\` as needed.
5554
5655
${SERVER_FEATURES_AND_NOTES}
5756
@@ -66,13 +65,9 @@ Multi-source (when configured): call list_sources, then list_namespaces (all sou
6665
/** Alliance-only supplement appended to core instructions for {@link setupAllianceServer}. */
6766
export const ALLIANCE_INSTRUCTIONS_APPENDIX = `
6867
69-
Alliance deployment: The Alliance CLI and \`resolveAllianceConfig\` default the index to \`rag-hybrid\` (and rerank to \`bge-reranker-v2-m3\`) when those env vars are omitted.
70-
71-
For manual flows with the full tool surface, call \`list_namespaces\` -> \`suggest_query_params\` -> \`query\` (use preset fast/detailed/full per suggestion) or \`count\` (the suggest step is a mandatory gate unless \`PINECONE_DISABLE_SUGGEST_FLOW=true\`).
72-
73-
Alliance usage (after list_namespaces):
74-
4. Call suggest_query_params before query/count/query_documents tools (mandatory flow gate) to get suggested_fields and recommended_tool.
75-
5. Use count for count questions, \`query\` with the appropriate preset for chunk-level retrieval, or query_documents for full-document content.`;
68+
Manual Alliance flow (after list_namespaces):
69+
- Call suggest_query_params before query (preset fast/detailed/full per suggestion), count, or query_documents — mandatory gate unless PINECONE_DISABLE_SUGGEST_FLOW=true
70+
- Use the recommended preset/tool from the suggestion response`;
7671

7772
/** MCP instructions for {@link setupAllianceServer} (core tools plus Alliance tools). */
7873
export const ALLIANCE_SERVER_INSTRUCTIONS =

0 commit comments

Comments
 (0)