0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

npxでGitHubで公開している自分のツールをインストールできるようにするまでのエラー解決方法まとめ

Last updated at Posted at 2025-04-22

package.jsonの設定にbinがいる

{
  "name": "ipinfo",
  "version": "1.0.0",
  "main": "index.js",
  "license": "UNLICENSED",
  "bin": { "ipinfo": "servers/ipinfo/dist/index.js" },
  "dependencies": {
    "@modelcontextprotocol/sdk": "^1.10.1",
    "node-fetch": "2",
    "zod": "^3.24.2",
    "zod-to-json-schema": "^3.24.5"
  }
}

package.jsonがリポジトリトップにないといけない

現象、npxを実行してもなにも返ってこない

# サブディレクトリにpackage.jsonを置いてうまく動かない例
npx -y github:RyosukeDTomita/mcp_tool_poisoning_attacks/servers/ipinfo

解決策 リポジトリトップにpackage.jsonを作った

RyosukeDTomita/mcp_tool_poisoning_attacks/servers/ipinfo/package.jsonとは別に、RyosukeDTomita/mcp_tool_poisoning_attacks/package.json
を作った。

参考: Run your NPX script directly from Github. Create your own CLI commands and other stories

npm error path git

現象: gitがないエラーがでる

npx -y github:RyosukeDTomita/mcp_tool_poisoning_attacks#main ipinfo
npm error code ENOENT
npm error syscall spawn git
npm error path git
npm error errno -2
npm error enoent An unknown git error occurred
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-04-22T02_59_32_181Z-debug-0.log
Failed to connect to MCP server: McpError: MCP error -32000: Connection closed
    at Client._onclose (/app/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/protocol.js:97:23)
    at _transport.onclose (/app/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/protocol.js:72:18)
    at ChildProcess.<anonymous> (/app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js:92:77)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1101:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5) {
  code: -32000,
  data: undefined
}
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

解決策: gitを入れる

apt-get update -y
apt-get install -y --no-install-recommends git

npm verbose code 128

現象

npx -y --loglevel verbose github:RyosukeDTomita/mcp_tool_poisoning_attacks#main ipinfo
npm exec github:RyosukeDTomita/mcp_tool_poisoning_attacks#main ipinfo
npm verbose argv "exec" "--yes" "--loglevel" "verbose" "--" "github:RyosukeDTomita/mcp_tool_poisoning_attacks#main" "ipinfo"
npm verbose logfile logs-max:10 dir:/root/.npm/_logs/2025-04-22T03_45_00_809Z-
npm verbose logfile /root/.npm/_logs/2025-04-22T03_45_00_809Z-debug-0.log
npm verbose cwd /app
npm verbose os Linux 6.8.0-57-generic
npm verbose node v22.14.0
npm verbose npm  v10.9.2
npm verbose exit 128
npm verbose code 128

解決策: ca-certificatesをいれる

npm install git+url exited with error code: 128のようなissueが見つかった。

試しにgit cloneしてみたら証明書エラーになったことからnpx実行時に同様のエラーがでていると考えられる。

git clone --branch main https://github.com/RyosukeDTomita/mcp_tool_poisoning_attacks.git
Cloning into 'mcp_tool_poisoning_attacks'...
fatal: unable to access 'https://github.com/RyosukeDTomita/mcp_tool_poisoning_attacks.git/': server certificate verification failed. CAfile: none CRLfile: none

なのでca-certificatesを入れる

apt-get update -y
apt-get install -y --no-install-recommends git ca-certificates

参考

自分のリポジトリ

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?