Skip to content

fix(docs-mcp-server): resolve package path on Windows startup#2474

Merged
colinaaa merged 2 commits intolynx-family:mainfrom
JohnieXu:fix/docs-mcp-windows-pkgpath
Apr 20, 2026
Merged

fix(docs-mcp-server): resolve package path on Windows startup#2474
colinaaa merged 2 commits intolynx-family:mainfrom
JohnieXu:fix/docs-mcp-windows-pkgpath

Conversation

@JohnieXu
Copy link
Copy Markdown
Contributor

@JohnieXu JohnieXu commented Apr 17, 2026

Summary

  • Replace file URL pathname usage with fileURLToPath(import.meta.url) + dirname(...) before package discovery
  • Add a guard that throws a clear error when findPackage.up(...) cannot resolve package.json
  • Prevent startup crashes caused by readFile(undefined, 'utf-8') on Windows

Test plan

  • Verified code change is minimal and scoped to packages/mcp-servers/docs-mcp-server/main.ts
  • Build/test in CI (local install blocked by repo engine requirement: Node ^22 || ^24, current env is Node v20.19.0)

Summary by CodeRabbit

  • Bug Fixes

    • Improved startup reliability with clearer error messages when initialization cannot find required configuration, preventing silent failures.
    • Resolved a Windows startup issue that could prevent the service from launching.
  • Chores

    • Added release metadata for a patch update to deploy the fix.

Resolve package.json lookup from file URL using fileURLToPath/dirname and add an explicit guard when package discovery fails, preventing startup crashes from readFile(undefined).

Made-with: Cursor
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 17, 2026

🦋 Changeset detected

Latest commit: 97de09a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lynx-js/docs-mcp-server Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 58e641d3-4f4f-4d29-a9ad-34089986643d

📥 Commits

Reviewing files that changed from the base of the PR and between 4a5a06d and 97de09a.

📒 Files selected for processing (1)
  • .changeset/pink-items-deliver.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/pink-items-deliver.md

📝 Walkthrough

Walkthrough

The change updates package.json discovery in docs-mcp-server to compute the directory with dirname(fileURLToPath(import.meta.url)) and uses it as the cwd for findPackage.up(...); it also adds a runtime guard that throws if findPackage.up(...) fails to locate package.json.

Changes

Cohort / File(s) Summary
Package.json discovery & runtime guard
packages/mcp-servers/docs-mcp-server/main.ts
Replaced new URL('.', import.meta.url).pathname with dirname(fileURLToPath(import.meta.url)) for directory resolution and added an explicit error throw when findPackage.up(...) returns undefined.
Release metadata
.changeset/pink-items-deliver.md
Added a changeset for @lynx-js/docs-mcp-server marking a patch release referencing a Windows startup error fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I hopped from URL to file with care,

dirname and fileURL led me there,
If package.json hides, I loudly cry,
"Find it or fail!" — beneath the sky,
A tiny rabbit, error-safe and spry.

🚥 Pre-merge checks | ✅ 3
✅ 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 directly matches the main change: fixing a package path resolution issue on Windows startup in the docs-mcp-server.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented Apr 17, 2026

CLA assistant check
All committers have signed the CLA.

Signed-off-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@colinaaa colinaaa left a comment

Choose a reason for hiding this comment

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

Thank you!

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/mcp-servers/docs-mcp-server/main.ts 0.00% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 20, 2026

Merging this PR will improve performance by 16.77%

⚡ 1 improved benchmark
✅ 80 untouched benchmarks
⏩ 26 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 47.7 ms 40.8 ms +16.77%

Comparing JohnieXu:fix/docs-mcp-windows-pkgpath (97de09a) with main (fb7bc84)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 20, 2026

React External

#529 Bundle Size — 580.35KiB (0%).

97de09a(current) vs 3118b10 main#524(baseline)

Bundle metrics  no changes
                 Current
#529
     Baseline
#524
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#529
     Baseline
#524
No change  Other 580.35KiB 580.35KiB

Bundle analysis reportBranch JohnieXu:fix/docs-mcp-windows-pk...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 20, 2026

React MTF Example

#545 Bundle Size — 193.94KiB (0%).

97de09a(current) vs 3118b10 main#540(baseline)

Bundle metrics  no changes
                 Current
#545
     Baseline
#540
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 173 173
No change  Duplicate Modules 66 66
No change  Duplicate Code 43.94% 43.94%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#545
     Baseline
#540
No change  IMG 111.23KiB 111.23KiB
No change  Other 82.71KiB 82.71KiB

Bundle analysis reportBranch JohnieXu:fix/docs-mcp-windows-pk...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 20, 2026

Web Explorer

#8986 Bundle Size — 898.09KiB (-0.03%).

97de09a(current) vs 3118b10 main#8981(baseline)

Bundle metrics  Change 3 changes
                 Current
#8986
     Baseline
#8981
No change  Initial JS 44.47KiB 44.47KiB
No change  Initial CSS 2.16KiB 2.16KiB
Change  Cache Invalidation 13.64% 0%
No change  Chunks 9 9
No change  Assets 11 11
Change  Modules 230(-0.43%) 231
No change  Duplicate Modules 11 11
Change  Duplicate Code 27.21%(+0.04%) 27.2%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#8986
     Baseline
#8981
Improvement  JS 494.3KiB (-0.05%) 494.55KiB
No change  Other 401.63KiB 401.63KiB
No change  CSS 2.16KiB 2.16KiB

Bundle analysis reportBranch JohnieXu:fix/docs-mcp-windows-pk...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 20, 2026

React Example

#7412 Bundle Size — 223.33KiB (0%).

97de09a(current) vs 3118b10 main#7407(baseline)

Bundle metrics  no changes
                 Current
#7412
     Baseline
#7407
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 179 179
No change  Duplicate Modules 69 69
No change  Duplicate Code 44.48% 44.48%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7412
     Baseline
#7407
No change  IMG 145.76KiB 145.76KiB
No change  Other 77.58KiB 77.58KiB

Bundle analysis reportBranch JohnieXu:fix/docs-mcp-windows-pk...Project dashboard


Generated by RelativeCIDocumentationReport issue

@colinaaa colinaaa merged commit 99172f1 into lynx-family:main Apr 20, 2026
100 of 107 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.

docs-mcp-server crashes on Windows: readFile receives undefined path at startup

2 participants