This commit is contained in:
MCP Packages
2026-02-05 10:58:27 +01:00
parent 0d36462241
commit 1bdbbd9d32
4 changed files with 5266 additions and 30 deletions

View File

@@ -2,8 +2,9 @@
## PDF Reader MCP Connection Issue
**Status:** Open
**Status:** Resolved
**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.
@@ -12,6 +13,19 @@
- MCP server has been enabled in configuration
- 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)

View File

@@ -24,7 +24,7 @@ Add this flake to your inputs and apply the overlay:
{
inputs = {
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, ... }: {
@@ -48,11 +48,11 @@ Access packages without the overlay:
```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, ... }: {
# 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

File diff suppressed because it is too large Load Diff

View File

@@ -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,
stdenvNoCC,
nodejs_22,
makeWrapper,
buildNpmPackage,
fetchzip,
}:
stdenvNoCC.mkDerivation rec {
buildNpmPackage rec {
pname = "pdf-reader-mcp";
version = "2.2.0";
version = "2.3.0";
# No source needed - we use npx to fetch and run the package
dontUnpack = true;
src = fetchzip {
url = "https://registry.npmjs.org/@sylphx/pdf-reader-mcp/-/pdf-reader-mcp-${version}.tgz";
hash = "sha256-nLtTYE5pSLigAQqsWx3TvntOign30vUJ4jaCDScm9oY=";
};
nativeBuildInputs = [ makeWrapper ];
npmDepsHash = "sha256-Z+C1pGJb1gCUR4qlM9ZSjhevqWPdCOVhL631GFaehbc=";
installPhase = ''
runHook preInstall
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
postPatch = ''
cp ${./package-lock.json} package-lock.json
'';
# dist/ is already built in the npm tarball
dontNpmBuild = true;
meta = with lib; {
description = "Production-ready MCP server for PDF processing with parallel processing";
homepage = "https://github.com/SylphxAI/pdf-reader-mcp";