Skip to content

feat(docsite): MCP server v2 — hybrid search+get with alias resolution - #2513

Merged
cixzhang merged 4 commits into
mainfrom
navi/feat/mcp-server-v2
Jun 8, 2026
Merged

cixzhang merged 4 commits into
mainfrom
navi/feat/mcp-server-v2

Conversation

@cixzhang

@cixzhang cixzhang commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Brings back the winning hybrid MCP server approach (from navi/feat/mcp-hybrid) with improvements for alias resolution, token budget control, and compound component awareness.

Approach: 2-tool hybrid (search + get)

Tool Purpose Token budget
search(query) Curated brief results with alias resolution ~100-200 tokens per result
get(name) Full component/topic/template details with examples ~1.5-5K tokens per item

Key improvements over v1 hybrid

  1. Semantic alias map — bridges natural language gaps:

    • "success message" → Toast, useXDSToast
    • "dropdown" → Selector, DropdownMenu
    • "admin panel" → AppShell, SideNav
    • "form" → FormLayout, TextInput, Selector
  2. Compound component awareness — requesting Table surfaces sorting/selection hooks via groupMembers

  3. Hook example fallback — hooks like useXDSToast find examples by searching the parent directory/group ("Toast")

  4. Context budget control — doc topics >4K chars get overview + section list with drill-down hint

Vibe test results

Prompt Score Tokens
A1: Finance dashboard 10/10 ~9,248
B1: Admin panel 10/10 ~6,431
C1: Sortable/selectable table 10/10 ~3,992
E1: Form with dropdown 10/10 ~6,815
F1: Success message (Toast) 10/10 ~2,385
G1: Sidebar navigation 10/10 ~4,203
H1: Role dropdown 10/10 ~2,817
Average 10/10 (100%) ~35,891 total

Token comparison

Variant Quality Tokens
v1 hybrid (2-tool) 9.3/10 ~35K
v1 multi (6-tool) 8.6/10 ~17K
v2 hybrid (this PR) 10/10 ~36K

Files changed

  • apps/docsite/src/app/[transport]/route.ts — MCP server route handler
  • apps/docsite/scripts/vibe-test.mjs — Automated vibe test battery
  • apps/docsite/package.json — Added mcp-handler, zod, @modelcontextprotocol/sdk deps

Running the vibe test

cd apps/docsite
pnpm generate  # Generate registries first
node scripts/vibe-test.mjs

Two-tool MCP server for AI agents to discover and use XDS components:
- search(): curated brief results with semantic alias resolution
- get(): full component details with examples and compound awareness

Key features:
- Alias map bridges semantic gaps ("success message" → Toast, "dropdown" → Selector)
- Compound component awareness (Table → sorting/selection hooks via group members)
- Context budget control (~1.5K tokens per brief response)
- Showcase examples included in get() responses
- Hook example fallback (searches by directory/group when no direct match)

Vibe test results: 10/10 (100%) across all 7 prompts at ~36K tokens.

Co-authored-by: Navi <[email protected]>
@vercel

vercel Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
xds-sandbox Ignored Ignored Jun 8, 2026 7:26pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Vercel Preview Deployment

Status ✅ Deployed
Preview Open Preview
Commit 89f3cec
Inspect Vercel Dashboard
Workflow View Logs

No authentication required — anyone with the link can view the preview.

@github-actions

github-actions Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core N/A 4.5KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Remove pretty-printing (null, 2) from JSON.stringify calls. Agents parse
structured JSON fine without indentation — saves ~9K tokens across the
7-prompt battery with zero quality impact.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 5, 2026
- Replace hardcoded ALIASES map with a keyword index built from each
  component's .doc.mjs `keywords` field at init time
- Update all MCP-facing output to use "Astryx (XDS)" branding
- Add MCP Server section to working-with-ai CLI docs with setup
  instructions for Claude Desktop, Cursor, and Windsurf

Addresses PR #2513 review feedback.
@cixzhang
cixzhang marked this pull request as ready for review June 5, 2026 01:02
cixzhang added a commit that referenced this pull request Jun 5, 2026
- Replace hardcoded ALIASES map with a keyword index built from each
  component's .doc.mjs `keywords` field at init time
- Update all MCP-facing output to use "Astryx (XDS)" branding
- Add MCP Server section to working-with-ai CLI docs with setup
  instructions for Claude Desktop, Cursor, and Windsurf

Addresses PR #2513 review feedback.
@cixzhang
cixzhang force-pushed the navi/feat/mcp-server-v2 branch from b573782 to 84b03e5 Compare June 5, 2026 01:04
cixzhang added a commit that referenced this pull request Jun 5, 2026
- Replace hardcoded ALIASES map with a keyword index built from each
  component's .doc.mjs `keywords` field at init time
- Update all MCP-facing output to use "Astryx (XDS)" branding
- Add MCP Server section to working-with-ai CLI docs with setup
  instructions for Claude Desktop, Cursor, and Windsurf

Addresses PR #2513 review feedback.
@cixzhang
cixzhang force-pushed the navi/feat/mcp-server-v2 branch from 84b03e5 to f3db310 Compare June 5, 2026 01:06
- Replace hardcoded ALIASES map with a keyword index built from each
  component's .doc.mjs `keywords` field at init time
- Update all MCP-facing output to use "Astryx (XDS)" branding
- Add MCP Server section to working-with-ai CLI docs with setup
  instructions for Claude Desktop, Cursor, and Windsurf

Addresses PR #2513 review feedback.
@cixzhang
cixzhang force-pushed the navi/feat/mcp-server-v2 branch from f3db310 to b4da937 Compare June 5, 2026 01:18
Merge main to pick up commit 726a159 which aligns the api component()
list-view detail default with the CLI (brief for list views, full for
single-component views). Without this, the API↔CLI parity smoke test
fails with 81 mismatches: the API returns component.full while the CLI
returns component.list for every category.
@cixzhang
cixzhang merged commit 0b18fa6 into main Jun 8, 2026
21 checks passed
cixzhang added a commit that referenced this pull request Jun 21, 2026
#2513)

* feat(docsite): add MCP server v2 with hybrid search+get approach

Two-tool MCP server for AI agents to discover and use XDS components:
- search(): curated brief results with semantic alias resolution
- get(): full component details with examples and compound awareness

Key features:
- Alias map bridges semantic gaps ("success message" → Toast, "dropdown" → Selector)
- Compound component awareness (Table → sorting/selection hooks via group members)
- Context budget control (~1.5K tokens per brief response)
- Showcase examples included in get() responses
- Hook example fallback (searches by directory/group when no direct match)

Vibe test results: 10/10 (100%) across all 7 prompts at ~36K tokens.


* perf(mcp): minify JSON responses (~25% token reduction)

Remove pretty-printing (null, 2) from JSON.stringify calls. Agents parse
structured JSON fine without indentation — saves ~9K tokens across the
7-prompt battery with zero quality impact.


* fix(mcp): derive aliases from doc keywords, brand as Astryx (XDS)

- Replace hardcoded ALIASES map with a keyword index built from each
  component's .doc.mjs `keywords` field at init time
- Update all MCP-facing output to use "Astryx (XDS)" branding
- Add MCP Server section to working-with-ai CLI docs with setup
  instructions for Claude Desktop, Cursor, and Windsurf

Addresses PR #2513 review feedback.

---------
cixzhang added a commit that referenced this pull request Jun 21, 2026
#2513)

* feat(docsite): add MCP server v2 with hybrid search+get approach

Two-tool MCP server for AI agents to discover and use XDS components:
- search(): curated brief results with semantic alias resolution
- get(): full component details with examples and compound awareness

Key features:
- Alias map bridges semantic gaps ("success message" → Toast, "dropdown" → Selector)
- Compound component awareness (Table → sorting/selection hooks via group members)
- Context budget control (~1.5K tokens per brief response)
- Showcase examples included in get() responses
- Hook example fallback (searches by directory/group when no direct match)

Vibe test results: 10/10 (100%) across all 7 prompts at ~36K tokens.


* perf(mcp): minify JSON responses (~25% token reduction)

Remove pretty-printing (null, 2) from JSON.stringify calls. Agents parse
structured JSON fine without indentation — saves ~9K tokens across the
7-prompt battery with zero quality impact.


* fix(mcp): derive aliases from doc keywords, brand as Astryx (XDS)

- Replace hardcoded ALIASES map with a keyword index built from each
  component's .doc.mjs `keywords` field at init time
- Update all MCP-facing output to use "Astryx (XDS)" branding
- Add MCP Server section to working-with-ai CLI docs with setup
  instructions for Claude Desktop, Cursor, and Windsurf

Addresses PR #2513 review feedback.

---------
@cixzhang
cixzhang deleted the navi/feat/mcp-server-v2 branch June 21, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants