Skip to content

docs(examples): generic quickstart + alliance examples layout#115

Merged
wpak-ai merged 5 commits into
cppalliance:mainfrom
jonathanMLDev:feat/quickstart-examples
May 28, 2026
Merged

docs(examples): generic quickstart + alliance examples layout#115
wpak-ai merged 5 commits into
cppalliance:mainfrom
jonathanMLDev:feat/quickstart-examples

Conversation

@jonathanMLDev
Copy link
Copy Markdown
Collaborator

@jonathanMLDev jonathanMLDev commented May 27, 2026

Summary

Adds a generic quickstart under examples/quickstart/ so any user with a free-tier Pinecone account can try the server without the C++ Alliance rag-hybrid index. Relocates all Alliance-specific demos to examples/alliance/ and updates the root README.md with a Quick start section and a restructured Examples table.

Closes w4_issue_05.

Merge order: after PR A (#109, already merged), before PR B (week4/release).


Changes

examples/quickstart/ (new)

  • README.md — End-to-end setup guide: Pinecone account, two integrated-embedding indexes (my-mcp-demo dense + my-mcp-demo-sparse sparse), env copy, seed step, MCP demo run, optional CLI, troubleshooting table.
  • .env.example — Placeholder values only (your-pinecone-api-key-here, my-mcp-demo); PINECONE_DISABLE_SUGGEST_FLOW=true pre-set and explained; no Alliance defaults.
  • seed-data.ts — Inserts 15 domain-neutral programming snippets (namespace quickstart) into both dense and sparse indexes using @pinecone-database/pinecone upsertRecords. Supports --dry-run. Guards against running main() when imported as a module.
  • mcp-demo.ts — In-process MCP demo using setupCoreServer (package root only, no Alliance import) + linked transport + SDK Client. Calls list_namespaces, count, and query (preset fast) in sequence.

examples/alliance/ (new directory, files moved)

Moved via git mv: suggest-flow-demo.ts, guided-query-demo.ts, library-embedding-demo.ts, custom-url-generator.ts, demo-mock-pinecone-client.ts.

Added examples/alliance/README.md — short banner noting Alliance surface (setupAllianceServer, suggest_query_params, guided_query, built-in URL generators), required env table, file table with run commands, and link back to quickstart for bootstrapping.

examples/README.md (rewritten)

Hub layout: "Generic quickstart (start here)" section first, "Alliance / advanced" section second, shared utilities (transport helper) at the bottom.

Root README.md

  • New Quick start section (after From Source) linking to examples/quickstart/README.md.
  • Library embedding paragraph updated: quickstart path for setupCoreServer, Alliance path for setupAllianceServer, with corrected file links.
  • Examples table replaced with two subsections (Generic / Alliance).
  • Existing JSON typo in Claude Desktop config fixed (missing comma after PINECONE_INDEX_NAME).

docs/CONFIGURATION.md

Updated examples/library-embedding-demo.ts reference to examples/alliance/library-embedding-demo.ts.

.env.example

Added one-line comment pointing to examples/quickstart/.env.example for onboarding.


Acceptance criteria checklist

  • At least one example works with any Pinecone free-tier instance (no Alliance-specific index names or data)
  • Example includes a setup guide: create account, create indexes, insert sample data, configure the MCP server
  • Example configuration uses placeholder values with clear documentation (not Alliance defaults)
  • Existing Alliance-specific examples moved to examples/alliance/
  • README quick-start section updated to reference the generic example
  • Tests pass in CI (npm run ci — 157 tests, 26 files, all green)
  • PR approved by at least 1 reviewer

Test plan

  • npm run ci (typecheck, lint, format, build, test:coverage) — passes
  • npx tsx examples/quickstart/seed-data.ts --dry-run — exits 0 with doc-only message (no env set)
  • npx tsx examples/quickstart/mcp-demo.ts — exits 0 with doc-only message (no env set)
  • npx tsx examples/alliance/suggest-flow-demo.ts — exits 0 with doc-only message (no env set)

Related issues

close #108

Summary by CodeRabbit

  • Documentation

    • Reorganized examples into a clearer Quickstart vs. advanced Alliance section; updated main README and docs links.
    • Added comprehensive Quickstart and Alliance guides, simplified build/run instructions, and clarified embedding/library guidance.
  • New Features

    • Added ready-to-run demo scripts to seed sample data and run a local demo flow.
    • Added environment-variable templates and clarified required/optional settings for running examples.

Review Change Stack

@jonathanMLDev jonathanMLDev self-assigned this May 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb3c1f07-d0e3-4496-86a3-4a61eb47146c

📥 Commits

Reviewing files that changed from the base of the PR and between 65dfae4 and 7cbf40e.

📒 Files selected for processing (1)
  • examples/quickstart/mcp-demo.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/quickstart/mcp-demo.ts

📝 Walkthrough

Walkthrough

Adds a generic quickstart: reorganized examples/docs, a quickstart .env template, a seed-data script inserting sample vectors into dense+sparse Pinecone indexes, and an in-process MCP demo script that runs list_namespaces → count → query against a user-owned Pinecone project.

Changes

Quickstart Example and Documentation

Layer / File(s) Summary
Examples index and quickstart documentation
examples/README.md, examples/alliance/README.md, examples/quickstart/.env.example, examples/quickstart/README.md, README.md, docs/CONFIGURATION.md, .env.example
Reorganizes examples into a generic quickstart and Alliance advanced demos, adds quickstart README and env template, and updates repository README and configuration references.
Sample data seeding script
examples/quickstart/seed-data.ts
Adds seed-data.ts that defines 15 sample snippets and upserts them into dense and sparse Pinecone indexes under the quickstart namespace; supports --dry-run and exports QUICKSTART_NAMESPACE.
MCP demo script
examples/quickstart/mcp-demo.ts
Adds mcp-demo.ts to load env, validate Pinecone config (suggest-flow disabled), start a Pinecone-backed MCP core server with linked in-process transports, and run list_namespaces → count → query with JSON parsing and teardown.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Quickstart Client
  participant Core as MCP Core Server
  participant Pinecone as Pinecone Service

  Client->>Core: connect via linked transport
  Client->>Core: list_namespaces()
  Core->>Pinecone: list namespaces request
  Pinecone-->>Core: namespaces list
  Core-->>Client: namespaces result

  Client->>Core: count(query_text: "document")
  Core->>Pinecone: count request
  Pinecone-->>Core: count result
  Core-->>Client: count result

  Client->>Core: query(preset: fast, top_k:3)
  Core->>Pinecone: query vectors
  Pinecone-->>Core: query results
  Core-->>Client: tool result (JSON/text)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • wpak-ai
  • AuraMindNest

Poem

🐇 Quickstart hops in, env and seed in hand,
Dense and sparse together, sample vectors stand.
Client asks, server queries, Pinecone hums along,
A rabbit parses JSON, logs the answer strong.
🌱✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Critical SDK API call issues remain unresolved: pc.index({name}) should be pc.index(string), upsertRecords({records}) should be upsertRecords(array). These violations will cause runtime failures and prevent the quickstart from functioning as required. Fix pc.index(indexName) and pc.index(sparseIndexName) calls to pass strings directly instead of objects. Fix upsertRecords(records) to pass the array directly instead of an object wrapper.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 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: adding a generic quickstart and reorganizing examples by moving Alliance-specific demos to a separate directory structure.
Out of Scope Changes check ✅ Passed All code changes directly address issue #108 objectives: generic quickstart with setup guide, free-tier compatibility, Alliance examples relocated, and documentation updated per requirements.

✏️ 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 May 27, 2026

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #115   +/-   ##
=======================================
  Coverage        ?   81.21%           
=======================================
  Files           ?       38           
  Lines           ?     1299           
  Branches        ?      437           
=======================================
  Hits            ?     1055           
  Misses          ?      242           
  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 (1)
examples/quickstart/mcp-demo.ts (1)

26-32: 💤 Low value

Consider more specific error messages in parseToolJson.

The function throws a generic error if no text content is found, and JSON.parse can throw without indicating malformed JSON. For better debuggability, consider catching parse errors separately or including the raw text in error messages.

♻️ Proposed enhancement
 function parseToolJson(result: { content?: Array<{ type: string; text?: string }>; isError?: boolean }): unknown {
   const text = result.content?.find((c) => c.type === 'text')?.text;
   if (!text) {
     throw new Error('Tool result had no text content');
   }
-  return JSON.parse(text) as unknown;
+  try {
+    return JSON.parse(text) as unknown;
+  } catch (err) {
+    throw new Error(`Failed to parse tool result JSON: ${err instanceof Error ? err.message : String(err)}`);
+  }
 }
🤖 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 `@examples/quickstart/mcp-demo.ts` around lines 26 - 32, The parseToolJson
function currently throws a generic error when no text is found and lets
JSON.parse errors bubble up without context; update parseToolJson to (1) include
the raw result.content (or the extracted text) in the thrown error when text is
missing so callers see what was returned, and (2) wrap JSON.parse in a try/catch
and rethrow a new Error that includes the offending text and the original
parsing error message (or attach the original error) to make malformed-JSON
failures clearly debuggable; reference the parseToolJson function and the local
variable text when implementing these changes.
🤖 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 `@examples/quickstart/mcp-demo.ts`:
- Around line 70-77: The list_namespaces result handling doesn't check for a
tool error before calling parseToolJson; update the block that calls
client.callTool({ name: 'list_namespaces', ... }) to first check listRaw.isError
(same pattern used in the count and query calls) and handle/log/return the error
instead of parsing it, and only call parseToolJson(listRaw) when
!listRaw.isError so parseToolJson isn't invoked on error payloads.

---

Nitpick comments:
In `@examples/quickstart/mcp-demo.ts`:
- Around line 26-32: The parseToolJson function currently throws a generic error
when no text is found and lets JSON.parse errors bubble up without context;
update parseToolJson to (1) include the raw result.content (or the extracted
text) in the thrown error when text is missing so callers see what was returned,
and (2) wrap JSON.parse in a try/catch and rethrow a new Error that includes the
offending text and the original parsing error message (or attach the original
error) to make malformed-JSON failures clearly debuggable; reference the
parseToolJson function and the local variable text when implementing these
changes.
🪄 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: 2adc3735-fe49-4baa-b94f-70d26eb42ee7

📥 Commits

Reviewing files that changed from the base of the PR and between 11b04be and 3b6094b.

📒 Files selected for processing (11)
  • examples/README.md
  • examples/alliance/README.md
  • examples/alliance/custom-url-generator.ts
  • examples/alliance/demo-mock-pinecone-client.ts
  • examples/alliance/guided-query-demo.ts
  • examples/alliance/library-embedding-demo.ts
  • examples/alliance/suggest-flow-demo.ts
  • examples/quickstart/.env.example
  • examples/quickstart/README.md
  • examples/quickstart/mcp-demo.ts
  • examples/quickstart/seed-data.ts

Comment thread examples/quickstart/mcp-demo.ts
@jonathanMLDev
Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review again

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== examples/quickstart/seed-data.ts ==="
cat examples/quickstart/seed-data.ts

echo ""
echo "=== examples/quickstart/mcp-demo.ts ==="
cat examples/quickstart/mcp-demo.ts

echo ""
echo "=== examples/quickstart/README.md ==="
cat examples/quickstart/README.md

echo ""
echo "=== examples/quickstart/.env.example ==="
cat examples/quickstart/.env.example

echo ""
echo "=== examples/alliance/README.md ==="
cat examples/alliance/README.md

echo ""
echo "=== examples/README.md ==="
cat examples/README.md

echo ""
echo "=== Root README.md (first 200 lines) ==="
head -200 README.md

echo ""
echo "=== Root .env.example ==="
cat .env.example

echo ""
echo "=== docs/CONFIGURATION.md (grep alliance) ==="
grep -n "alliance\|quickstart\|library-embedding" docs/CONFIGURATION.md | head -40

echo ""
echo "=== examples/alliance/ directory listing ==="
ls -la examples/alliance/

echo ""
echo "=== examples/quickstart/ directory listing ==="
ls -la examples/quickstart/

echo ""
echo "=== package.json (scripts, dependencies) ==="
cat package.json

echo ""
echo "=== Check for tsconfig or similar ==="
cat tsconfig.json 2>/dev/null || echo "tsconfig.json not found"

Length of output: 38214


🏁 Script executed:

#!/bin/bash
echo "=== .gitignore (check for .env patterns) ==="
cat .gitignore

echo ""
echo "=== Pinecone SDK index() signature (look in node_modules) ==="
find node_modules/@pinecone-database/pinecone/dist -name "*.d.ts" 2>/dev/null | head -5 | xargs grep -l "upsertRecords" 2>/dev/null | head -3

echo ""
echo "=== upsertRecords signature ==="
find node_modules/@pinecone-database/pinecone/dist -name "*.d.ts" 2>/dev/null | xargs grep -A3 "upsertRecords" 2>/dev/null | head -30

echo ""
echo "=== pc.index() signature ==="
find node_modules/@pinecone-database/pinecone/dist -name "*.d.ts" 2>/dev/null | xargs grep -A3 "index(" 2>/dev/null | grep -E "index\(|IndexName|PineconeIndex" | head -20

echo ""
echo "=== Check for examples/tsconfig.json ==="
ls examples/ 2>/dev/null

echo ""
echo "=== Check if examples/quickstart/.env is gitignored ==="
git check-ignore -v examples/quickstart/.env 2>/dev/null || echo "NOT gitignored"

echo ""
echo "=== existing alliance demo files check ==="
cat examples/alliance/suggest-flow-demo.ts

Length of output: 4122



@jonathanMLDev: Here is a full review of PR #115.


PR Review — docs(examples): generic quickstart + alliance examples layout

Overall the structure is clean and well-documented. Two runtime bugs in seed-data.ts need fixing before this works end-to-end; a few medium-priority issues in mcp-demo.ts are worth addressing before merge.


🔴 Critical — examples/quickstart/seed-data.ts

1. pc.index({ name: indexName }) — wrong API shape

The Pinecone TypeScript SDK Pinecone#index() method takes a string (index name), not an object. The current call will fail at runtime with a type/runtime error.

// ❌ current
const index = pc.index({ name: indexName }).namespace(namespace);

// ✅ fix
const index = pc.index(indexName).namespace(namespace);

2. upsertRecords({ records }) — wrong argument type

For integrated-embedding indexes, upsertRecords() takes the array directly, not a wrapper object. The current call will silently upsert nothing (or throw depending on SDK version).

// ❌ current
await index.upsertRecords({ records });

// ✅ fix
await index.upsertRecords(records);

🟡 Medium — examples/quickstart/mcp-demo.ts

3. Missing isError check on list_namespaces result

countRaw and queryRaw both guard with if (raw.isError) throw … before calling parseToolJson, but listRaw does not. A list_namespaces failure will produce a confusing downstream error.

// After:  const listRaw = await client.callTool({ name: 'list_namespaces', arguments: {} });
if (listRaw.isError) {
  throw new Error(`list_namespaces failed: ${JSON.stringify(listRaw)}`);
}
const listPayload = parseToolJson(listRaw) as {  };

4. Process may hang on success — no process.exit(0)

After main() resolves, open SDK handles (keep-alive timers, transport streams) may prevent the process from exiting. The seed-data.ts script exits cleanly via process.exit(1) on error; mcp-demo.ts should mirror that:

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
// Add to guarantee clean exit:
// main().then(() => process.exit(0)).catch(…)

Or inline:

main()
  .then(() => { process.exit(0); })
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });

🟡 Medium — Root .env.example

5. PINECONE_RERANK_MODEL is uncommented with a concrete default

Free-tier users following the quickstart who source the root .env.example will have PINECONE_RERANK_MODEL=bge-reranker-v2-m3 active even though that model may not be available on their Pinecone project (and the quickstart explicitly avoids Alliance defaults). Consider commenting it out:

-PINECONE_RERANK_MODEL=bge-reranker-v2-m3
+# PINECONE_RERANK_MODEL=bge-reranker-v2-m3

🟢 Low / Nits

6. Unreachable return after process.exit()seed-data.ts

process.exit(dryRun ? 0 : 1);
return;  // ← never reached; safe to remove

7. mcp-demo.ts finally block calls teardownServer() unconditionally

If server.connect() or client.connect() throws, teardownServer() is called before the server was fully initialized, which may emit a secondary error and obscure the root cause. A simple guard helps:

let serverReady = false;
// … after successful connect:
serverReady = true;
// … in finally:
if (serverReady) teardownServer();

✅ What looks good

  • Directory reorganization is clean; git-mv preserves history for the moved Alliance files.
  • QUICKSTART_NAMESPACE export from seed-data.ts and its import in mcp-demo.ts keep the namespace in sync nicely.
  • isDirectRun guard in seed-data.ts correctly prevents auto-execution on import.
  • .env gitignoreexamples/quickstart/.env is covered by the root .gitignore .env pattern. ✓
  • examples/tsconfig.json exists; the examples/README.md path alias reference is correct. ✓
  • Troubleshooting table in quickstart/README.md anticipates the most common failure modes (FLOW_GATE, empty namespaces, hybrid partial results).
  • Dry-run support in seed-data.ts is a nice touch for CI/docs validation.

Summary

Severity File Issue
🔴 Critical seed-data.ts pc.index({ name })pc.index(name)
🔴 Critical seed-data.ts upsertRecords({ records })upsertRecords(records)
🟡 Medium mcp-demo.ts Missing isError check on list_namespaces
🟡 Medium mcp-demo.ts No process.exit(0) — process may hang on success
🟡 Medium root .env.example PINECONE_RERANK_MODEL uncommented may surprise free-tier users
🟢 Low seed-data.ts Unreachable return after process.exit()
🟢 Low mcp-demo.ts teardownServer() called before confirming server was ready
✅ Actions performed

Full review triggered.

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

🤖 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 `@examples/quickstart/mcp-demo.ts`:
- Line 69: The local variable "connected" in examples/quickstart/mcp-demo.ts is
redundant (set to true and never changed); remove its declaration and the
conditional check in the finally block, and always run the cleanup logic there
(e.g., call the same disconnect/cleanup functions directly). Update any
references to "connected" (if present) and ensure the finally block performs the
intended cleanup without the dead "if (connected)" branch.
🪄 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: 60dddd8b-4159-4ced-97b5-3071e9433eb5

📥 Commits

Reviewing files that changed from the base of the PR and between 3b6094b and 65dfae4.

📒 Files selected for processing (5)
  • .env.example
  • README.md
  • docs/CONFIGURATION.md
  • examples/quickstart/mcp-demo.ts
  • examples/quickstart/seed-data.ts
✅ Files skipped from review due to trivial changes (3)
  • .env.example
  • docs/CONFIGURATION.md
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/quickstart/seed-data.ts

Comment thread examples/quickstart/mcp-demo.ts Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@jonathanMLDev jonathanMLDev requested a review from wpak-ai May 28, 2026 14:04
@wpak-ai wpak-ai merged commit 297eb32 into cppalliance:main May 28, 2026
12 checks passed
@jonathanMLDev jonathanMLDev deleted the feat/quickstart-examples branch June 1, 2026 17:43
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.

Update Examples to Not Require Alliance Pinecone Instance

2 participants