friday-mcp-v2 3.0.5 → 3.0.7

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.
Files changed (2) hide show
  1. package/dist/mcp-server.js +45 -8
  2. package/package.json +1 -1
@@ -942,6 +942,20 @@ function resolveRefFromState(snapshotId, ref, mode, sessionId, postId, currentSt
942
942
  (c.parentIndex ?? null) === snapBlock.parentIndex
943
943
  );
944
944
  if (refined.length === 1) return refined[0].index;
945
+
946
+ // 5b-2. ordinal(出現順序)で特定
947
+ if (refined.length > 1) {
948
+ const sameInSnapshot = snap.blocks.filter(b =>
949
+ b.fingerprint === snapBlock.fingerprint &&
950
+ (b.depth || 0) === snapBlock.depth &&
951
+ (b.parentIndex ?? null) === snapBlock.parentIndex
952
+ );
953
+ const ordinal = sameInSnapshot.findIndex(b => b.ref === ref);
954
+ if (ordinal >= 0 && ordinal < refined.length) {
955
+ return refined[ordinal].index;
956
+ }
957
+ }
958
+
945
959
  throw new Error(
946
960
  `ref "${ref}" (type: ${snapBlock.type}) の解決先が ${refined.length > 0 ? refined.length : candidates.length} 件見つかりました。` +
947
961
  `一意に特定できません。Re-fetch via get_article_structure.`
@@ -2042,7 +2056,7 @@ const tools = [
2042
2056
  },
2043
2057
  {
2044
2058
  name: "select_block",
2045
- description: "Select block(s). Index is 0-based flattened.",
2059
+ description: "Select block(s) by ref, section, blockType, or contains.",
2046
2060
  inputSchema: {
2047
2061
  type: "object",
2048
2062
  properties: {
@@ -2237,6 +2251,10 @@ const tools = [
2237
2251
  postId: postIdParam,
2238
2252
  site: siteParam,
2239
2253
  target: targetSchema,
2254
+ snapshotId: {
2255
+ type: "string",
2256
+ description: "Snapshot ID (from get_article_structure or any write response). Required when using ref/refs in target.",
2257
+ },
2240
2258
  },
2241
2259
  required: ["target"],
2242
2260
  },
@@ -2581,7 +2599,7 @@ async function handleUpdateBlocksTool(args, toolName) {
2581
2599
  // Headless モードで target: "selected" はエラー
2582
2600
  if (mode === 'headless' && target === 'selected') {
2583
2601
  return {
2584
- content: [{ type: "text", text: "❌ target:'selected' はエディタ接続時のみ使用可能です。index を指定してください。" }],
2602
+ content: [{ type: "text", text: "❌ target:'selected' はエディタ接続時のみ使用可能です。ref+snapshotId, section, blockType, contains 等を指定してください。" }],
2585
2603
  isError: true,
2586
2604
  };
2587
2605
  }
@@ -2592,7 +2610,7 @@ async function handleUpdateBlocksTool(args, toolName) {
2592
2610
  (headingLevel && headingContains);
2593
2611
  if (!hasTarget && !(appendToEnd && insertOnly)) {
2594
2612
  return {
2595
- content: [{ type: "text", text: "❌ ターゲットが指定されていません。\ntarget, index, indices, section, blockType, contains 等のいずれかを指定してください。" }],
2613
+ content: [{ type: "text", text: "❌ ターゲットが指定されていません。\nref+snapshotId, section, blockType, contains 等のいずれかを指定してください。" }],
2596
2614
  isError: true,
2597
2615
  };
2598
2616
  }
@@ -3315,7 +3333,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3315
3333
  // BUG-3: select_block では selected は使用不可
3316
3334
  if (tp.target === "selected") {
3317
3335
  return {
3318
- content: [{ type: "text", text: "❌ select_block では selected は使用できません。index, blockType, range 等を指定してください。" }],
3336
+ content: [{ type: "text", text: "❌ select_block では selected は使用できません。ref+snapshotId, blockType, contains 等を指定してください。" }],
3319
3337
  isError: true,
3320
3338
  };
3321
3339
  }
@@ -3328,7 +3346,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3328
3346
  (headingLevel && headingContains);
3329
3347
  if (!hasTarget) {
3330
3348
  return {
3331
- content: [{ type: "text", text: "❌ ターゲットが指定されていません。index, blockType, range, heading, contains 等のいずれかを指定してください。" }],
3349
+ content: [{ type: "text", text: "❌ ターゲットが指定されていません。ref+snapshotId, blockType, heading, contains 等のいずれかを指定してください。" }],
3332
3350
  isError: true,
3333
3351
  };
3334
3352
  }
@@ -3927,7 +3945,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3927
3945
  }
3928
3946
 
3929
3947
  case "get_block_html": {
3930
- let { mode, postId: _postId, sessionId: _sessionId, message, client } = await resolveMode(args, name);
3948
+ let { mode, postId: _postId, sessionId: _sessionId, message, client, siteName } = await resolveMode(args, name);
3931
3949
  if (mode === 'error') {
3932
3950
  return errorResponse(name, message, args?.site);
3933
3951
  }
@@ -3935,16 +3953,35 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3935
3953
  if (_resolved.error) return { content: [{ type: "text", text: _resolved.error }], isError: true };
3936
3954
  if (_resolved.editorConnected) mode = 'editor';
3937
3955
  const postId = _resolved.postId ?? _postId;
3956
+ const _siteName = siteName || args?.site || 'default';
3938
3957
 
3939
3958
  let tp;
3940
3959
  try { tp = normalizeTarget(args?.target); }
3941
3960
  catch (e) { return { content: [{ type: "text", text: `❌ ${e.message}` }], isError: true }; }
3942
3961
 
3962
+ // ref 解決(snapshotId + ref → index に変換)
3963
+ const resolved = await resolveRefsAndCheckRevision({
3964
+ snapshotId: args?.snapshotId,
3965
+ ref: tp._ref,
3966
+ refs: tp._refs,
3967
+ expectedRevision: args?.expectedRevision,
3968
+ mode, client, postId, sessionId: _sessionId, siteName: _siteName,
3969
+ });
3970
+ if (resolved.error) return resolved.error;
3971
+ if (resolved.index !== undefined) {
3972
+ tp.index = resolved.index;
3973
+ delete tp._ref;
3974
+ }
3975
+ if (resolved.indices !== undefined) {
3976
+ tp.indices = resolved.indices;
3977
+ delete tp._refs;
3978
+ }
3979
+
3943
3980
  const { target, index, indices, startIndex, endIndex, section, blockType, typeIndex, contains, headingLevel, headingContains } = tp;
3944
3981
 
3945
3982
  if (mode === 'headless' && target === 'selected') {
3946
3983
  return {
3947
- content: [{ type: "text", text: "❌ target:'selected' はエディタ接続時のみ使用可能です。index を指定してください。" }],
3984
+ content: [{ type: "text", text: "❌ target:'selected' はエディタ接続時のみ使用可能です。ref+snapshotId, section, blockType, contains 等を指定してください。" }],
3948
3985
  isError: true,
3949
3986
  };
3950
3987
  }
@@ -3954,7 +3991,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3954
3991
  (headingLevel && headingContains);
3955
3992
  if (!hasTarget) {
3956
3993
  return {
3957
- content: [{ type: "text", text: "❌ ターゲットが指定されていません。\ntarget, index, indices, section, blockType, contains 等のいずれかを指定してください。" }],
3994
+ content: [{ type: "text", text: "❌ ターゲットが指定されていません。\nref+snapshotId, section, blockType, contains 等のいずれかを指定してください。" }],
3958
3995
  isError: true,
3959
3996
  };
3960
3997
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "friday-mcp-v2",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "WordPress MCP Server for Claude Code - REST API direct communication",
5
5
  "type": "module",
6
6
  "main": "dist/mcp-server.js",