fix
This commit is contained in:
18
ISSUES.md
18
ISSUES.md
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
## PDF Reader MCP Connection Issue
|
## PDF Reader MCP Connection Issue
|
||||||
|
|
||||||
**Status:** Open
|
**Status:** Resolved
|
||||||
**Reported:** 2026-02-04
|
**Reported:** 2026-02-04
|
||||||
|
**Resolved:** 2026-02-05
|
||||||
|
|
||||||
**Issue:** The pdf-reader-mcp is in the path, I have enabled it, but it still says connection closed.
|
**Issue:** The pdf-reader-mcp is in the path, I have enabled it, but it still says connection closed.
|
||||||
|
|
||||||
@@ -12,6 +13,19 @@
|
|||||||
- MCP server has been enabled in configuration
|
- MCP server has been enabled in configuration
|
||||||
- Connection still fails with "connection closed" error
|
- Connection still fails with "connection closed" error
|
||||||
|
|
||||||
|
**Root Cause:**
|
||||||
|
The package used an `npx` wrapper that fetched `@sylphx/pdf-reader-mcp` from the npm registry at
|
||||||
|
runtime. On first invocation `npx` needs to download and cache the package before the server process
|
||||||
|
starts, causing the MCP client to time out and close the connection before the server was ready to
|
||||||
|
respond to the initial handshake. The pinned version (2.2.0) was also outdated.
|
||||||
|
|
||||||
|
**Fix:**
|
||||||
|
Rewrote `packages/pdf-reader-mcp/package.nix` to use `buildNpmPackage`, following the same pattern
|
||||||
|
used by `claude-code` in nixpkgs. The npm tarball (v2.3.0) is fetched at build time via `fetchzip`,
|
||||||
|
a `package-lock.json` is provided for reproducible dependency resolution, and `dontNpmBuild = true`
|
||||||
|
skips the build step because `dist/` is already included in the published tarball. The resulting
|
||||||
|
binary starts instantly with no network dependency at runtime.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## [Back to top](#issues)
|
## [Back to top](#issues)
|
||||||
@@ -24,7 +24,7 @@ Add this flake to your inputs and apply the overlay:
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
mcp-servers.url = "git+ssh://gitea@gitea.bueso.eu/luis/mcp-servert";
|
mcp-servers.url = "git+ssh://gitea@gitea.bueso.eu/luis/mcp-servers";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { nixpkgs, mcp-servers, ... }: {
|
outputs = { nixpkgs, mcp-servers, ... }: {
|
||||||
@@ -48,11 +48,11 @@ Access packages without the overlay:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
mcp-servers.url = "git+ssh://gitea@gitea.bueso.eu/luis/mcp-servert";
|
mcp-servers.url = "git+ssh://gitea@gitea.bueso.eu/luis/mcp-servers";
|
||||||
|
|
||||||
outputs = { mcp-servers, ... }: {
|
outputs = { mcp-servers, ... }: {
|
||||||
# Access directly
|
# Access directly
|
||||||
myPackage = mcp.packages.x86_64-linux.manim-mcp-server;
|
myPackage = mcp-servers.packages.x86_64-linux.manim-mcp-server;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
5233
packages/pdf-reader-mcp/package-lock.json
generated
Normal file
5233
packages/pdf-reader-mcp/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,38 +1,27 @@
|
|||||||
# NOTE: This package uses a wrapper approach because the upstream project
|
|
||||||
# uses bun.lock instead of package-lock.json, which buildNpmPackage requires.
|
|
||||||
# The wrapper invokes npx to run the package with its dependencies.
|
|
||||||
# For a fully offline/reproducible build, upstream would need to provide
|
|
||||||
# a package-lock.json file.
|
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
stdenvNoCC,
|
buildNpmPackage,
|
||||||
nodejs_22,
|
fetchzip,
|
||||||
makeWrapper,
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenvNoCC.mkDerivation rec {
|
buildNpmPackage rec {
|
||||||
pname = "pdf-reader-mcp";
|
pname = "pdf-reader-mcp";
|
||||||
version = "2.2.0";
|
version = "2.3.0";
|
||||||
|
|
||||||
# No source needed - we use npx to fetch and run the package
|
src = fetchzip {
|
||||||
dontUnpack = true;
|
url = "https://registry.npmjs.org/@sylphx/pdf-reader-mcp/-/pdf-reader-mcp-${version}.tgz";
|
||||||
|
hash = "sha256-nLtTYE5pSLigAQqsWx3TvntOign30vUJ4jaCDScm9oY=";
|
||||||
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
npmDepsHash = "sha256-Z+C1pGJb1gCUR4qlM9ZSjhevqWPdCOVhL631GFaehbc=";
|
||||||
|
|
||||||
installPhase = ''
|
postPatch = ''
|
||||||
runHook preInstall
|
cp ${./package-lock.json} package-lock.json
|
||||||
|
|
||||||
mkdir -p $out/bin
|
|
||||||
|
|
||||||
# Create wrapper that uses npx to run the package
|
|
||||||
# npx will cache the package after first run
|
|
||||||
makeWrapper ${nodejs_22}/bin/npx $out/bin/${pname} \
|
|
||||||
--add-flags "--yes" \
|
|
||||||
--add-flags "@sylphx/pdf-reader-mcp@${version}"
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# dist/ is already built in the npm tarball
|
||||||
|
dontNpmBuild = true;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Production-ready MCP server for PDF processing with parallel processing";
|
description = "Production-ready MCP server for PDF processing with parallel processing";
|
||||||
homepage = "https://github.com/SylphxAI/pdf-reader-mcp";
|
homepage = "https://github.com/SylphxAI/pdf-reader-mcp";
|
||||||
|
|||||||
Reference in New Issue
Block a user