friday-mcp-v2 3.0.5 → 3.0.6

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 +38 -1
  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.`
@@ -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
  },
@@ -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,11 +3953,30 @@ 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') {
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.6",
4
4
  "description": "WordPress MCP Server for Claude Code - REST API direct communication",
5
5
  "type": "module",
6
6
  "main": "dist/mcp-server.js",