poker-mcp 1.2.6 → 1.2.8
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 +99 -52
- package/package.json +1 -1
- package/src/mcp/handlers/calculationHandlers.js +27 -30
- package/src/mcp/handlers/guiHandlers.js +124 -0
- package/src/mcp/handlers/index.js +4 -0
- package/src/mcp/tools/calculationTools.js +2 -2
- package/src/mcp/tools/guiTools.js +25 -0
- package/src/mcp/tools/index.js +5 -2
package/README.md
CHANGED
|
@@ -4,12 +4,43 @@ YAML-based input file management tool for radiation-shielding calculation code P
|
|
|
4
4
|
|
|
5
5
|
## 📋 クイック情報
|
|
6
6
|
|
|
7
|
-
- **バージョン**: 1.2.
|
|
7
|
+
- **バージョン**: 1.2.8
|
|
8
8
|
- **プロトコル**: MCP (Model Context Protocol) 1.0.0 完全準拠
|
|
9
9
|
- **メインサーバー**: `src/mcp_server_stdio_v4.js`
|
|
10
|
-
- **データ保存**:
|
|
10
|
+
- **データ保存**: `~/.poker-mcp/`(`POKER_MCP_HOME`環境変数で変更可)
|
|
11
11
|
- **実行方式**: STDIO通信(MCPプロトコル標準)
|
|
12
12
|
|
|
13
|
+
## 🆕 バージョン1.2.8の新機能
|
|
14
|
+
|
|
15
|
+
### ✨ `poker_openGui` — POKER GUI 起動メソッドを追加
|
|
16
|
+
作成した入力ファイルを POKER.exe でビジュアル確認できます。
|
|
17
|
+
|
|
18
|
+
- 保留中の変更を **自動保存してから** POKER.exe を起動
|
|
19
|
+
- `yaml_file` は省略可(デフォルト: `poker.yaml`)
|
|
20
|
+
- `POKER_INSTALL_PATH/POKER.exe`(デフォルト: `C:/Poker/POKER.exe`)を使用
|
|
21
|
+
- Windows 専用
|
|
22
|
+
|
|
23
|
+
## 🆕 バージョン1.2.7の修正(バグフィックス)
|
|
24
|
+
|
|
25
|
+
### 🐛 `poker_executeCalculation` の yaml_file パス解決を修正
|
|
26
|
+
ファイル名のみ(例: `poker.yaml`)を渡すと絶対パス要求でエラーになっていた
|
|
27
|
+
スキーマ・ハンドラー間の矛盾を修正しました。
|
|
28
|
+
|
|
29
|
+
- **ファイル名のみ指定** → `POKER_MCP_HOME/tasks/` に自動解決
|
|
30
|
+
- **絶対パス指定** → そのまま使用(後方互換)
|
|
31
|
+
|
|
32
|
+
## 🆕 バージョン1.2.6の修正(バグフィックス)
|
|
33
|
+
|
|
34
|
+
### 🐛 SERVER DISCONNECTED 問題を修正
|
|
35
|
+
`npx poker-mcp` 実行時にClaude Desktopがカレントディレクトリを
|
|
36
|
+
`C:\Windows\System32` に設定するため、相対パスでのフォルダ作成が
|
|
37
|
+
権限エラー(EPERM)で失敗していた問題を修正しました。
|
|
38
|
+
|
|
39
|
+
- **`src/utils/paths.js` 新設**: 作業ディレクトリを一元管理
|
|
40
|
+
- **全ファイルパスを絶対パス化**: `logs/`・`backups/`・`tasks/`・`data/`
|
|
41
|
+
- **`POKER_MCP_HOME` 環境変数サポート**: 作業場所を自由に指定可能
|
|
42
|
+
- **エラー出力を `stderr` に追加**: 問題発生時の原因特定が容易に
|
|
43
|
+
|
|
13
44
|
## 🆕 バージョン1.2.5の新機能
|
|
14
45
|
|
|
15
46
|
### ⚡ 衝突検出システム
|
|
@@ -41,31 +72,45 @@ YAML-based input file management tool for radiation-shielding calculation code P
|
|
|
41
72
|
|
|
42
73
|
### 1. インストール
|
|
43
74
|
```bash
|
|
44
|
-
#
|
|
75
|
+
# 依存関係インストール(ローカル開発時のみ)
|
|
45
76
|
npm install
|
|
46
77
|
|
|
47
|
-
# または NPX
|
|
78
|
+
# または NPX で直接使用(インストール不要)
|
|
48
79
|
npx poker-mcp
|
|
49
80
|
```
|
|
50
81
|
|
|
51
|
-
### 2.
|
|
82
|
+
### 2. 環境変数設定
|
|
83
|
+
|
|
84
|
+
#### `POKER_MCP_HOME`(推奨・新設)
|
|
85
|
+
作業ファイル(YAML・バックアップ・ログ・核種DB)の格納先を指定します。
|
|
86
|
+
**未設定時は `~/.poker-mcp/` が自動的に使用されます。**
|
|
87
|
+
|
|
88
|
+
#### `POKER_INSTALL_PATH`(オプション)
|
|
89
|
+
ICRP-07.NDX 核種データベースのコピー元を指定します。
|
|
52
90
|
|
|
53
|
-
**POKER_INSTALL_PATH環境変数**(オプション):
|
|
54
91
|
```bash
|
|
55
|
-
# Windows
|
|
92
|
+
# Windows(コマンドプロンプト)
|
|
93
|
+
set POKER_MCP_HOME=C:\Users\yoshi\poker_mcp_workspace
|
|
56
94
|
set POKER_INSTALL_PATH=C:/Poker
|
|
57
95
|
|
|
58
|
-
# Windows
|
|
96
|
+
# Windows(PowerShell)
|
|
97
|
+
$env:POKER_MCP_HOME="C:\Users\yoshi\poker_mcp_workspace"
|
|
59
98
|
$env:POKER_INSTALL_PATH="C:/Poker"
|
|
60
99
|
|
|
61
|
-
# Linux/macOS
|
|
100
|
+
# Linux/macOS
|
|
101
|
+
export POKER_MCP_HOME="$HOME/.poker-mcp"
|
|
62
102
|
export POKER_INSTALL_PATH="/usr/local/share/poker"
|
|
63
103
|
```
|
|
64
104
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
105
|
+
**データ格納先の構造:**
|
|
106
|
+
```
|
|
107
|
+
POKER_MCP_HOME/ # デフォルト: ~/.poker-mcp/
|
|
108
|
+
├── tasks/ # poker.yaml, pending_changes.json
|
|
109
|
+
├── backups/ # 自動バックアップ(最大10世代)
|
|
110
|
+
├── data/ # ICRP-07.NDX 核種データベース
|
|
111
|
+
├── logs/ # error.log, combined.log
|
|
112
|
+
└── config.json # ユーザー設定(任意)
|
|
113
|
+
```
|
|
69
114
|
|
|
70
115
|
### 3. Claude Desktop設定
|
|
71
116
|
|
|
@@ -78,22 +123,7 @@ export POKER_INSTALL_PATH="/usr/local/share/poker"
|
|
|
78
123
|
Linux: ~/.config/claude/claude_desktop_config.json
|
|
79
124
|
```
|
|
80
125
|
|
|
81
|
-
2.
|
|
82
|
-
```json
|
|
83
|
-
{
|
|
84
|
-
"mcpServers": {
|
|
85
|
-
"poker-mcp": {
|
|
86
|
-
"command": "node",
|
|
87
|
-
"args": ["C:\\Users\\yoshi\\Desktop\\poker_mcp\\src\\mcp_server_stdio_v4.js"],
|
|
88
|
-
"env": {
|
|
89
|
-
"POKER_INSTALL_PATH": "C:/Poker"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
3. **NPXを使用する場合**
|
|
126
|
+
2. **推奨設定(v1.2.6)**
|
|
97
127
|
```json
|
|
98
128
|
{
|
|
99
129
|
"mcpServers": {
|
|
@@ -101,18 +131,20 @@ export POKER_INSTALL_PATH="/usr/local/share/poker"
|
|
|
101
131
|
"command": "npx",
|
|
102
132
|
"args": ["poker-mcp"],
|
|
103
133
|
"env": {
|
|
134
|
+
"POKER_MCP_HOME": "C:\\Users\\<username>\\poker_mcp_workspace",
|
|
104
135
|
"POKER_INSTALL_PATH": "C:/Poker"
|
|
105
136
|
}
|
|
106
137
|
}
|
|
107
138
|
}
|
|
108
139
|
}
|
|
109
140
|
```
|
|
141
|
+
`<username>` はご自身のWindowsユーザー名に置き換えてください。
|
|
142
|
+
`POKER_INSTALL_PATH` は省略可能です(デフォルト: `C:/Poker`)。
|
|
110
143
|
|
|
111
|
-
|
|
144
|
+
> **⚠️ 注意:** `cwd`(作業ディレクトリ)の指定は不要です。`POKER_MCP_HOME`
|
|
145
|
+
> 環境変数で管理するため、`cwd` を設定すると v1.2.5 以前の問題が再発します。
|
|
112
146
|
|
|
113
|
-
|
|
114
|
-
- `env`セクションの`POKER_INSTALL_PATH`はオプションです(省略時は`C:/Poker`を使用)
|
|
115
|
-
- 環境変数で指定したパスの`lib/ICRP-07.NDX`ファイルが初回起動時に`data/`にコピーされます
|
|
147
|
+
3. **Claude Desktopを再起動** してMCPサーバーを有効化
|
|
116
148
|
|
|
117
149
|
### 4. 動作確認
|
|
118
150
|
Claude Desktopで以下のようにテストできます:
|
|
@@ -188,28 +220,28 @@ poker_mcp/
|
|
|
188
220
|
│ ├── 📁 services/ # ビジネスロジック
|
|
189
221
|
│ ├── 📁 validators/ # データ検証(物理・単位・衝突)
|
|
190
222
|
│ ├── 📁 utils/ # ユーティリティ
|
|
223
|
+
│ │ ├── paths.js # ★ パス管理(POKER_MCP_HOME起点)
|
|
224
|
+
│ │ ├── logger.js # ログ出力(絶対パス)
|
|
225
|
+
│ │ └── ...
|
|
191
226
|
│ └── 📁 config/ # 設定管理
|
|
192
|
-
├── 📁 data/ # 📊 核種データベース
|
|
193
|
-
│ └── ICRP-07.NDX # ICRP-107核種データ(1,254核種)
|
|
194
|
-
├── 📁 config/ # ⚙️ 設定ファイル
|
|
195
|
-
│ ├── mcp-manifest.json # MCPマニフェスト (2,276行)
|
|
196
|
-
│ └── mcp-example.json # 設定例
|
|
197
227
|
├── 📁 docs/ # 📚 完全ドキュメント
|
|
198
|
-
│ ├── README.md # 詳細ドキュメント
|
|
199
|
-
│ ├── 📁 manuals/ # マニュアル集
|
|
200
|
-
│ └── 📁 interactive_guides/ # インタラクティブ学習ガイド
|
|
201
|
-
├── 📁 node_modules/ # 📦 依存パッケージ
|
|
202
228
|
├── .mcp.json # MCPクライアント接続設定
|
|
203
|
-
├── package.json #
|
|
204
|
-
├── package-lock.json # 依存関係ロック
|
|
229
|
+
├── package.json # パッケージ定義(v1.2.6)
|
|
205
230
|
└── README.md # このファイル
|
|
206
231
|
|
|
207
|
-
#
|
|
208
|
-
|
|
232
|
+
# 実行時に自動作成されるディレクトリ(POKER_MCP_HOME配下)
|
|
233
|
+
# デフォルト: C:\Users\<username>\.poker-mcp\ または ~/.poker-mcp/
|
|
234
|
+
POKER_MCP_HOME/
|
|
235
|
+
├── 📁 tasks/ # 📊 作業ディレクトリ
|
|
209
236
|
│ ├── poker.yaml # メインYAMLファイル
|
|
210
237
|
│ └── pending_changes.json # 保留中の変更
|
|
211
|
-
├── 📁 backups/ # 💾
|
|
212
|
-
|
|
238
|
+
├── 📁 backups/ # 💾 自動バックアップ(最大10世代)
|
|
239
|
+
├── 📁 data/ # 🧪 核種データベース
|
|
240
|
+
│ └── ICRP-07.NDX # ICRP-07核種データ(1,254核種)
|
|
241
|
+
├── 📁 logs/ # 📝 ログファイル
|
|
242
|
+
│ ├── error.log
|
|
243
|
+
│ └── combined.log
|
|
244
|
+
└── config.json # ユーザー設定(任意)
|
|
213
245
|
```
|
|
214
246
|
|
|
215
247
|
## 🔧 Claude経由での使用例
|
|
@@ -323,6 +355,23 @@ poker_mcp/
|
|
|
323
355
|
|
|
324
356
|
## 📝 更新履歴
|
|
325
357
|
|
|
358
|
+
### v1.2.8 (2026-05-16)
|
|
359
|
+
- ✨ `poker_openGui` メソッドを新設(POKER.exe でGUI確認)
|
|
360
|
+
- ✨ 起動前に `applyChanges` を自動実行
|
|
361
|
+
- ✨ `yaml_file` 省略可(デフォルト: `poker.yaml`)、`POKER_INSTALL_PATH` 環境変数使用
|
|
362
|
+
|
|
363
|
+
### v1.2.7 (2026-05-16)
|
|
364
|
+
- 🐛 `poker_executeCalculation` の `yaml_file` パス解決バグを修正(スキーマ・ハンドラー間の矛盾)
|
|
365
|
+
- ✨ ファイル名のみの指定で `POKER_MCP_HOME/tasks/` 配下を自動参照
|
|
366
|
+
- 📝 `API_COMPLETE.md`・`INTEGRATION_GUIDE.md`・`RESEARCH_WORKFLOWS.md` 更新
|
|
367
|
+
|
|
368
|
+
### v1.2.6 (2026-05-16)
|
|
369
|
+
- 🐛 `npx` 実行時のSERVER DISCONNECTED問題を修正(EPERM: C:\Windows\System32\logs)
|
|
370
|
+
- ✨ `src/utils/paths.js` 新設(`POKER_MCP_HOME`環境変数によるパス一元管理)
|
|
371
|
+
- ✨ `POKER_MCP_HOME`環境変数サポート(未設定時は`~/.poker-mcp/`をデフォルト使用)
|
|
372
|
+
- 🐛 全ファイルパスを絶対パスに変更(logger, DataManager, ConfigManager, server)
|
|
373
|
+
- ✨ 致命的エラーを`stderr`にも出力(Claude Desktopログから原因確認可能に)
|
|
374
|
+
|
|
326
375
|
### v1.2.5 (2025-01-24)
|
|
327
376
|
- ✨ 衝突検出システム実装
|
|
328
377
|
- ✨ 子孫核種自動補完機能追加(ICRP-07統合)
|
|
@@ -330,9 +379,7 @@ poker_mcp/
|
|
|
330
379
|
- ✨ YAMLリセット機能実装(3段階レベル)
|
|
331
380
|
- ✨ 検出器分析機能追加
|
|
332
381
|
- 🐛 NuclideManagerデフォルトパス統一
|
|
333
|
-
- 📝 .mcp.json完全化
|
|
334
382
|
- 📝 材料数13→14(VOID追加明記)
|
|
335
|
-
- 🗑️ archiveディレクトリ削除(未使用ファイル整理)
|
|
336
383
|
|
|
337
384
|
### v1.1.0 (Previous)
|
|
338
385
|
- 基本24メソッド実装
|
|
@@ -348,11 +395,11 @@ poker_mcp/
|
|
|
348
395
|
- **📖 詳細README**: [docs/README.md](docs/README.md)
|
|
349
396
|
- **📚 完全マニュアル**: [docs/manuals/](docs/manuals/)
|
|
350
397
|
- **🎓 インタラクティブガイド**: [docs/interactive_guides/](docs/interactive_guides/)
|
|
351
|
-
- **📋
|
|
398
|
+
- **📋 変更履歴**: [CHANGELOG.md](CHANGELOG.md)
|
|
352
399
|
- **🐛 Issues**: [GitHub Issues](https://github.com/Hirao-Y/poker_mcp/issues)
|
|
353
400
|
|
|
354
401
|
---
|
|
355
402
|
|
|
356
|
-
**🎯 Poker MCP Server v1.2.
|
|
403
|
+
**🎯 Poker MCP Server v1.2.8**
|
|
357
404
|
**プロトコル**: MCP 1.0.0 完全準拠
|
|
358
405
|
**作者**: Yoshihiro Hirao | **ライセンス**: ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poker-mcp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "YAML-based input file management tool for radiation shielding calculation code POKER with MCP support - Enhanced with collision detection, daughter nuclide auto-completion, and environment variable support",
|
|
5
5
|
"main": "src/mcp_server_stdio_v4.js",
|
|
6
6
|
"type": "module",
|
|
@@ -3,6 +3,7 @@ import { CalculationService } from '../../services/CalculationService.js';
|
|
|
3
3
|
import { ValidationError, CalculationError } from '../../utils/errors.js';
|
|
4
4
|
import { logger } from '../../utils/logger.js';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import { TASKS_DIR } from '../../utils/paths.js';
|
|
6
7
|
|
|
7
8
|
export function createCalculationHandlers(taskManager) {
|
|
8
9
|
const calculationService = new CalculationService();
|
|
@@ -15,18 +16,22 @@ export function createCalculationHandlers(taskManager) {
|
|
|
15
16
|
throw new ValidationError('YAML file is required', 'yaml_file', args.yaml_file);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
//
|
|
19
|
+
// パス解決:
|
|
20
|
+
// 絶対パスが渡された場合 → そのまま使用(後方互換)
|
|
21
|
+
// ファイル名のみの場合 → TASKS_DIR と結合して絶対パスに解決
|
|
19
22
|
const absolutePathPattern = /^([a-zA-Z]:[\\\/]|\/)/;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const resolvedYamlFile = absolutePathPattern.test(args.yaml_file)
|
|
24
|
+
? args.yaml_file
|
|
25
|
+
: path.join(TASKS_DIR, args.yaml_file);
|
|
26
|
+
|
|
27
|
+
logger.info('yaml_file path resolved', {
|
|
28
|
+
input: args.yaml_file,
|
|
29
|
+
resolved: resolvedYamlFile,
|
|
30
|
+
tasksDir: TASKS_DIR
|
|
31
|
+
});
|
|
27
32
|
|
|
28
33
|
// YAML拡張子チェック
|
|
29
|
-
if (!
|
|
34
|
+
if (!resolvedYamlFile.match(/\.(yaml|yml)$/i)) {
|
|
30
35
|
throw new ValidationError(
|
|
31
36
|
'YAML file must have .yaml or .yml extension',
|
|
32
37
|
'yaml_file',
|
|
@@ -46,13 +51,12 @@ export function createCalculationHandlers(taskManager) {
|
|
|
46
51
|
const resolvedOutputFiles = {};
|
|
47
52
|
|
|
48
53
|
if (Object.keys(outputFiles).length > 0) {
|
|
49
|
-
//
|
|
50
|
-
const inputDir = path.dirname(
|
|
54
|
+
// 解決済みの入力YAMLファイルのディレクトリを取得
|
|
55
|
+
const inputDir = path.dirname(resolvedYamlFile);
|
|
51
56
|
|
|
52
57
|
// 各出力ファイルの絶対パス化
|
|
53
58
|
for (const [key, fileName] of Object.entries(outputFiles)) {
|
|
54
59
|
if (fileName) {
|
|
55
|
-
// ファイル名の拡張子チェック
|
|
56
60
|
if (!fileName.match(/\.(yaml|yml)$/i)) {
|
|
57
61
|
throw new ValidationError(
|
|
58
62
|
`Output file ${key} must have .yaml or .yml extension`,
|
|
@@ -60,42 +64,35 @@ export function createCalculationHandlers(taskManager) {
|
|
|
60
64
|
fileName
|
|
61
65
|
);
|
|
62
66
|
}
|
|
63
|
-
|
|
64
|
-
// 絶対パスに解決
|
|
65
67
|
resolvedOutputFiles[key] = path.join(inputDir, fileName);
|
|
66
|
-
|
|
67
68
|
logger.debug('Output file path resolved', {
|
|
68
|
-
key,
|
|
69
|
-
fileName,
|
|
70
|
-
inputDir,
|
|
69
|
+
key, fileName, inputDir,
|
|
71
70
|
resolvedPath: resolvedOutputFiles[key]
|
|
72
71
|
});
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
// 出力ファイル検証(従来の検証は不要、上記で実施済み)
|
|
78
|
-
|
|
79
76
|
logger.info('Starting radiation shielding calculation', {
|
|
80
|
-
yamlFile:
|
|
77
|
+
yamlFile: resolvedYamlFile,
|
|
81
78
|
summaryOptions,
|
|
82
|
-
outputFiles
|
|
79
|
+
outputFiles,
|
|
83
80
|
resolvedOutputFiles
|
|
84
81
|
});
|
|
85
82
|
|
|
86
|
-
//
|
|
83
|
+
// 計算実行(統合検証付き)
|
|
87
84
|
const result = await calculationService.executeWithValidation(
|
|
88
|
-
|
|
85
|
+
resolvedYamlFile,
|
|
89
86
|
summaryOptions,
|
|
90
|
-
resolvedOutputFiles,
|
|
91
|
-
undefined,
|
|
92
|
-
taskManager.dataManager
|
|
87
|
+
resolvedOutputFiles,
|
|
88
|
+
undefined,
|
|
89
|
+
taskManager.dataManager
|
|
93
90
|
);
|
|
94
91
|
|
|
95
92
|
// 事前検証で重大エラーが検出された場合の処理
|
|
96
93
|
if (result.success === false && result.stage === 'pre_validation') {
|
|
97
94
|
logger.error('Pre-calculation validation failed', {
|
|
98
|
-
yamlFile:
|
|
95
|
+
yamlFile: resolvedYamlFile,
|
|
99
96
|
criticalErrors: result.criticalErrors
|
|
100
97
|
});
|
|
101
98
|
|
|
@@ -128,7 +125,7 @@ export function createCalculationHandlers(taskManager) {
|
|
|
128
125
|
success: true,
|
|
129
126
|
message: 'Radiation shielding calculation completed successfully',
|
|
130
127
|
calculation: {
|
|
131
|
-
input_file:
|
|
128
|
+
input_file: resolvedYamlFile,
|
|
132
129
|
execution_time_ms: result.executionTime,
|
|
133
130
|
timestamp: result.summary.timestamp,
|
|
134
131
|
options: result.summary.options
|
|
@@ -161,7 +158,7 @@ export function createCalculationHandlers(taskManager) {
|
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
logger.info('Calculation completed successfully', {
|
|
164
|
-
yamlFile:
|
|
161
|
+
yamlFile: resolvedYamlFile,
|
|
165
162
|
executionTime: result.executionTime,
|
|
166
163
|
outputFiles: Object.keys(fileVerification).filter(k => k !== 'allFilesGenerated')
|
|
167
164
|
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// mcp/handlers/guiHandlers.js
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { logger } from '../../utils/logger.js';
|
|
6
|
+
import { TASKS_DIR, YAML_FILE } from '../../utils/paths.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* POKER.exe のパスを解決する
|
|
10
|
+
* POKER_INSTALL_PATH 環境変数(デフォルト: C:/Poker)配下の POKER.exe を参照
|
|
11
|
+
*/
|
|
12
|
+
function resolvePokerExePath() {
|
|
13
|
+
const installPath = process.env.POKER_INSTALL_PATH || 'C:/Poker';
|
|
14
|
+
return path.win32.join(installPath.replace(/\//g, '\\'), 'POKER.exe');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* yaml_file 引数を絶対パスに解決する
|
|
19
|
+
* ファイル名のみ → TASKS_DIR と結合
|
|
20
|
+
* 絶対パス → そのまま使用(後方互換)
|
|
21
|
+
*/
|
|
22
|
+
function resolveYamlPath(yamlFile) {
|
|
23
|
+
const absolutePathPattern = /^([a-zA-Z]:[\\\/]|\/)/;
|
|
24
|
+
return absolutePathPattern.test(yamlFile)
|
|
25
|
+
? yamlFile
|
|
26
|
+
: path.join(TASKS_DIR, yamlFile);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createGuiHandlers(taskManager) {
|
|
30
|
+
return {
|
|
31
|
+
async openGui(args) {
|
|
32
|
+
const yamlFile = args?.yaml_file || 'poker.yaml';
|
|
33
|
+
const resolvedYaml = resolveYamlPath(yamlFile);
|
|
34
|
+
const pokerExePath = resolvePokerExePath();
|
|
35
|
+
|
|
36
|
+
logger.info('poker_openGui: 開始', {
|
|
37
|
+
input: yamlFile,
|
|
38
|
+
resolvedYaml,
|
|
39
|
+
pokerExePath
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// ── Step 1: applyChanges を自動実行 ──────────────────────────
|
|
43
|
+
let applyResult;
|
|
44
|
+
try {
|
|
45
|
+
applyResult = await taskManager.applyChanges();
|
|
46
|
+
logger.info('poker_openGui: applyChanges 完了', { result: applyResult });
|
|
47
|
+
} catch (applyError) {
|
|
48
|
+
logger.error('poker_openGui: applyChanges 失敗', { error: applyError.message });
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: `変更の保存に失敗しました: ${applyError.message}`,
|
|
52
|
+
error_type: 'APPLY_CHANGES_FAILED',
|
|
53
|
+
suggestion: 'poker_applyChanges を手動で実行してエラー内容を確認してください。'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ── Step 2: POKER.exe の存在確認 ─────────────────────────────
|
|
58
|
+
try {
|
|
59
|
+
await fs.access(pokerExePath);
|
|
60
|
+
} catch {
|
|
61
|
+
logger.error('poker_openGui: POKER.exe が見つかりません', { pokerExePath });
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
error: `POKER.exe が見つかりません: ${pokerExePath}`,
|
|
65
|
+
error_type: 'POKER_EXE_NOT_FOUND',
|
|
66
|
+
suggestion: 'POKER_INSTALL_PATH 環境変数を正しいインストールディレクトリに設定してください。'
|
|
67
|
+
+ '\n例: "POKER_INSTALL_PATH": "C:\\\\Program Files\\\\POKER"'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ── Step 3: 入力 YAML の存在確認 ─────────────────────────────
|
|
72
|
+
try {
|
|
73
|
+
await fs.access(resolvedYaml);
|
|
74
|
+
} catch {
|
|
75
|
+
logger.error('poker_openGui: YAML ファイルが見つかりません', { resolvedYaml });
|
|
76
|
+
return {
|
|
77
|
+
success: false,
|
|
78
|
+
error: `入力ファイルが見つかりません: ${resolvedYaml}`,
|
|
79
|
+
error_type: 'YAML_FILE_NOT_FOUND',
|
|
80
|
+
suggestion: 'poker_applyChanges を先に実行してください。'
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ── Step 4: POKER.exe をデタッチ起動 ─────────────────────────
|
|
85
|
+
try {
|
|
86
|
+
const child = spawn(pokerExePath, [resolvedYaml], {
|
|
87
|
+
detached: true,
|
|
88
|
+
stdio: 'ignore', // MCPサーバーの stdio を汚染しない
|
|
89
|
+
shell: false
|
|
90
|
+
});
|
|
91
|
+
child.unref(); // MCPサーバーが POKER.exe の終了を待たない
|
|
92
|
+
|
|
93
|
+
logger.info('poker_openGui: POKER.exe 起動成功', {
|
|
94
|
+
pid: child.pid,
|
|
95
|
+
executable: pokerExePath,
|
|
96
|
+
inputFile: resolvedYaml
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
message: 'POKER GUI を起動しました。',
|
|
102
|
+
launched: {
|
|
103
|
+
executable: pokerExePath,
|
|
104
|
+
input_file: resolvedYaml,
|
|
105
|
+
pid: child.pid
|
|
106
|
+
},
|
|
107
|
+
auto_saved: {
|
|
108
|
+
performed: true,
|
|
109
|
+
details: applyResult
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
} catch (launchError) {
|
|
114
|
+
logger.error('poker_openGui: POKER.exe 起動失敗', { error: launchError.message });
|
|
115
|
+
return {
|
|
116
|
+
success: false,
|
|
117
|
+
error: `POKER.exe の起動に失敗しました: ${launchError.message}`,
|
|
118
|
+
error_type: 'POKER_LAUNCH_FAILED',
|
|
119
|
+
suggestion: 'POKER.exe の実行権限および POKER_INSTALL_PATH の設定を確認してください。'
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -9,6 +9,7 @@ import { createUnitHandlers } from './unitHandlers.js';
|
|
|
9
9
|
import { createCalculationHandlers } from './calculationHandlers.js';
|
|
10
10
|
import { resetHandlers } from './resetHandlers.js';
|
|
11
11
|
import { createDaughterNuclideHandler } from './daughterNuclideHandler.js';
|
|
12
|
+
import { createGuiHandlers } from './guiHandlers.js';
|
|
12
13
|
|
|
13
14
|
export function createAllHandlers(taskManager) {
|
|
14
15
|
return {
|
|
@@ -41,6 +42,9 @@ export function createAllHandlers(taskManager) {
|
|
|
41
42
|
|
|
42
43
|
// リセット操作
|
|
43
44
|
resetYaml: resetHandlers.resetYaml(taskManager),
|
|
45
|
+
|
|
46
|
+
// GUI表示操作
|
|
47
|
+
...createGuiHandlers(taskManager),
|
|
44
48
|
|
|
45
49
|
// 共通操作
|
|
46
50
|
async applyChanges(args) {
|
|
@@ -8,8 +8,8 @@ export const calculationTools = [
|
|
|
8
8
|
properties: {
|
|
9
9
|
yaml_file: {
|
|
10
10
|
type: 'string',
|
|
11
|
-
description: '計算に使用するYAMLファイル名(拡張子.yaml
|
|
12
|
-
pattern: '^[a-zA-Z0-9_\\-\\.]+\\.(yaml|yml)$'
|
|
11
|
+
description: '計算に使用するYAMLファイル名(拡張子.yamlを含む)。ファイル名のみ指定(例: poker.yaml)で、POKER_MCP_HOME/tasks/ 配下のファイルが自動的に参照されます。絶対パスも指定可能です。',
|
|
12
|
+
pattern: '^([a-zA-Z0-9_\\-\\.]+\\.(yaml|yml)|([a-zA-Z]:[\\\\\/]|\\/)[^\\\\]+\\.(yaml|yml))$'
|
|
13
13
|
},
|
|
14
14
|
summary_options: {
|
|
15
15
|
type: 'object',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// mcp/tools/guiTools.js
|
|
2
|
+
export const guiTools = [
|
|
3
|
+
{
|
|
4
|
+
name: 'poker_openGui',
|
|
5
|
+
description:
|
|
6
|
+
'YAMLファイルを保存してから POKER.exe でGUI表示します。'
|
|
7
|
+
+ '未保存の変更は自動的に保存(applyChanges)されてから起動します。'
|
|
8
|
+
+ 'POKER_INSTALL_PATH 環境変数(デフォルト: C:/Poker)の POKER.exe を使用します。'
|
|
9
|
+
+ 'Windows専用です。',
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
yaml_file: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description:
|
|
16
|
+
'表示する入力ファイル名(省略時は poker.yaml)。'
|
|
17
|
+
+ 'ファイル名のみ指定すると POKER_MCP_HOME/tasks/ 配下を自動参照します。'
|
|
18
|
+
+ '絶対パスも指定可能です。',
|
|
19
|
+
pattern: '^([a-zA-Z0-9_\\-\\.]+\\.(yaml|yml)|([a-zA-Z]:[\\\\\/]|\\/)[^\\\\]+\\.(yaml|yml))$'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
];
|
package/src/mcp/tools/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { unitTools } from './unitTools.js';
|
|
|
10
10
|
import { calculationTools } from './calculationTools.js';
|
|
11
11
|
import { resetTools } from './resetTools.js';
|
|
12
12
|
import { daughterNuclideTools } from './daughterNuclideTools.js';
|
|
13
|
+
import { guiTools } from './guiTools.js';
|
|
13
14
|
|
|
14
15
|
export const allTools = [
|
|
15
16
|
...bodyTools,
|
|
@@ -22,7 +23,8 @@ export const allTools = [
|
|
|
22
23
|
...unitTools,
|
|
23
24
|
...calculationTools,
|
|
24
25
|
...resetTools,
|
|
25
|
-
...daughterNuclideTools
|
|
26
|
+
...daughterNuclideTools,
|
|
27
|
+
...guiTools
|
|
26
28
|
];
|
|
27
29
|
|
|
28
30
|
export {
|
|
@@ -36,5 +38,6 @@ export {
|
|
|
36
38
|
unitTools,
|
|
37
39
|
calculationTools,
|
|
38
40
|
resetTools,
|
|
39
|
-
daughterNuclideTools
|
|
41
|
+
daughterNuclideTools,
|
|
42
|
+
guiTools
|
|
40
43
|
};
|