friday-mcp-v2 2.0.4 → 2.0.5
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/dist/mcp-server.js +21 -32
- package/dist/wordpress-api.js +26 -1
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -87,9 +87,13 @@ function errorResponse(toolName, message, site) {
|
|
|
87
87
|
function timeoutResponse(toolName, client, site) {
|
|
88
88
|
sendFeedback({ tool: toolName, category: 'error', content: 'タイムアウト: WordPressエディタが応答していません', site: site || 'default' });
|
|
89
89
|
const debug = client?.lastTimeoutDebug;
|
|
90
|
+
const debugEnabled = process.env.FRIDAY_DEBUG === '1';
|
|
90
91
|
let text = '⏳ タイムアウト: WordPressエディタが応答していません。';
|
|
91
|
-
if (debug) {
|
|
92
|
+
if (debugEnabled && debug) {
|
|
92
93
|
text += `\n\n[DEBUG] command=${debug.command} cmdId=${debug.commandId} elapsed=${debug.elapsed}ms polls=${debug.polls}`;
|
|
94
|
+
if (debug.ackSupported !== undefined) {
|
|
95
|
+
text += ` ackSupported=${debug.ackSupported}`;
|
|
96
|
+
}
|
|
93
97
|
if (debug.pollLog?.length > 0) {
|
|
94
98
|
text += '\n' + debug.pollLog.map(p => ` poll${p.poll}: ${p.error ? 'ERROR ' + p.error : JSON.stringify(p._debug)}`).join('\n');
|
|
95
99
|
}
|
|
@@ -1088,8 +1092,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1088
1092
|
|
|
1089
1093
|
const result = await client.sendEditorCommand("delete_block", { indices: uniqueIndices });
|
|
1090
1094
|
if (!result)
|
|
1091
|
-
|
|
1092
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1095
|
+
return timeoutResponse(name, client, args?.site);
|
|
1093
1096
|
if (!result.success)
|
|
1094
1097
|
return errorResponse(name, result.error, args?.site);
|
|
1095
1098
|
const details = result.deleted.map(d => ` [${d.index}] ${d.type}`).join('\n');
|
|
@@ -1108,8 +1111,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1108
1111
|
|
|
1109
1112
|
const result = await client.sendEditorCommand("delete_block", { index, count });
|
|
1110
1113
|
if (!result)
|
|
1111
|
-
|
|
1112
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1114
|
+
return timeoutResponse(name, client, args?.site);
|
|
1113
1115
|
if (!result.success)
|
|
1114
1116
|
return errorResponse(name, result.error, args?.site);
|
|
1115
1117
|
const details = result.deleted.map(d => ` [${d.index}] ${d.type}`).join('\n');
|
|
@@ -1150,8 +1152,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1150
1152
|
|
|
1151
1153
|
const result = await client.sendEditorCommand("move_block", { fromFlat, toFlat });
|
|
1152
1154
|
if (!result)
|
|
1153
|
-
|
|
1154
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1155
|
+
return timeoutResponse(name, client, args?.site);
|
|
1155
1156
|
if (!result.success)
|
|
1156
1157
|
return errorResponse(name, result.error, args?.site);
|
|
1157
1158
|
return { content: [{ type: "text", text: `✅ ブロック移動: flat[${fromFlat}] → flat[${toFlat}] (${result.moved.type})` }] };
|
|
@@ -1169,8 +1170,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1169
1170
|
|
|
1170
1171
|
const result = await client.sendEditorCommand("move_block", { from, to });
|
|
1171
1172
|
if (!result)
|
|
1172
|
-
|
|
1173
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1173
|
+
return timeoutResponse(name, client, args?.site);
|
|
1174
1174
|
if (!result.success)
|
|
1175
1175
|
return errorResponse(name, result.error, args?.site);
|
|
1176
1176
|
if (result.moved?.noop)
|
|
@@ -1188,8 +1188,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
const result = await client.sendEditorCommand("undo", { steps: args?.steps });
|
|
1190
1190
|
if (!result)
|
|
1191
|
-
|
|
1192
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1191
|
+
return timeoutResponse(name, client, args?.site);
|
|
1193
1192
|
if (!result.success)
|
|
1194
1193
|
return errorResponse(name, result.error, args?.site);
|
|
1195
1194
|
return { content: [{ type: "text", text: `✅ ${result.done}回取り消し` }] };
|
|
@@ -1205,8 +1204,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1205
1204
|
}
|
|
1206
1205
|
const result = await client.sendEditorCommand("redo", { steps: args?.steps });
|
|
1207
1206
|
if (!result)
|
|
1208
|
-
|
|
1209
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1207
|
+
return timeoutResponse(name, client, args?.site);
|
|
1210
1208
|
if (!result.success)
|
|
1211
1209
|
return errorResponse(name, result.error, args?.site);
|
|
1212
1210
|
return { content: [{ type: "text", text: `✅ ${result.done}回やり直し` }] };
|
|
@@ -1230,8 +1228,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1230
1228
|
|
|
1231
1229
|
const result = await client.sendEditorCommand("duplicate_block", { index });
|
|
1232
1230
|
if (!result)
|
|
1233
|
-
|
|
1234
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1231
|
+
return timeoutResponse(name, client, args?.site);
|
|
1235
1232
|
if (!result.success)
|
|
1236
1233
|
return errorResponse(name, result.error, args?.site);
|
|
1237
1234
|
return { content: [{ type: "text", text: `✅ ブロック複製完了` }] };
|
|
@@ -1250,8 +1247,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1250
1247
|
|
|
1251
1248
|
const result = await client.sendEditorCommand("save_post", {});
|
|
1252
1249
|
if (!result)
|
|
1253
|
-
|
|
1254
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1250
|
+
return timeoutResponse(name, client, args?.site);
|
|
1255
1251
|
if (!result.success)
|
|
1256
1252
|
return errorResponse(name, result.error, args?.site);
|
|
1257
1253
|
return { content: [{ type: "text", text: `✅ 保存完了` }] };
|
|
@@ -1436,8 +1432,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1436
1432
|
if (hasRawHTML) cmdParams.rawHTML = rawHTML;
|
|
1437
1433
|
const result = await client.sendEditorCommand("insert_block", cmdParams);
|
|
1438
1434
|
if (!result)
|
|
1439
|
-
|
|
1440
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1435
|
+
return timeoutResponse(name, client, args?.site);
|
|
1441
1436
|
if (!result.success)
|
|
1442
1437
|
return errorResponse(name, result.error, args?.site);
|
|
1443
1438
|
const count = result.insertedCount || result.inserted?.length || 1;
|
|
@@ -1456,8 +1451,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1456
1451
|
|
|
1457
1452
|
const result = await client.sendEditorCommand("insert_block", { blockType, content, index });
|
|
1458
1453
|
if (!result)
|
|
1459
|
-
|
|
1460
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1454
|
+
return timeoutResponse(name, client, args?.site);
|
|
1461
1455
|
if (!result.success)
|
|
1462
1456
|
return errorResponse(name, result.error, args?.site);
|
|
1463
1457
|
return { content: [{ type: "text", text: `✅ ブロック挿入: ${result.inserted.type} at ${result.inserted.index}` }] };
|
|
@@ -1499,7 +1493,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1499
1493
|
} else {
|
|
1500
1494
|
const result = await client.sendEditorCommand("get_block_html", { target, index, indices, startIndex, endIndex, section, blockType, typeIndex, headingLevel, headingContains }, 10000);
|
|
1501
1495
|
if (!result) {
|
|
1502
|
-
return
|
|
1496
|
+
return timeoutResponse(name, client, args?.site);
|
|
1503
1497
|
}
|
|
1504
1498
|
if (result.error) {
|
|
1505
1499
|
return errorResponse(name, result.error, args?.site);
|
|
@@ -1669,8 +1663,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1669
1663
|
insertPosition,
|
|
1670
1664
|
}, 10000);
|
|
1671
1665
|
if (!result)
|
|
1672
|
-
|
|
1673
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1666
|
+
return timeoutResponse(name, client, args?.site);
|
|
1674
1667
|
if (!result.success)
|
|
1675
1668
|
return errorResponse(name, result.error, args?.site);
|
|
1676
1669
|
return { content: [{ type: "text", text: `✅ ${result.mode === "insert" ? "挿入" : "更新"}完了${hasTextSelection ? "(カーソル選択モード)" : "(差分)"}` }] };
|
|
@@ -1686,8 +1679,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1686
1679
|
insertPosition,
|
|
1687
1680
|
}, 10000);
|
|
1688
1681
|
if (!result)
|
|
1689
|
-
|
|
1690
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1682
|
+
return timeoutResponse(name, client, args?.site);
|
|
1691
1683
|
if (!result.success)
|
|
1692
1684
|
return errorResponse(name, result.error, args?.site);
|
|
1693
1685
|
return { content: [{ type: "text", text: `✅ ${result.mode === "insert" ? "挿入" : "更新"}完了` }] };
|
|
@@ -1701,8 +1693,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1701
1693
|
dryRun: dryRun || false,
|
|
1702
1694
|
}, 10000);
|
|
1703
1695
|
if (!result)
|
|
1704
|
-
|
|
1705
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1696
|
+
return timeoutResponse(name, client, args?.site);
|
|
1706
1697
|
if (!result.success)
|
|
1707
1698
|
return errorResponse(name, result.error, args?.site);
|
|
1708
1699
|
return { content: [{ type: "text", text: `✅ 属性更新完了` }] };
|
|
@@ -1720,8 +1711,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1720
1711
|
dryRun: dryRun || false,
|
|
1721
1712
|
}, maxWait);
|
|
1722
1713
|
if (!result)
|
|
1723
|
-
|
|
1724
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1714
|
+
return timeoutResponse(name, client, args?.site);
|
|
1725
1715
|
if (!result.success)
|
|
1726
1716
|
return errorResponse(name, result.error, args?.site);
|
|
1727
1717
|
|
|
@@ -1804,8 +1794,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1804
1794
|
// Editor モード
|
|
1805
1795
|
const result = await client.sendEditorCommand("table_operations", tableParams, 10000);
|
|
1806
1796
|
if (!result)
|
|
1807
|
-
|
|
1808
|
-
return { content: [{ type: "text", text: "⏳ タイムアウト: WordPressエディタが応答していません。" }] };
|
|
1797
|
+
return timeoutResponse(name, client, args?.site);
|
|
1809
1798
|
if (!result.success)
|
|
1810
1799
|
return errorResponse(name, result.error, args?.site);
|
|
1811
1800
|
|
package/dist/wordpress-api.js
CHANGED
|
@@ -23,6 +23,7 @@ export class FridayWPClient {
|
|
|
23
23
|
|
|
24
24
|
this.authHeader = "Basic " + Buffer.from(`${this.wpUser}:${this.wpAppPassword}`).toString("base64");
|
|
25
25
|
this.baseUrl = this.wpUrl.replace(/\/$/, '') + '/wp-json/friday/v1';
|
|
26
|
+
this.commandResultAckSupported = true;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -97,6 +98,22 @@ export class FridayWPClient {
|
|
|
97
98
|
try {
|
|
98
99
|
const data = await this.request(`/editor/command/result/${commandId}`);
|
|
99
100
|
if (data?.status === 'completed' && data?.result !== undefined) {
|
|
101
|
+
if (this.commandResultAckSupported) {
|
|
102
|
+
try {
|
|
103
|
+
await this.request(`/editor/command/result/${commandId}/ack`, {
|
|
104
|
+
method: 'POST',
|
|
105
|
+
body: JSON.stringify({}),
|
|
106
|
+
});
|
|
107
|
+
} catch (ackError) {
|
|
108
|
+
const message = ackError?.message || String(ackError);
|
|
109
|
+
if (message.includes('API 404') || message.includes('rest_no_route')) {
|
|
110
|
+
this.commandResultAckSupported = false;
|
|
111
|
+
pollLog.push({ poll: i + 1, ackUnsupported: true, error: message });
|
|
112
|
+
} else {
|
|
113
|
+
pollLog.push({ poll: i + 1, ackError: message });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
100
117
|
this.lastTimeoutDebug = null;
|
|
101
118
|
return data.result;
|
|
102
119
|
}
|
|
@@ -108,7 +125,14 @@ export class FridayWPClient {
|
|
|
108
125
|
pollLog.push({ poll: i + 1, error: e.message });
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
|
-
this.lastTimeoutDebug = {
|
|
128
|
+
this.lastTimeoutDebug = {
|
|
129
|
+
command,
|
|
130
|
+
commandId,
|
|
131
|
+
elapsed: Date.now() - t0,
|
|
132
|
+
polls: maxAttempts,
|
|
133
|
+
ackSupported: this.commandResultAckSupported,
|
|
134
|
+
pollLog
|
|
135
|
+
};
|
|
112
136
|
return null; // timeout
|
|
113
137
|
}
|
|
114
138
|
|
|
@@ -327,6 +351,7 @@ export class FridayWPClient {
|
|
|
327
351
|
instance.wpAppPassword = config.pass;
|
|
328
352
|
instance.authHeader = "Basic " + Buffer.from(`${config.user}:${config.pass}`).toString("base64");
|
|
329
353
|
instance.baseUrl = config.url.replace(/\/$/, '') + '/wp-json/friday/v1';
|
|
354
|
+
instance.commandResultAckSupported = true;
|
|
330
355
|
return instance;
|
|
331
356
|
}
|
|
332
357
|
}
|