feat: introduce @lynx-js/docs-mcp-server#1925
Conversation
🦋 Changeset detectedLatest commit: 654bea7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughA new MCP server package is introduced that serves Markdown documentation from a configurable base URL. The server extracts and registers internal links as MCP resources, enabling dynamic content fetching on demand. Supporting configuration files, documentation, and a changelog entry accompany the implementation. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (10)📓 Common learnings📚 Learning: 2025-11-06T01:19:23.670ZApplied to files:
📚 Learning: 2025-09-12T09:43:04.847ZApplied to files:
📚 Learning: 2025-08-19T11:25:36.127ZApplied to files:
📚 Learning: 2025-08-13T11:36:12.075ZApplied to files:
📚 Learning: 2025-09-12T09:43:04.847ZApplied to files:
📚 Learning: 2025-11-06T01:17:11.892ZApplied to files:
📚 Learning: 2025-08-27T08:10:09.932ZApplied to files:
📚 Learning: 2025-08-20T04:56:36.011ZApplied to files:
📚 Learning: 2025-08-13T11:46:43.737ZApplied to files:
🔇 Additional comments (5)
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. Comment |
5c72897 to
76360c1
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new MCP (Model Context Protocol) server package for serving Lynx documentation to LLMs. The server fetches and parses markdown documentation from the Lynx website, registers them as MCP resources, and makes them available to LLM clients through the stdio transport protocol.
- Adds a new
@lynx-js/docs-mcp-serverpackage with dependencies for MCP SDK, markdown parsing, and HTTP fetching - Implements a CLI tool that fetches documentation from a configurable base URL and exposes it via MCP
- Updates workspace configuration to include the new MCP servers packages
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Adds packages/mcp-servers/* to workspace packages |
| pnpm-lock.yaml | Adds dependencies for MCP SDK, commander, debug, markdown utilities, and undici |
| packages/mcp-servers/docs-mcp-server/package.json | Defines package metadata, scripts, and dependencies for the docs MCP server |
| packages/mcp-servers/docs-mcp-server/tsconfig.json | TypeScript configuration for the MCP server package |
| packages/mcp-servers/docs-mcp-server/main.ts | Main implementation of the MCP server CLI tool |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "outDir": "dist", | ||
| }, | ||
| "include": ["src", "main.ts"], |
There was a problem hiding this comment.
Trailing comma on line 8 in a JSON file will cause parse errors. JSON does not allow trailing commas before closing braces.
| "outDir": "dist", | |
| }, | |
| "include": ["src", "main.ts"], | |
| "outDir": "dist" | |
| }, | |
| "include": ["src", "main.ts"] |
| // NOTE: This instruction for now is not supported by Codex's MCP support, | ||
| // see https://github.com/openai/codex/issues/6148 |
There was a problem hiding this comment.
The comment references 'Codex', which appears to be incorrect. Based on the context of MCP (Model Context Protocol), this should likely reference 'Claude' or another LLM client, not OpenAI's Codex.
| // NOTE: This instruction for now is not supported by Codex's MCP support, | |
| // see https://github.com/openai/codex/issues/6148 | |
| // NOTE: This instruction is not currently supported by most MCP clients (e.g., Claude). | |
| // See the relevant client documentation or issue trackers for updates. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (2)
packages/mcp-servers/docs-mcp-server/main.ts (1)
134-135: Update MCP client reference from "Codex" to appropriate LLM client.The comment incorrectly references "Codex" (OpenAI's old model). Based on the MCP protocol context, this should reference Claude or other supported LLM clients. This was flagged in a prior review but remains unaddressed.
- // NOTE: This instruction for now is not supported by Codex's MCP support, - // see https://github.com/openai/codex/issues/6148 + // NOTE: This instruction for now is not fully supported by all MCP clients. + // See the relevant client documentation for updates on supported features.packages/mcp-servers/docs-mcp-server/tsconfig.json (1)
8-9: Fix JSON syntax error: trailing comma before closing brace.JSON does not permit trailing commas. Line 8 has a trailing comma that will cause parsing errors during build and TypeScript compilation.
Apply this diff to fix the syntax error:
"compilerOptions": { "allowImportingTsExtensions": false, "isolatedDeclarations": false, "emitDeclarationOnly": false, "types": ["node"], - "outDir": "dist", + "outDir": "dist" },
🧹 Nitpick comments (2)
packages/mcp-servers/docs-mcp-server/package.json (2)
17-17: Upgradeempathicto use caret range for consistency.The
empathicdependency is pinned to an exact version while all other dependencies use caret ranges. Adopt the same versioning pattern for consistency and to allow patch updates.- "empathic": "2.0.0", + "empathic": "^2.0.0",
14-14: Consider upgrading@modelcontextprotocol/sdkto the latest patch.The latest version of
@modelcontextprotocol/sdkis 1.20.1, which includes recent fixes. You're currently at 1.20.0. Consider updating to the latest patch version.- "@modelcontextprotocol/sdk": "^1.20.0", + "@modelcontextprotocol/sdk": "^1.20.1",
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.changeset/public-carrots-search.md(1 hunks)packages/mcp-servers/docs-mcp-server/main.ts(1 hunks)packages/mcp-servers/docs-mcp-server/package.json(1 hunks)packages/mcp-servers/docs-mcp-server/tsconfig.json(1 hunks)pnpm-workspace.yaml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
For contributions, generate and commit a Changeset describing your changes
Files:
.changeset/public-carrots-search.md
🧠 Learnings (19)
📓 Common learnings
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/tsconfig.json:8-8
Timestamp: 2025-11-06T01:19:23.670Z
Learning: The lynx-js/devtool-mcp-server package in lynx-family/lynx-stack targets Node.js >=18.19 (specified in its package.json engines), which is different from the root project's requirement of Node.js ^22 || ^24. The package uses "lib": ["ES2024.Promise"] in its tsconfig.json because it manually includes polyfills for Promise.withResolvers while maintaining compatibility with Node.js v18.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/src/connector.ts:347-368
Timestamp: 2025-11-06T01:17:11.892Z
Learning: In the lynx-family/lynx-stack repository, for the devtool-mcp-server package, the getSource and getConsole methods intentionally throw errors when collectors don't exist (rather than returning empty arrays) to provide clear feedback to code agents and automation tools that something is wrong (e.g., debugger not enabled, collectors not initialized), enabling them to take corrective action.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
📚 Learning: 2025-11-06T01:19:23.670Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/tsconfig.json:8-8
Timestamp: 2025-11-06T01:19:23.670Z
Learning: The lynx-js/devtool-mcp-server package in lynx-family/lynx-stack targets Node.js >=18.19 (specified in its package.json engines), which is different from the root project's requirement of Node.js ^22 || ^24. The package uses "lib": ["ES2024.Promise"] in its tsconfig.json because it manually includes polyfills for Promise.withResolvers while maintaining compatibility with Node.js v18.
Applied to files:
packages/mcp-servers/docs-mcp-server/tsconfig.jsonpackages/mcp-servers/docs-mcp-server/package.jsonpnpm-workspace.yamlpackages/mcp-servers/docs-mcp-server/main.ts
📚 Learning: 2025-08-18T08:46:20.001Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1547
File: packages/rspeedy/core/src/config/loadConfig.ts:11-11
Timestamp: 2025-08-18T08:46:20.001Z
Learning: `#register` and similar imports starting with "#" are Node.js subpath imports defined in the "imports" field of package.json, not TypeScript path mapping aliases. These are natively supported by both Node.js and TypeScript without requiring additional tsconfig.json configuration like "moduleResolution" or "resolvePackageJsonImports" settings.
Applied to files:
packages/mcp-servers/docs-mcp-server/tsconfig.json
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.
Applied to files:
.changeset/public-carrots-search.mdpackages/mcp-servers/docs-mcp-server/package.json
📚 Learning: 2025-07-22T09:26:16.722Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.
Applied to files:
.changeset/public-carrots-search.md
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to .changeset/*.md : For contributions, generate and commit a Changeset describing your changes
Applied to files:
.changeset/public-carrots-search.md
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
Applied to files:
packages/mcp-servers/docs-mcp-server/package.jsonpnpm-workspace.yaml
📚 Learning: 2025-08-13T11:36:12.075Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:52-72
Timestamp: 2025-08-13T11:36:12.075Z
Learning: The lynx-stack project requires Node.js >=22 as specified in package.json engines, so Node.js compatibility fallbacks for features introduced before v22 are unnecessary.
Applied to files:
packages/mcp-servers/docs-mcp-server/package.json
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).
Applied to files:
packages/mcp-servers/docs-mcp-server/package.json
📚 Learning: 2025-08-27T08:10:09.932Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.
Applied to files:
packages/mcp-servers/docs-mcp-server/package.json
📚 Learning: 2025-08-20T04:56:36.011Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1566
File: package.json:53-53
Timestamp: 2025-08-20T04:56:36.011Z
Learning: In lynx-stack, Node.js v24 is the preferred/default version for development (established in PR #1557), but Node.js v22 compatibility is maintained specifically for external CI systems like rspack-ecosystem-ci. The engines.node specification uses "^22 || ^24" to support both versions while keeping v24 as the primary target.
Applied to files:
packages/mcp-servers/docs-mcp-server/package.json
📚 Learning: 2025-11-06T01:17:11.892Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/src/connector.ts:347-368
Timestamp: 2025-11-06T01:17:11.892Z
Learning: In the lynx-family/lynx-stack repository, for the devtool-mcp-server package, the getSource and getConsole methods intentionally throw errors when collectors don't exist (rather than returning empty arrays) to provide clear feedback to code agents and automation tools that something is wrong (e.g., debugger not enabled, collectors not initialized), enabling them to take corrective action.
Applied to files:
packages/mcp-servers/docs-mcp-server/package.jsonpackages/mcp-servers/docs-mcp-server/main.ts
📚 Learning: 2025-08-13T11:46:43.737Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:5-6
Timestamp: 2025-08-13T11:46:43.737Z
Learning: In the lynx-stack codebase, default imports are consistently used for Node.js built-in modules (e.g., `import os from 'node:os'`, `import fs from 'node:fs'`). The TypeScript configuration supports esModuleInterop and allowSyntheticDefaultImports, making default imports the preferred pattern over namespace imports for Node.js built-ins.
Applied to files:
packages/mcp-servers/docs-mcp-server/package.json
📚 Learning: 2025-08-14T12:54:51.143Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: .changeset/brave-melons-add.md:1-7
Timestamp: 2025-08-14T12:54:51.143Z
Learning: In the lynx-family/lynx-stack repository, packages use 0.x.x versioning where minor version bumps indicate breaking changes (not major bumps), following pre-1.0 semantic versioning conventions.
Applied to files:
packages/mcp-servers/docs-mcp-server/package.json
📚 Learning: 2025-08-06T08:25:15.392Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1447
File: pnpm-workspace.yaml:20-22
Timestamp: 2025-08-06T08:25:15.392Z
Learning: In pnpm, configDependencies in pnpm-workspace.yaml (used for plugins like pnpm/plugin-better-defaults and pnpm/plugin-trusted-deps) do not appear in or modify pnpm-lock.yaml. These plugins are managed separately by pnpm itself, not as part of the workspace's dependency tree. This is different from the internal configDependencies field that can appear within pnpm-lock.yaml for tracking configuration file dependencies.
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-08-06T08:25:15.392Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1447
File: pnpm-workspace.yaml:20-22
Timestamp: 2025-08-06T08:25:15.392Z
Learning: In pnpm, configDependencies in pnpm-workspace.yaml (used for plugins like pnpm/plugin-better-defaults and pnpm/plugin-trusted-deps) do not appear in or modify pnpm-lock.yaml. These plugins are managed separately by pnpm itself as configuration-level dependencies, not as part of the workspace's dependency tree. Running pnpm install after adding configDependencies will not change the lockfile.
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-10-29T10:28:27.519Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js:20-24
Timestamp: 2025-10-29T10:28:27.519Z
Learning: Files inside packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/ are auto-generated test snapshot files and should not be manually updated. Any issues with the generated code should be addressed in the code generator/transform logic, not in the snapshots themselves.
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.
Applied to files:
pnpm-workspace.yaml
🪛 LanguageTool
.changeset/public-carrots-search.md
[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: --- ---
(QB_NEW_DE)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build / Build (Windows)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (2)
pnpm-workspace.yaml (1)
6-6: Workspace configuration correctly updated.The addition of
packages/mcp-servers/*properly integrates new MCP server packages into the monorepo workspace, enabling dependency resolution and hoisting for all packages under that directory.packages/mcp-servers/docs-mcp-server/package.json (1)
20-20: Verify undici version addresses known security vulnerabilities.The version
6.22.0should resolve CVE-2025-22150 (fixed in 6.21.1+), however please confirm the package.json dependency declaration is using the correct version and that no other undici-related vulnerabilities apply to this use case.
| --- | ||
|
|
||
| --- |
There was a problem hiding this comment.
Changeset requires meaningful content for this public package.
An empty changeset is only appropriate for private packages. Since @lynx-js/docs-mcp-server is a new public package, the changeset should document the addition with a version bump and description. Based on learnings, public packages require meaningful changelog entries.
Add changeset content describing this new package:
---
-
+@lynx-js/docs-mcp-server: minor
---
+Introduce a new MCP server for providing Lynx documentation resources to LLM clients. The server fetches and registers Markdown documentation from a configurable base URL with automatic resource discovery and content resolution.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| --- | |
| --- | |
| --- | |
| @lynx-js/docs-mcp-server: minor | |
| --- | |
| Introduce a new MCP server for providing Lynx documentation resources to LLM clients. The server fetches and registers Markdown documentation from a configurable base URL with automatic resource discovery and content resolution. |
🧰 Tools
🪛 LanguageTool
[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: --- ---
(QB_NEW_DE)
🤖 Prompt for AI Agents
.changeset/public-carrots-search.md lines 1-3: the changeset file is empty which
is invalid for a new public package; update this file to include a meaningful
changeset entry that names the package @lynx-js/docs-mcp-server, specifies the
new version bump (e.g., minor or patch as appropriate), and includes a short
descriptive summary of the change (e.g., "add new public package
@lynx-js/docs-mcp-server: initial release — implements X and Y"), then save the
file so the changeset contains valid YAML/frontmatter and a description for the
changelog.
| async () => ({ | ||
| contents: [ | ||
| { | ||
| uri: `lynx-docs://${strippedUrl}`, | ||
| text: await fetch(link.url).then((res) => res.text()), | ||
| mimeType: 'text/markdown', | ||
| }, | ||
| ], | ||
| }), | ||
| ); |
There was a problem hiding this comment.
Add error handling for content resolution fetch.
The dynamic content resolver on line 113 lacks error handling. If the fetch fails or the URL is inaccessible, the error will propagate unhandled and crash the MCP server. Wrap the fetch in a try-catch to provide graceful error handling.
async () => ({
contents: [
{
uri: `lynx-docs://${strippedUrl}`,
- text: await fetch(link.url).then((res) => res.text()),
+ text: await fetch(link.url)
+ .then((res) => {
+ if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
+ return res.text();
+ })
+ .catch((error) => {
+ debug(`Failed to fetch ${link.url}:`, error);
+ throw new Error(`Cannot retrieve content for ${link.url}`);
+ }),
mimeType: 'text/markdown',
},
],
}),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async () => ({ | |
| contents: [ | |
| { | |
| uri: `lynx-docs://${strippedUrl}`, | |
| text: await fetch(link.url).then((res) => res.text()), | |
| mimeType: 'text/markdown', | |
| }, | |
| ], | |
| }), | |
| ); | |
| async () => ({ | |
| contents: [ | |
| { | |
| uri: `lynx-docs://${strippedUrl}`, | |
| text: await fetch(link.url) | |
| .then((res) => { | |
| if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`); | |
| return res.text(); | |
| }) | |
| .catch((error) => { | |
| debug(`Failed to fetch ${link.url}:`, error); | |
| throw new Error(`Cannot retrieve content for ${link.url}`); | |
| }), | |
| mimeType: 'text/markdown', | |
| }, | |
| ], | |
| }), |
🤖 Prompt for AI Agents
In packages/mcp-servers/docs-mcp-server/main.ts around lines 109 to 118, the
dynamic content resolver calls fetch(link.url) without error handling which can
propagate exceptions and crash the MCP server; wrap the await
fetch(...).then(res => res.text()) in a try-catch, log the error (using the
existing server logger or console.error), and return a safe fallback object with
the same shape (e.g., contents array with a placeholder text or empty string and
appropriate mimeType) so the resolver always resolves gracefully instead of
allowing the exception to bubble.
| async function main(baseUrl: string) { | ||
| const ROOT_DOC_URL = `${baseUrl}/llms.txt`; | ||
| const ROOT_DOC_MARKDOWN = await fetch(ROOT_DOC_URL).then((res) => res.text()); |
There was a problem hiding this comment.
Add error handling for root document fetch.
The root document fetch on line 124 lacks error handling. If the fetch fails or baseUrl/llms.txt is unreachable, the error will crash the server during startup.
async function main(baseUrl: string) {
const ROOT_DOC_URL = `${baseUrl}/llms.txt`;
- const ROOT_DOC_MARKDOWN = await fetch(ROOT_DOC_URL).then((res) => res.text());
+ try {
+ const response = await fetch(ROOT_DOC_URL);
+ if (!response.ok) {
+ throw new Error(`Failed to fetch root doc: HTTP ${response.status}`);
+ }
+ const ROOT_DOC_MARKDOWN = await response.text();
+ } catch (error) {
+ debug(`Error fetching root documentation from ${ROOT_DOC_URL}:`, error);
+ throw error;
+ }Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/mcp-servers/docs-mcp-server/main.ts around lines 122 to 124, the
fetch of the root document (ROOT_DOC_URL) has no error handling; wrap the fetch
and text extraction in a try/catch (or check response.ok) to handle network or
non-2xx responses, log the error with context, and fallback to a safe default
(e.g., empty string or cached content) so server startup does not crash; ensure
the function returns or continues safely when the root doc cannot be retrieved.
CodSpeed Performance ReportMerging #1925 will not alter performanceComparing Summary
Footnotes
|
React Example#6153 Bundle Size — 234.35KiB (0%).2e8296d(current) vs ebc1a60 main#6145(baseline) Bundle metrics
Bundle size by type
|
| Current #6153 |
Baseline #6145 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
88.59KiB |
88.59KiB |
Bundle analysis report Branch hzy:p/hzy/docs-mcp-server Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#6168 Bundle Size — 366.74KiB (0%).654bea7(current) vs 3bc8903 main#6165(baseline) Bundle metrics
Bundle size by type
|
| Current #6168 |
Baseline #6165 |
|
|---|---|---|
240.72KiB |
240.72KiB |
|
93.8KiB |
93.8KiB |
|
32.22KiB |
32.22KiB |
Bundle analysis report Branch hzy:p/hzy/docs-mcp-server Project dashboard
Generated by RelativeCI Documentation Report issue
76360c1 to
2e8296d
Compare
Summary by CodeRabbit
New Features
Documentation
Checklist