@echoes-io/mcp-server 1.3.0 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import { existsSync, readdirSync } from 'node:fs';
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
2
  import { extname, join } from 'node:path';
3
3
  import { getTextStats, parseMarkdown } from '@echoes-io/utils';
4
4
  import { z } from 'zod';
@@ -43,22 +43,29 @@ export async function timelineSync(args, tracker) {
43
43
  const episodePath = join(arcPath, ep.name);
44
44
  let episode = await tracker.getEpisode(timeline, arcName, ep.number);
45
45
  if (!episode) {
46
- episode = await tracker.createEpisode({
47
- timelineName: timeline,
48
- arcName: arcName,
49
- number: ep.number,
50
- slug: ep.name,
51
- title: ep.name,
52
- description: `Episode ${ep.number}`,
53
- });
54
- added++;
46
+ try {
47
+ episode = await tracker.createEpisode({
48
+ timelineName: timeline,
49
+ arcName: arcName,
50
+ number: ep.number,
51
+ slug: ep.name,
52
+ title: ep.name,
53
+ description: `Episode ${ep.number}`,
54
+ });
55
+ added++;
56
+ }
57
+ catch (error) {
58
+ console.error(`Error creating episode ${arcName}/ep${ep.number}:`, error instanceof Error ? error.message : error);
59
+ errors++;
60
+ continue; // Skip chapters if episode creation failed
61
+ }
55
62
  }
56
63
  const chapters = readdirSync(episodePath)
57
64
  .filter((file) => extname(file) === '.md')
58
65
  .map((file) => {
59
66
  try {
60
67
  const filePath = join(episodePath, file);
61
- const content = require('node:fs').readFileSync(filePath, 'utf-8');
68
+ const content = readFileSync(filePath, 'utf-8');
62
69
  const { metadata, content: markdownContent } = parseMarkdown(content);
63
70
  const stats = getTextStats(markdownContent);
64
71
  return {
@@ -73,6 +80,30 @@ export async function timelineSync(args, tracker) {
73
80
  }
74
81
  })
75
82
  .filter((ch) => ch !== null);
83
+ // Collect unique part numbers
84
+ const partNumbers = new Set(chapters.map((ch) => ch?.metadata.part || 1));
85
+ // Create parts if they don't exist
86
+ for (const partNum of partNumbers) {
87
+ try {
88
+ const existingPart = await tracker.getPart(timeline, arcName, ep.number, partNum);
89
+ if (!existingPart) {
90
+ await tracker.createPart({
91
+ timelineName: timeline,
92
+ arcName: arcName,
93
+ episodeNumber: ep.number,
94
+ number: partNum,
95
+ slug: `part-${partNum}`,
96
+ title: `Part ${partNum}`,
97
+ description: `Part ${partNum} of Episode ${ep.number}`,
98
+ });
99
+ added++;
100
+ }
101
+ }
102
+ catch (error) {
103
+ console.error(`Error creating part ${arcName}/ep${ep.number}/part${partNum}:`, error instanceof Error ? error.message : error);
104
+ errors++;
105
+ }
106
+ }
76
107
  for (const chapterData of chapters) {
77
108
  if (!chapterData)
78
109
  continue;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@echoes-io/mcp-server",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "1.3.1",
5
5
  "description": "Model Context Protocol server for AI integration with Echoes storytelling platform",
6
6
  "scripts": {
7
7
  "dev": "tsx cli/index.ts",