Skip to content

Core vs Alliance MCP instructions and suggest-flow gate#125

Merged
wpak-ai merged 3 commits into
cppalliance:mainfrom
jonathanMLDev:fix/core-alliance-instructions-gate
Jun 3, 2026
Merged

Core vs Alliance MCP instructions and suggest-flow gate#125
wpak-ai merged 3 commits into
cppalliance:mainfrom
jonathanMLDev:fix/core-alliance-instructions-gate

Conversation

@jonathanMLDev
Copy link
Copy Markdown
Collaborator

@jonathanMLDev jonathanMLDev commented Jun 2, 2026

Summary

Completes the runtime contract boundary between generic setupCoreServer embedders and the full Alliance MCP surface. Core servers no longer advertise Alliance-only tools in MCP metadata, and core embedders can call query, count, and query_documents without suggest_query_params or PINECONE_DISABLE_SUGGEST_FLOW=true.

Problem

  1. Shared SERVER_INSTRUCTIONS — Both setupCoreServer and setupAllianceServer told clients to use guided_query and mandatory suggest_query_params, but only Alliance registers those tools.
  2. Suggest-flow gate in corequery / count / query_documents call requireSuggested(), yet only Alliance provides suggest_query_params. Quickstart had to set PINECONE_DISABLE_SUGGEST_FLOW=true.

Solution (Option A)

MCP instructions

  • CORE_SERVER_INSTRUCTIONS — Quickstart for seven core tools only; no guided_query / suggest_query_params.
  • ALLIANCE_SERVER_INSTRUCTIONS — Core text + appendix (guided query, suggest-flow, Alliance index/rerank defaults).
  • setupCoreServer(config?, options?) — Optional instructions (defaults to core).
  • setupAllianceServer — Passes ALLIANCE_SERVER_INSTRUCTIONS.
  • SERVER_INSTRUCTIONS — Deprecated alias → ALLIANCE_SERVER_INSTRUCTIONS.

Suggest-flow defaults

Resolver disableSuggestFlow default Gate
resolveConfig (core) true Off
resolveAllianceConfig / CLI false On

Alliance re-applies its default after resolveConfig so core’s new default does not leak into the CLI.

requireSuggested / markSuggested remain in core; tool handlers unchanged.

Breaking changes (core embedders only)

  • MCP instructions for setupCoreServer no longer mention Alliance tools.
  • resolveConfig defaults disableSuggestFlow to true (gate off). To enforce the gate on core, set PINECONE_DISABLE_SUGGEST_FLOW=false or disableSuggestFlow: false.

Unchanged: Alliance CLI, resolveAllianceConfig, and setupAllianceServer behavior (gate on by default; full instructions).

Files changed

  • src/constants.ts, src/core/setup.ts, src/alliance/setup.ts
  • src/core/config.ts, src/alliance/config.ts (+ exported asBool)
  • Tests: src/constants.test.ts, src/core/config.test.ts, src/alliance/config.test.ts, src/core/server/tools/count-tool.test.ts, src/core/server.test.ts
  • Quickstart: examples/quickstart/mcp-demo.ts, .env.example, README.md
  • Docs: docs/TOOLS.md, docs/CONFIGURATION.md, docs/FAQ.md, README.md, .env.example, CHANGELOG.md

Test plan

  • npm run build
  • npm test
  • src/constants.test.ts — core instructions exclude Alliance tool names; Alliance includes them
  • src/core/config.test.tsresolveConfigdisableSuggestFlow: true; env false → gate on
  • src/alliance/config.test.tsresolveAllianceConfigdisableSuggestFlow: false
  • count-tool.test.ts — count succeeds without prior suggest_query_params under core default config
  • Manual: npx tsx examples/quickstart/mcp-demo.ts (no PINECONE_DISABLE_SUGGEST_FLOW in .env)
  • Manual: Alliance CLI / guided_query still works with suggest gate on

Related

Summary by CodeRabbit

  • Breaking Changes

    • Core setup now disables the suggest-flow gate by default; query/count/query_documents work without Alliance tooling. Alliance flow remains enabled by default.
  • Documentation

    • Clarified resolver-dependent defaults and suggest-flow gating across README, CONFIGURATION, FAQ and tooling docs.
  • Examples

    • Quickstart env and demo guidance updated to reflect optional PINECONE_DISABLE_SUGGEST_FLOW and new defaults.
  • Tests

    • Added coverage verifying suggest-flow defaults for core and Alliance.

@jonathanMLDev jonathanMLDev self-assigned this Jun 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 79240eff-f425-4eed-b83f-4b75bd902d64

📥 Commits

Reviewing files that changed from the base of the PR and between f1b58fd and 8f891bc.

📒 Files selected for processing (1)
  • src/constants.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/constants.ts

📝 Walkthrough

Walkthrough

This PR splits server instruction text into core vs Alliance variants, makes suggest-flow defaults resolver-specific (core: disabled by default; Alliance: enabled by default), passes Alliance instructions from setupAllianceServer, and updates tests, examples, and docs to reflect the contract.

Changes

Core/Alliance Instruction Split and Suggest-Flow Defaults

Layer / File(s) Summary
Server Instructions Architecture
src/constants.ts, src/core/setup.ts
Refactor shared SERVER_INSTRUCTIONS into SERVER_FEATURES_AND_NOTES, CORE_SERVER_INSTRUCTIONS, and ALLIANCE_INSTRUCTIONS_APPENDIX; update SERVER_INSTRUCTIONS to alias Alliance instructions and add optional instructions to setupCoreServer via SetupCoreServerOptions.
Instructions Testing and Alliance Setup Wiring
src/constants.test.ts, src/alliance/setup.ts, src/core/server.test.ts
Add tests verifying CORE_SERVER_INSTRUCTIONS omits guided_query/suggest_query_params while ALLIANCE_SERVER_INSTRUCTIONS includes them; have setupAllianceServer pass ALLIANCE_SERVER_INSTRUCTIONS to setupCoreServer; update alliance lifecycle test to use resolveAllianceConfig.
Core Config Suggest-Flow Default
src/core/config.ts, src/core/config.test.ts
Export asBool with doc comment and change resolveConfig to default disableSuggestFlow to true when unset; add tests for default and string parsing.
Alliance Config Suggest-Flow Resolution
src/alliance/config.ts, src/alliance/config.test.ts
Have resolveAllianceConfig compute disableSuggestFlow from overrides or PINECONE_DISABLE_SUGGEST_FLOW (via asBool, default false) and merge into returned config; add test asserting the Alliance default.
Core Tool Behavior Validation
src/core/server/tools/count-tool.test.ts
Add tests that set server config via resolveConfig/setServerConfig to disable suggest flow and assert count succeeds without prior suggest_query_params.
Documentation and Examples
.env.example, README.md, docs/CONFIGURATION.md, docs/FAQ.md, docs/TOOLS.md, examples/quickstart/*, CHANGELOG.md
Document resolver-specific suggest-flow defaults (core off, Alliance on); remove mandatory PINECONE_DISABLE_SUGGEST_FLOW=true from quickstart examples and update guidance and changelog entry for the behavioral change.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • AuraMindNest
  • wpak-ai
  • whisper67265

Poem

🐰 I hopped through docs and constants bright,
split instructions so each server sees right,
Core walks quiet, Alliance brings light,
two paths now clear beneath the moonlight,
cheers — both embeddings sleep tight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: separating core vs Alliance MCP instructions and configuring the suggest-flow gate behavior differently for each context.
Linked Issues check ✅ Passed All acceptance criteria from issue #124 are met: core instructions exclude Alliance tools [124], Alliance instructions are separate [124], core works without PINECONE_DISABLE_SUGGEST_FLOW=true via Option A (disableSuggestFlow defaults true in core) [124], quickstart updated [124], tests added for core behavior [124], documentation updated in README/TOOLS/CONFIGURATION [124], and CHANGELOG entry added [124].
Out of Scope Changes check ✅ Passed All changes align with issue #124 scope: MCP instructions separation, suggest-flow gate defaults, config resolution, setup functions, tests, documentation, quickstart example, and environment files are all directly required by the acceptance criteria.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@eb467ba). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #125   +/-   ##
=======================================
  Coverage        ?   82.48%           
=======================================
  Files           ?       38           
  Lines           ?     1313           
  Branches        ?      440           
=======================================
  Hits            ?     1083           
  Misses          ?      228           
  Partials        ?        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/core/server/tools/count-tool.test.ts (1)

108-129: ⚡ Quick win

Assert the gate helper is bypassed, not just that the call succeeds.

This currently proves the request can succeed, but not that disableSuggestFlow=true skipped requireSuggested. Spying on requireSuggested here would make the contract explicit and avoid false passes if shared flow state is ever present.

Suggested tightening
   it('does not return FLOW_GATE without prior suggest_query_params', async () => {
-    setServerConfig(resolveConfig({ apiKey: 'sk-test', indexName: 'my-index' }));
-    expect(resolveConfig({ apiKey: 'sk-test', indexName: 'my-index' }).disableSuggestFlow).toBe(
-      true
-    );
+    const cfg = resolveConfig({ apiKey: 'sk-test', indexName: 'my-index' });
+    const requireSuggestedSpy = vi.spyOn(suggestionFlow, 'requireSuggested');
+    setServerConfig(cfg);
+    expect(cfg.disableSuggestFlow).toBe(true);
 
     mockedGetClient.mockReturnValue({
       count: vi.fn().mockResolvedValue({ count: 2, truncated: false }),
     } as never);
@@
     const envelope = raw as { isError?: boolean };
     expect(envelope.isError).not.toBe(true);
     const body = parseToolJson(raw);
     expect(body['status']).toBe('success');
+    expect(requireSuggestedSpy).not.toHaveBeenCalled();
     expect(mockedGetClient().count).toHaveBeenCalled();
   });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/server/tools/count-tool.test.ts` around lines 108 - 129, Test
currently only asserts success but not that the suggest-gate was bypassed; add a
spy on the requireSuggested helper and assert it was not called when
disableSuggestFlow is true. In the test that calls registerCountTool and invokes
the 'count' handler (the block that sets resolveConfig(...).disableSuggestFlow),
create a spy for the requireSuggested function used by the count tool (spyOn or
vi.spyOn the module that exports requireSuggested) before invoking the handler,
then assert that requireSuggested was not called after the request completes
while keeping the existing assertions (mockedGetClient, parseToolJson, status
checks) intact. Ensure you restore or clear the spy after the test to avoid
cross-test pollution.
src/alliance/config.ts (1)

38-41: ⚡ Quick win

Keep disableSuggestFlow resolution in one place.

This computes the flag twice and then overwrites the core result. Feeding the Alliance default into resolveConfig keeps the normalization path single-sourced and avoids drift if core adds more logic around this field later.

Suggested simplification
-  const cfg = resolveConfig({ ...overrides, indexName, rerankModel }, env);
   const disableSuggestFlow =
     overrides.disableSuggestFlow ?? asBool(env['PINECONE_DISABLE_SUGGEST_FLOW'], false);
-  return { ...cfg, disableSuggestFlow };
+  return resolveConfig({ ...overrides, indexName, rerankModel, disableSuggestFlow }, env);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/alliance/config.ts` around lines 38 - 41, The code computes
disableSuggestFlow twice and overwrites the resolved config; instead compute the
final boolean once (using overrides.disableSuggestFlow ??
asBool(env['PINECONE_DISABLE_SUGGEST_FLOW'], false)), include that value in the
object passed to resolveConfig (instead of passing rerankModel only), and return
the result directly (remove the post-resolve overwrite of
cfg.disableSuggestFlow) so resolveConfig is the single source of truth for that
field; update references to disableSuggestFlow, resolveConfig, and cfg
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/constants.ts`:
- Line 67: The comment's gate wording is inaccurate: update the text that
references PINECONE_DISABLE_SUGGEST_FLOW (near the sentence describing the
manual flow: "list_namespaces -> suggest_query_params -> query or count") to
explicitly require the variable to be true (e.g., "unless
PINECONE_DISABLE_SUGGEST_FLOW=true" or "unless PINECONE_DISABLE_SUGGEST_FLOW is
set to true") so the described gate behavior matches the actual boolean
semantics of PINECONE_DISABLE_SUGGEST_FLOW and avoids implying presence-only
semantics.

---

Nitpick comments:
In `@src/alliance/config.ts`:
- Around line 38-41: The code computes disableSuggestFlow twice and overwrites
the resolved config; instead compute the final boolean once (using
overrides.disableSuggestFlow ?? asBool(env['PINECONE_DISABLE_SUGGEST_FLOW'],
false)), include that value in the object passed to resolveConfig (instead of
passing rerankModel only), and return the result directly (remove the
post-resolve overwrite of cfg.disableSuggestFlow) so resolveConfig is the single
source of truth for that field; update references to disableSuggestFlow,
resolveConfig, and cfg accordingly.

In `@src/core/server/tools/count-tool.test.ts`:
- Around line 108-129: Test currently only asserts success but not that the
suggest-gate was bypassed; add a spy on the requireSuggested helper and assert
it was not called when disableSuggestFlow is true. In the test that calls
registerCountTool and invokes the 'count' handler (the block that sets
resolveConfig(...).disableSuggestFlow), create a spy for the requireSuggested
function used by the count tool (spyOn or vi.spyOn the module that exports
requireSuggested) before invoking the handler, then assert that requireSuggested
was not called after the request completes while keeping the existing assertions
(mockedGetClient, parseToolJson, status checks) intact. Ensure you restore or
clear the spy after the test to avoid cross-test pollution.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82e0a7e6-ed8e-449b-a637-13f8f678efef

📥 Commits

Reviewing files that changed from the base of the PR and between eb467ba and 581ee05.

📒 Files selected for processing (19)
  • .env.example
  • CHANGELOG.md
  • README.md
  • docs/CONFIGURATION.md
  • docs/FAQ.md
  • docs/TOOLS.md
  • examples/quickstart/.env.example
  • examples/quickstart/README.md
  • examples/quickstart/mcp-demo.ts
  • src/alliance/config.test.ts
  • src/alliance/config.ts
  • src/alliance/setup.ts
  • src/constants.test.ts
  • src/constants.ts
  • src/core/config.test.ts
  • src/core/config.ts
  • src/core/server.test.ts
  • src/core/server/tools/count-tool.test.ts
  • src/core/setup.ts

Comment thread src/constants.ts Outdated
@jonathanMLDev
Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review again

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

@jonathanMLDev Sure! I'll kick off a full review of PR #125 now.

✅ Action performed

Full review finished.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/core/setup.ts (1)

32-47: ⚡ Quick win

Function JSDoc now documents the wrong declaration.

The descriptive block at lines 32-38 (explaining setupCoreServer behavior, Alliance tool exclusion, etc.) now immediately precedes export type SetupCoreServerOptions, so editors/IntelliSense attach it to the type rather than to setupCoreServer. Move the function doc directly above the function.

♻️ Proposed fix
-/**
- * Create and configure the MCP server with generic (core) tools only.
- *
- * Does not register Alliance-specific tools (`suggest_query_params`, `guided_query`)
- * or built-in Boost/Slack URL generators. Use {`@link` setupAllianceServer} from
- * `@will-cppa/pinecone-read-only-mcp/alliance` for the full tool surface.
- */
 export type SetupCoreServerOptions = {
   /** MCP server instructions; defaults to {`@link` CORE_SERVER_INSTRUCTIONS}. */
   instructions?: string;
 };
 
+/**
+ * Create and configure the MCP server with generic (core) tools only.
+ *
+ * Does not register Alliance-specific tools (`suggest_query_params`, `guided_query`)
+ * or built-in Boost/Slack URL generators. Use {`@link` setupAllianceServer} from
+ * `@will-cppa/pinecone-read-only-mcp/alliance` for the full tool surface.
+ */
 export async function setupCoreServer(
   config?: ServerConfig,
   options?: SetupCoreServerOptions
 ): Promise<McpServer> {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/setup.ts` around lines 32 - 47, The JSDoc describing setupCoreServer
is currently attached to the type SetupCoreServerOptions; move that descriptive
comment block so it immediately precedes the function declaration export async
function setupCoreServer(...) and ensure the type SetupCoreServerOptions has its
own brief JSDoc (or none) so editors/IntelliSense show the correct documentation
for setupCoreServer; reference symbols: SetupCoreServerOptions and
setupCoreServer.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/core/setup.ts`:
- Around line 32-47: The JSDoc describing setupCoreServer is currently attached
to the type SetupCoreServerOptions; move that descriptive comment block so it
immediately precedes the function declaration export async function
setupCoreServer(...) and ensure the type SetupCoreServerOptions has its own
brief JSDoc (or none) so editors/IntelliSense show the correct documentation for
setupCoreServer; reference symbols: SetupCoreServerOptions and setupCoreServer.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 03b27d69-7a99-4a65-9d25-a497bcc0c388

📥 Commits

Reviewing files that changed from the base of the PR and between eb467ba and f1b58fd.

📒 Files selected for processing (19)
  • .env.example
  • CHANGELOG.md
  • README.md
  • docs/CONFIGURATION.md
  • docs/FAQ.md
  • docs/TOOLS.md
  • examples/quickstart/.env.example
  • examples/quickstart/README.md
  • examples/quickstart/mcp-demo.ts
  • src/alliance/config.test.ts
  • src/alliance/config.ts
  • src/alliance/setup.ts
  • src/constants.test.ts
  • src/constants.ts
  • src/core/config.test.ts
  • src/core/config.ts
  • src/core/server.test.ts
  • src/core/server/tools/count-tool.test.ts
  • src/core/setup.ts

Comment thread src/constants.ts Outdated
@jonathanMLDev jonathanMLDev requested a review from wpak-ai June 3, 2026 18:00
@wpak-ai wpak-ai merged commit b594690 into cppalliance:main Jun 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core/alliance MCP instructions and suggest-flow gate

3 participants