@akiojin/unity-mcp-server 2.44.1 → 2.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -315,18 +315,22 @@ Unity MCP Server uses the following components for code indexing and analysis:
315
315
 
316
316
  | Component | Purpose | Distribution | Notes |
317
317
  |-----------|---------|--------------|-------|
318
- | **sql.js** | Code index database | npm dependency | Pure JS/WASM, no native compilation |
318
+ | **fast-sql** | Code index database | npm dependency | Hybrid backend: better-sqlite3 (native) or sql.js (WASM) |
319
319
  | **csharp-lsp** | C# symbol analysis | Downloaded on first use | ~80 MB per platform |
320
320
 
321
- #### Why sql.js?
321
+ #### Why fast-sql?
322
322
 
323
- We use **sql.js** (pure JavaScript/WebAssembly SQLite) for the code index database:
323
+ We use **fast-sql** (hybrid SQLite library) for the code index database:
324
324
 
325
- - **Zero native compilation**: Works immediately via `npx` without build tools
326
- - **Cross-platform**: Same code runs on all Node.js platforms
327
- - **No installation delays**: Avoids 30+ second native module compilation timeouts
325
+ - **Optimal performance**: Uses better-sqlite3 (native) when available for ~34x faster queries
326
+ - **npx compatible**: Falls back to sql.js (WASM) when native bindings unavailable
327
+ - **Zero native compilation required**: Works immediately via `npx` without build tools
328
+ - **Cross-platform**: Automatic backend selection based on environment
328
329
 
329
- **Trade-off**: sql.js is 1.5-5x slower than native SQLite (better-sqlite3), but this is acceptable for code index operations which are infrequent.
330
+ **Performance comparison** (better-sqlite3 vs sql.js):
331
+ - 50K inserts: 29ms vs 53ms (1.8x faster)
332
+ - 1000 queries: 0.34μs vs 11.78μs (34x faster)
333
+ - LIKE search: 2.5ms vs 7ms (2.8x faster)
330
334
 
331
335
  #### csharp-lsp Distribution
332
336
 
@@ -338,14 +342,14 @@ We use **sql.js** (pure JavaScript/WebAssembly SQLite) for the code index databa
338
342
 
339
343
  #### Supported Platforms
340
344
 
341
- | Platform | sql.js | csharp-lsp |
342
- |----------|--------|------------|
343
- | Linux x64 | ✅ Built-in | ✅ Downloaded (~79 MB) |
344
- | Linux arm64 | ✅ Built-in | ✅ Downloaded (~86 MB) |
345
- | macOS x64 | ✅ Built-in | ✅ Downloaded (~80 MB) |
346
- | macOS arm64 (Apple Silicon) | ✅ Built-in | ✅ Downloaded (~86 MB) |
347
- | Windows x64 | ✅ Built-in | ✅ Downloaded (~80 MB) |
348
- | Windows arm64 | ✅ Built-in | ✅ Downloaded (~85 MB) |
345
+ | Platform | fast-sql | csharp-lsp |
346
+ |----------|----------|------------|
347
+ | Linux x64 | ✅ Native (better-sqlite3) | ✅ Downloaded (~79 MB) |
348
+ | Linux arm64 | ✅ Native (better-sqlite3) | ✅ Downloaded (~86 MB) |
349
+ | macOS x64 | ✅ Native (better-sqlite3) | ✅ Downloaded (~80 MB) |
350
+ | macOS arm64 (Apple Silicon) | ✅ Native (better-sqlite3) | ✅ Downloaded (~86 MB) |
351
+ | Windows x64 | ✅ Native (better-sqlite3) | ✅ Downloaded (~80 MB) |
352
+ | Windows arm64 | ✅ WASM fallback (sql.js) | ✅ Downloaded (~85 MB) |
349
353
 
350
354
  #### Storage Locations
351
355
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akiojin/unity-mcp-server",
3
- "version": "2.44.1",
3
+ "version": "2.45.1",
4
4
  "description": "MCP server and Unity Editor bridge — enables AI assistants to control Unity for AI-assisted workflows",
5
5
  "type": "module",
6
6
  "main": "src/core/server.js",
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "@modelcontextprotocol/sdk": "^1.24.3",
52
52
  "find-up": "^6.3.0",
53
- "sql.js": "^1.13.0"
53
+ "@akiojin/fast-sql": "^0.1.0"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=18 <23"
@@ -3,10 +3,9 @@ import path from 'path';
3
3
  import { ProjectInfoProvider } from './projectInfo.js';
4
4
  import { logger } from './config.js';
5
5
 
6
- // sql.js helper: execute query and return results (wrapper to avoid hook false positive)
6
+ // fast-sql helper: execute query and return results
7
7
  function querySQL(db, sql) {
8
- const fn = db['ex' + 'ec'].bind(db);
9
- return fn(sql);
8
+ return db.execSql(sql);
10
9
  }
11
10
 
12
11
  // Shared driver availability state across CodeIndex instances
@@ -43,9 +42,9 @@ export class CodeIndex {
43
42
  }
44
43
  if (this._SQL) return true;
45
44
  try {
46
- // Dynamic import sql.js (pure JavaScript/WASM, no native bindings)
47
- const initSqlJs = (await import('sql.js')).default;
48
- this._SQL = await initSqlJs();
45
+ // Dynamic import fast-sql (hybrid backend: better-sqlite3 or sql.js fallback)
46
+ const initFastSql = (await import('@akiojin/fast-sql')).default;
47
+ this._SQL = await initFastSql();
49
48
  sharedConnections.SQL = this._SQL;
50
49
  driverStatus.available = true;
51
50
  driverStatus.error = null;
@@ -53,7 +52,7 @@ export class CodeIndex {
53
52
  } catch (e) {
54
53
  this.disabled = true;
55
54
  const errMsg = e && typeof e === 'object' && 'message' in e ? e.message : String(e);
56
- this.disableReason = `sql.js unavailable: ${errMsg}. Code index features are disabled.`;
55
+ this.disableReason = `fast-sql unavailable: ${errMsg}. Code index features are disabled.`;
57
56
  driverStatus.available = false;
58
57
  driverStatus.error = this.disableReason;
59
58
  this._logDisable(this.disableReason);
@@ -102,12 +101,12 @@ export class CodeIndex {
102
101
 
103
102
  /**
104
103
  * Save in-memory database to file
105
- * sql.js requires explicit save (unlike better-sqlite3 which auto-persists)
104
+ * fast-sql requires explicit save when using sql.js backend
106
105
  */
107
106
  _saveToFile() {
108
107
  if (!this.db || !this.dbPath) return;
109
108
  try {
110
- const data = this.db.export();
109
+ const data = this.db.exportDb();
111
110
  const buffer = Buffer.from(data);
112
111
  fs.writeFileSync(this.dbPath, buffer);
113
112
  } catch (e) {
@@ -130,7 +129,7 @@ export class CodeIndex {
130
129
 
131
130
  _initSchema() {
132
131
  if (!this.db) return;
133
- // sql.js doesn't support WAL mode (in-memory), skip PRAGMA journal_mode
132
+ // fast-sql applies optimal PRAGMAs automatically
134
133
  this.db.run(`
135
134
  CREATE TABLE IF NOT EXISTS meta (
136
135
  key TEXT PRIMARY KEY,
@@ -171,7 +170,7 @@ export class CodeIndex {
171
170
 
172
171
  async clearAndLoad(symbols) {
173
172
  const db = await this.open();
174
- if (!db) throw new Error('CodeIndex is unavailable (sql.js not loaded)');
173
+ if (!db) throw new Error('CodeIndex is unavailable (fast-sql not loaded)');
175
174
 
176
175
  db.run('BEGIN TRANSACTION');
177
176
  try {
@@ -12,7 +12,7 @@ const __dirname = path.dirname(__filename);
12
12
  *
13
13
  * This class manages Worker Threads that execute index builds in a separate
14
14
  * thread, preventing the main Node.js event loop from being blocked by
15
- * sql.js database operations.
15
+ * fast-sql database operations (hybrid backend with better-sqlite3 or sql.js fallback).
16
16
  *
17
17
  * Requirements:
18
18
  * - FR-056: Execute index build in Worker Thread
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * This script runs in a separate thread and performs the heavy lifting of
5
5
  * index builds: file scanning, LSP document symbol requests, and SQLite
6
- * database operations (using sql.js - pure JS/WASM, no native bindings).
6
+ * database operations (using fast-sql - hybrid backend with better-sqlite3 or sql.js fallback).
7
7
  * By running in a Worker Thread, these operations don't block the main event loop.
8
8
  *
9
9
  * Communication with main thread:
@@ -16,22 +16,20 @@ import fs from 'fs';
16
16
  import path from 'path';
17
17
  import { fileURLToPath } from 'url';
18
18
 
19
- // sql.js helper: run SQL statement (wrapper to avoid hook false positive on "exec")
19
+ // fast-sql helper: run SQL statement
20
20
  function runSQL(db, sql) {
21
21
  return db.run(sql);
22
22
  }
23
23
 
24
- // sql.js helper: execute query and return results
24
+ // fast-sql helper: execute query and return results
25
25
  function querySQL(db, sql) {
26
- // sql.js exec returns array of result sets
27
- const fn = db['ex' + 'ec'].bind(db);
28
- return fn(sql);
26
+ return db.execSql(sql);
29
27
  }
30
28
 
31
- // Save sql.js database to file
29
+ // Save fast-sql database to file
32
30
  function saveDatabase(db, dbPath) {
33
31
  try {
34
- const data = db.export();
32
+ const data = db.exportDb();
35
33
  const buffer = Buffer.from(data);
36
34
  fs.writeFileSync(dbPath, buffer);
37
35
  } catch (e) {
@@ -186,13 +184,13 @@ async function runBuild() {
186
184
  let db = null;
187
185
 
188
186
  try {
189
- // Dynamic import sql.js in worker thread (pure JS/WASM, no native bindings)
187
+ // Dynamic import fast-sql in worker thread (hybrid: better-sqlite3 or sql.js fallback)
190
188
  let SQL;
191
189
  try {
192
- const initSqlJs = (await import('sql.js')).default;
193
- SQL = await initSqlJs();
190
+ const initFastSql = (await import('@akiojin/fast-sql')).default;
191
+ SQL = await initFastSql();
194
192
  } catch (e) {
195
- throw new Error(`sql.js unavailable in worker: ${e.message}`);
193
+ throw new Error(`fast-sql unavailable in worker: ${e.message}`);
196
194
  }
197
195
 
198
196
  // Open or create database
@@ -203,7 +201,7 @@ async function runBuild() {
203
201
  db = new SQL.Database();
204
202
  }
205
203
 
206
- // Initialize schema if needed (sql.js doesn't support WAL mode)
204
+ // Initialize schema if needed (fast-sql applies optimal PRAGMAs automatically)
207
205
  runSQL(
208
206
  db,
209
207
  `
@@ -39,13 +39,13 @@ export class CodeIndexStatusToolHandler extends BaseToolHandler {
39
39
  coverage: 0,
40
40
  message:
41
41
  this.codeIndex.disableReason ||
42
- 'Code index is disabled because sql.js could not be loaded. The server will continue without the symbol index.',
42
+ 'Code index is disabled because fast-sql could not be loaded. The server will continue without the symbol index.',
43
43
  remediation:
44
- 'Ensure sql.js is installed by running "npm install sql.js". After installing, restart unity-mcp-server.',
44
+ 'Ensure fast-sql is properly installed. After reinstalling dependencies, restart unity-mcp-server.',
45
45
  index: {
46
46
  ready: false,
47
47
  disabled: true,
48
- reason: this.codeIndex.disableReason || 'sql.js unavailable; code index is disabled'
48
+ reason: this.codeIndex.disableReason || 'fast-sql unavailable; code index is disabled'
49
49
  }
50
50
  };
51
51
  }
@@ -94,7 +94,7 @@ export class ScriptRefsFindToolHandler extends BaseToolHandler {
94
94
  this.index.disableReason ||
95
95
  'Code index is disabled because the SQLite driver could not be loaded.',
96
96
  remediation:
97
- 'Ensure sql.js is installed by running "npm install sql.js". After installing, restart unity-mcp-server.'
97
+ 'Ensure fast-sql is properly installed. After reinstalling dependencies, restart unity-mcp-server.'
98
98
  };
99
99
  }
100
100
 
@@ -61,7 +61,7 @@ export class ScriptSymbolFindToolHandler extends BaseToolHandler {
61
61
  this.index.disableReason ||
62
62
  'Code index is disabled because the SQLite driver could not be loaded.',
63
63
  remediation:
64
- 'Ensure sql.js is installed by running "npm install sql.js". After installing, restart unity-mcp-server.'
64
+ 'Ensure fast-sql is properly installed. After reinstalling dependencies, restart unity-mcp-server.'
65
65
  };
66
66
  }
67
67