Skip to content

Commit 5e03a3a

Browse files
Merge pull request #111 from akiojin/bugfix/mcp-tools
bugfix/mcp tools
2 parents d61a400 + eaba959 commit 5e03a3a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ sequenceDiagram
195195

196196
ネイティブ拡張(`better-sqlite3` など)は **MCPサーバーを動かすOS上で依存関係をインストールしたとき** にのみ正しく構築されます。以下を必ず実施してください。
197197

198-
> 初回 npx 実行の注意: 対応する prebuilt が無い環境では、最初の `npx @akiojin/unity-mcp-server@latest` で `better-sqlite3` のビルドに 60〜90 秒かかる場合があります。MCP クライアントの既定タイムアウト(30 秒)にかからないよう、事前に `npx -y @akiojin/unity-mcp-server@latest --help` でキャッシュを温めるか、`MCP_TIMEOUT=90000` などタイムアウトを延長して起動してください。2回目以降はキャッシュが効くため高速に起動します
198+
> 初回 npx 実行の注意: 対応する prebuilt が無い環境では、最初の `npx @akiojin/unity-mcp-server@latest` で `better-sqlite3` のビルドに 60〜90 秒かかる場合があります。MCP クライアントの既定タイムアウト(30 秒)にかからないよう、事前に `npx -y @akiojin/unity-mcp-server@latest --help` でキャッシュを温めるか、`MCP_TIMEOUT=90000` などタイムアウトを延長して起動してください。初回ビルド待ちを避けるため、初期設定ではネイティブ再ビルドをスキップしています。ネイティブを強制したい場合は `UNITY_MCP_SKIP_NATIVE_BUILD=0` または `UNITY_MCP_FORCE_NATIVE=1` を指定してインストールしてください
199199

200200
- **基本ルール**: `.mcp.json` で `"command": "node"`(例: `node bin/unity-mcp-server serve`)を使う場合は、MCPサーバーを動かすマシン/コンテナ内で本パッケージが展開されているディレクトリで `npm ci` を実行してから MCP クライアントを起動します。
201201
- **`npx` 実行**: README の例(`npx @akiojin/unity-mcp-server@latest`)は起動時に依存をダウンロードします。サポート対象の Node.js(18.x / 20.x / 22.x)では追加作業なしで利用できます。Node.js 23 以上はサポート外であり、サーバー起動時に拒否されます。

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Installation
209209

210210
You must install the MCP server's dependencies **on the same OS where the server runs** so that native modules such as `better-sqlite3` are built for the correct platform.
211211

212-
> First-time install note (npx): On environments without a matching prebuilt `better-sqlite3`, the very first `npx @akiojin/unity-mcp-server@latest` may spend 60–90s compiling the native addon. To avoid MCP client timeouts (default 30s), either warm the cache once with `npx -y @akiojin/unity-mcp-server@latest --help` or start your client with a higher timeout (e.g. `MCP_TIMEOUT=90000`). Subsequent runs use the warmed cache and start quickly.
212+
> First-time install note (npx): On environments without a matching prebuilt `better-sqlite3`, the very first `npx @akiojin/unity-mcp-server@latest` can spend 60–90s compiling the native addon. To avoid MCP client timeouts (default 30s), either warm the cache once with `npx -y @akiojin/unity-mcp-server@latest --help` or start your client with a higher timeout (e.g. `MCP_TIMEOUT=90000`). By default we now **skip native rebuild** to keep first-run fast; to force native build set `UNITY_MCP_SKIP_NATIVE_BUILD=0` or `UNITY_MCP_FORCE_NATIVE=1` before install.
213213

214214
- **General rule**: if your `.mcp.json` uses `"command": "node"` (e.g. `node bin/unity-mcp-server serve`), run `npm install` (or `npm ci`) inside the directory where the package lives _on that machine/container_ before launching the MCP client.
215215
- **`npx` launch**: the README example above (`npx @akiojin/unity-mcp-server@latest`) downloads dependencies at runtime and works on the supported Node.js versions (18.x / 20.x / 22.x). Node.js 23+ is not supported; the server exits early with a version error.

mcp-server/scripts/ensure-better-sqlite3.mjs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,30 @@ const bindingPath = resolve(
1111
'Release',
1212
'better_sqlite3.node'
1313
);
14+
// Default: skip native rebuild to avoid first-time npx timeouts; set UNITY_MCP_SKIP_NATIVE_BUILD=0 to allow.
15+
const skipNative = process.env.UNITY_MCP_SKIP_NATIVE_BUILD !== '0';
16+
const forceNative = process.env.UNITY_MCP_FORCE_NATIVE === '1';
1417

1518
function main() {
1619
if (process.env.SKIP_SQLITE_REBUILD) {
1720
console.log('[postinstall] SKIP_SQLITE_REBUILD set, skipping better-sqlite3 check');
1821
return;
1922
}
2023

21-
if (existsSync(bindingPath)) {
24+
if (skipNative && !forceNative) {
25+
console.log(
26+
'[postinstall] UNITY_MCP_SKIP_NATIVE_BUILD=1 -> skipping better-sqlite3 rebuild (will rely on fallback/sql.js if missing)'
27+
);
28+
return;
29+
}
30+
31+
if (forceNative) {
32+
console.log(
33+
'[postinstall] UNITY_MCP_FORCE_NATIVE=1 -> forcing better-sqlite3 rebuild even if binding exists'
34+
);
35+
}
36+
37+
if (!forceNative && existsSync(bindingPath)) {
2238
return;
2339
}
2440

0 commit comments

Comments
 (0)