Skip to content

feat: add enclave mcp package#1390

Merged
cedoor merged 5 commits into
mainfrom
feat/enclave-mcp
Mar 9, 2026
Merged

feat: add enclave mcp package#1390
cedoor merged 5 commits into
mainfrom
feat/enclave-mcp

Conversation

@cedoor

@cedoor cedoor commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Closes #1058

Summary by CodeRabbit

  • New Features

    • Adds an MCP server integration for Enclave docs with tools to list, read, and search documentation pages and an executable CLI.
  • Documentation

    • Adds a comprehensive README with usage, configuration snippets, and integration guides for Claude Desktop, VS Code, Cursor, and Windsurf.
  • Chores

    • Adds build/release scripts and includes the new package in the workspace to enable build and publish workflows.

@cedoor cedoor requested a review from ctrlc03 March 6, 2026 14:02
@vercel

vercel Bot commented Mar 6, 2026

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
crisp Skipped Skipped Mar 6, 2026 3:01pm
enclave-docs Skipped Skipped Mar 6, 2026 3:01pm

Request Review

@coderabbitai

coderabbitai Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2cd7d886-d64f-4db3-8906-9bd82e39c7b1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new @enclave-e3/mcp package that runs an MCP documentation server (list/read/search docs), integrates it into the monorepo build/release scripts, and registers the package in workspace and version-bump tooling. Includes TypeScript build config, bundler config, and README.

Changes

Cohort / File(s) Summary
MCP Server Core Implementation
packages/enclave-mcp/src/index.ts
New MCP server implementation: loads sitemap, fetches/sanitizes doc pages, registers per-page resources and three tools (list_docs, read_doc, search_docs), and connects via stdio transport.
MCP Package Configuration
packages/enclave-mcp/package.json, packages/enclave-mcp/tsconfig.json, packages/enclave-mcp/tsup.config.ts
New package manifest and build config: bin entry, dependencies, scripts (build/dev/prerelease/release), tsconfig for ESM, and tsup bundler config with node shebang.
MCP Package Documentation
packages/enclave-mcp/README.md
New README documenting MCP tools, integration snippets for Claude/VSCode/Cursor/Windsurf, usage examples, and license.
Monorepo Integration
package.json, pnpm-workspace.yaml, scripts/bump-versions.ts
Root changes to include enclave-mcp in workspace, add mcp:build and mcp:release scripts and chain them into existing build:ts and npm:release, and add package to version-bump list.
Build Script Cleanup
scripts/build-circuits.ts
Removed unused CircuitVariant type import from circuit-constants.

Sequence Diagram

sequenceDiagram
    autonumber
    actor Client
    participant MCP as MCP Server
    participant Fetcher as Doc Fetcher
    participant Parser as HTML Parser
    participant Transport as StdioTransport

    Client->>MCP: read_doc(slug)
    activate MCP
    MCP->>Fetcher: fetchDocPage(url)
    activate Fetcher
    Fetcher->>Parser: parse & sanitize HTML
    activate Parser
    Parser-->>Fetcher: cleaned text/markdown
    deactivate Parser
    Fetcher-->>MCP: page content
    deactivate Fetcher
    MCP-->>Client: title + content
    deactivate MCP

    Client->>MCP: search_docs(query)
    activate MCP
    MCP->>Fetcher: fetchDocPage (parallel for all pages)
    activate Fetcher
    Fetcher-->>MCP: page contents or per-page errors
    deactivate Fetcher
    Note over MCP: case-insensitive search, snippets returned
    MCP-->>Client: matching snippets
    deactivate MCP

    MCP->>Transport: connect()
    Transport-->>MCP: stdin/stdout messages
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ctrlc03
  • ryardley

Poem

🐰 I nibble docs and hop with cheer,

MCP whispers, "Knowledge near!"
Slugs and snippets, tidy and bright,
I bounce—your docs now take to flight. 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 and concisely describes the main change: adding a new enclave-mcp package as an official MCP server for Enclave documentation.
Linked Issues check ✅ Passed The pull request successfully implements all core requirements from issue #1058: provides an official MCP server package with documentation tools (list_docs, read_doc, search_docs), integration guides for MCP-compatible environments, and makes Enclave docs programmatically accessible to LLMs.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the MCP server package. Minor updates to root package.json scripts, pnpm workspace config, and build scripts are necessary supporting changes with no extraneous modifications.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/enclave-mcp

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/bump-versions.ts (1)

385-391: ⚠️ Potential issue | 🟡 Minor

Keep the dry-run output aligned with the actual bump list.

packages/enclave-mcp is now updated in bumpNpmPackages(), but the --dry-run summary above still omits it. That makes the release preview incomplete.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/bump-versions.ts` around lines 385 - 391, The dry-run summary is
missing 'packages/enclave-mcp' even though bumpNpmPackages() now updates it;
update the packagesToBump array used for the dry-run output to include
'packages/enclave-mcp' so the preview matches the real bump list, i.e., locate
the packagesToBump constant and add the same entry used by bumpNpmPackages()
(ensure both lists are derived from the same source or consolidate into a single
source of truth to avoid future drift).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/enclave-mcp/package.json`:
- Around line 1-35: Add an "engines" field to package.json specifying Node
>=18.20.0 to ensure required ESM features (JSON import attributes, global fetch,
top-level await) are available; update the package's README to document the Node
requirement and the CLI runtime expectation. Locate the package.json top-level
object (around "name", "version", "type", "bin") and add "engines": { "node":
">=18.20.0" }, and add a short note in the README mentioning the Node version
requirement for running the enclave-mcp CLI.

In `@packages/enclave-mcp/src/index.ts`:
- Around line 117-145: The search_docs tool currently swallows fetchDocPage
errors and accepts empty queries; update the server.registerTool handler for
'search_docs' to validate and reject empty/whitespace-only queries up front, and
collect page-load errors instead of ignoring them: when iterating DOC_PAGES and
calling fetchDocPage, push failed page identifiers (e.g., page.url or
page.title) into a separate failures array and continue, then after the
Promise.all return a response that includes both results and an explicit
failures summary if any fetches failed (or an error status for widespread
failures); ensure the final no-hit case only returns “No results found” when
there were zero results and zero failures, and surface fetch failures clearly in
the returned content.
- Around line 22-69: The code currently hard-codes DOC_PAGES and scrapes the
rendered DOM in fetchDocPage (using BASE_URL and parse), which is brittle and
lacks a network timeout; replace the static DOC_PAGES with a generated docs
manifest/sitemap (or an API endpoint that returns canonical doc slugs/paths) and
drive your corpus from that manifest instead of the hand-maintained array,
update fetchDocPage to prefer fetching a stable export (raw markdown or a
manifest-provided HTML source) rather than scraping the rendered site, and add a
fetch timeout/AbortController to fetchDocPage so requests cannot hang
indefinitely; keep parse-based DOM fallback only as a last-resort when no
manifest/source is available.
- Line 63: The callback passed to root.querySelectorAll(...).forEach currently
uses an expression-bodied arrow that implicitly returns el.remove(), triggering
the useIterableCallbackReturn rule; change the arrow to a block-bodied callback
so it does not implicitly return (e.g., replace (el) => el.remove() with (el) =>
{ el.remove(); }) ensuring you reference the same root.querySelectorAll and
forEach invocation and the el.remove() call.

---

Outside diff comments:
In `@scripts/bump-versions.ts`:
- Around line 385-391: The dry-run summary is missing 'packages/enclave-mcp'
even though bumpNpmPackages() now updates it; update the packagesToBump array
used for the dry-run output to include 'packages/enclave-mcp' so the preview
matches the real bump list, i.e., locate the packagesToBump constant and add the
same entry used by bumpNpmPackages() (ensure both lists are derived from the
same source or consolidate into a single source of truth to avoid future drift).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ab63c372-7f22-42d5-9992-5a1ce8d7e426

📥 Commits

Reviewing files that changed from the base of the PR and between fcc541f and b19e52d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • package.json
  • packages/enclave-mcp/README.md
  • packages/enclave-mcp/package.json
  • packages/enclave-mcp/src/index.ts
  • packages/enclave-mcp/tsconfig.json
  • packages/enclave-mcp/tsup.config.ts
  • pnpm-workspace.yaml
  • scripts/build-circuits.ts
  • scripts/bump-versions.ts

Comment thread packages/enclave-mcp/package.json
Comment thread packages/enclave-mcp/src/index.ts Outdated
Comment thread packages/enclave-mcp/src/index.ts
Comment thread packages/enclave-mcp/src/index.ts Outdated
@vercel vercel Bot temporarily deployed to Preview – enclave-docs March 6, 2026 15:01 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp March 6, 2026 15:01 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/enclave-mcp/README.md (1)

9-15: Document the MCP resources alongside the tools.

The server also exposes docs://index and per-page docs://<slug> resources, but this README only describes tool calls. Adding a short resources section would make the full client-facing surface discoverable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/enclave-mcp/README.md` around lines 9 - 15, Add a short "Resources"
section to the README documenting the MCP's docs:// resources so consumers can
discover the server-facing URIs in addition to the tool functions; explicitly
mention docs://index for the index and docs://<slug> for per-page access and
show that these correspond to the existing tool names (list_docs, read_doc,
search_docs) so readers understand the relationship between the tools and the
raw resource URIs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/enclave-mcp/src/index.ts`:
- Around line 144-151: The async handler that looks up DOC_PAGES by slug calls
fetchDocPage without handling failures; wrap the fetchDocPage call in a
try/catch inside the async ({ slug }) => handler so that network/parse errors
return a structured MCP error instead of throwing: on catch return { content: [{
type: 'text', text: `Failed to fetch page "${slug}": ${err.message ||
String(err)}` }], isError: true } (preserving the existing invalid-slug
behavior), referencing DOC_PAGES, fetchDocPage and the async ({ slug }) =>
handler to locate where to add the try/catch.
- Around line 90-107: The fetchDocPage function currently fetches every page on
each call; add an in-memory cache (e.g., a Map keyed by fullUrl) at module scope
and check it at the start of fetchDocPage to return cached content when present;
when missing, store the in-flight Promise or resulting content in the cache (to
avoid duplicate concurrent requests), perform the existing fetch/parse/cleanup
logic, then cache and return the cleaned text (use fullUrl as the key and
reference fetchDocPage, fullUrl, and the cached Promise/content in your
implementation).

---

Nitpick comments:
In `@packages/enclave-mcp/README.md`:
- Around line 9-15: Add a short "Resources" section to the README documenting
the MCP's docs:// resources so consumers can discover the server-facing URIs in
addition to the tool functions; explicitly mention docs://index for the index
and docs://<slug> for per-page access and show that these correspond to the
existing tool names (list_docs, read_doc, search_docs) so readers understand the
relationship between the tools and the raw resource URIs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1164db94-bd8b-402f-ad67-0f1e102bf2e0

📥 Commits

Reviewing files that changed from the base of the PR and between b19e52d and 26b8628.

📒 Files selected for processing (3)
  • packages/enclave-mcp/README.md
  • packages/enclave-mcp/package.json
  • packages/enclave-mcp/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/enclave-mcp/package.json

Comment thread packages/enclave-mcp/src/index.ts
Comment thread packages/enclave-mcp/src/index.ts
@cedoor cedoor enabled auto-merge (squash) March 8, 2026 08:33
@cedoor cedoor requested a review from 0xjei March 9, 2026 11:54

@0xjei 0xjei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK

@cedoor cedoor merged commit fc40b34 into main Mar 9, 2026
23 checks passed
@github-actions github-actions Bot deleted the feat/enclave-mcp branch March 17, 2026 03:14
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.

Add an MCP Server (NPM Package) for Enclave

2 participants