@echoes-io/mcp-server 1.6.0 → 1.8.0

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 CHANGED
@@ -8,9 +8,27 @@ The server is distributed as an npm package and can be used without cloning the
8
8
 
9
9
  ### Using with MCP Clients
10
10
 
11
- **Important:** The server must be run from the `.github` directory of your Echoes project.
11
+ The server can run in three modes depending on the working directory:
12
12
 
13
- Add to your MCP client configuration (e.g., `~/.config/q/mcp.json` for Amazon Q):
13
+ 1. **Single Timeline Mode**: Run from a `timeline-*` directory to work with that specific timeline
14
+ 2. **Multi-Timeline Mode**: Run from `.github` directory to access all timelines
15
+ 3. **Test Mode**: Run from `mcp-server` directory for development
16
+
17
+ #### Single Timeline Configuration (Recommended for Kiro CLI)
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "echoes": {
23
+ "command": "npx",
24
+ "args": ["-y", "@echoes-io/mcp-server"],
25
+ "cwd": "/path/to/timeline-pulse"
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ #### Multi-Timeline Configuration (Legacy/CAO)
14
32
 
15
33
  ```json
16
34
  {
@@ -37,7 +55,7 @@ Then configure:
37
55
  "mcpServers": {
38
56
  "echoes": {
39
57
  "command": "echoes-mcp-server",
40
- "cwd": "/path/to/echoes-io/.github",
58
+ "cwd": "/path/to/timeline-pulse",
41
59
  "env": {
42
60
  "ECHOES_RAG_PROVIDER": "e5-small"
43
61
  }
@@ -50,13 +68,49 @@ Then configure:
50
68
  - `ECHOES_RAG_PROVIDER`: Embedding provider (`e5-small`, `e5-large`, or `gemini`). Default: `e5-small`
51
69
  - `ECHOES_GEMINI_API_KEY`: Required if using `gemini` provider
52
70
 
53
- ## Multi-Timeline Architecture
71
+ ## Execution Modes
72
+
73
+ ### Single Timeline Mode (Recommended)
74
+ Run from a timeline directory to work with that specific timeline:
75
+ ```bash
76
+ cd timeline-pulse
77
+ npx @echoes-io/mcp-server
78
+ # [DEBUG] Mode: single-timeline "pulse"
79
+ ```
80
+
81
+ **Benefits:**
82
+ - Simpler configuration for single-timeline workflows
83
+ - Direct access to timeline databases
84
+ - Perfect for Kiro CLI integration
85
+
86
+ ### Multi-Timeline Mode (Legacy)
87
+ Run from `.github` directory to access all timelines:
88
+ ```bash
89
+ cd .github
90
+ npx @echoes-io/mcp-server
91
+ # [DEBUG] Mode: multi-timeline (scanning /path/to/echoes-io)
92
+ ```
93
+
94
+ **Benefits:**
95
+ - Manage multiple timelines simultaneously
96
+ - Backward compatible with CAO agents
97
+ - Timeline repositories can be private
98
+
99
+ ### Test Mode
100
+ Run from `mcp-server` directory for development:
101
+ ```bash
102
+ cd mcp-server
103
+ npm run dev
104
+ # [DEBUG] Mode: test from mcp-server (in-memory)
105
+ ```
106
+
107
+ ## Timeline Architecture
54
108
 
55
- The server automatically discovers and manages multiple timelines:
109
+ Each timeline has isolated databases in its own repository:
56
110
 
57
111
  ```
58
112
  echoes-io/
59
- .github/ # Server runs from here
113
+ .github/ # Multi-timeline mode runs from here
60
114
  timeline-eros/ # Private timeline repo
61
115
  tracker.db # Timeline-specific database
62
116
  rag.db # Timeline-specific RAG index
@@ -0,0 +1,21 @@
1
+ import type { Tracker } from '@echoes-io/tracker';
2
+ export declare function listPrompts(): {
3
+ prompts: {
4
+ name: string;
5
+ description: string;
6
+ arguments: {
7
+ name: string;
8
+ description: string;
9
+ required: boolean;
10
+ }[];
11
+ }[];
12
+ };
13
+ export declare function getPrompt(name: string, args: Record<string, string>, timeline: string, tracker: Tracker): Promise<{
14
+ messages: {
15
+ role: "user";
16
+ content: {
17
+ type: "text";
18
+ text: string;
19
+ };
20
+ }[];
21
+ }>;
@@ -0,0 +1,107 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { join, resolve } from 'node:path';
4
+ import { substitutePlaceholders } from './substitution.js';
5
+ import { validateGitHubRepo } from './validation.js';
6
+ const PROMPTS = [
7
+ {
8
+ name: 'new-chapter',
9
+ description: 'Create a new chapter for a timeline arc',
10
+ arguments: [
11
+ { name: 'arc', description: 'Arc name (e.g., "work", "anima")', required: true },
12
+ { name: 'chapter', description: 'Chapter number (e.g., "1", "12")', required: true },
13
+ ],
14
+ },
15
+ {
16
+ name: 'revise-chapter',
17
+ description: 'Revise an existing chapter with specific improvements',
18
+ arguments: [
19
+ { name: 'arc', description: 'Arc name', required: true },
20
+ { name: 'chapter', description: 'Chapter number', required: true },
21
+ ],
22
+ },
23
+ {
24
+ name: 'expand-chapter',
25
+ description: 'Expand a chapter to reach target word count',
26
+ arguments: [
27
+ { name: 'arc', description: 'Arc name', required: true },
28
+ { name: 'chapter', description: 'Chapter number', required: true },
29
+ { name: 'target', description: 'Target word count (e.g., "4000")', required: true },
30
+ ],
31
+ },
32
+ {
33
+ name: 'new-character',
34
+ description: 'Create a new character sheet',
35
+ arguments: [{ name: 'name', description: 'Character name', required: true }],
36
+ },
37
+ {
38
+ name: 'new-episode',
39
+ description: 'Create a new episode outline',
40
+ arguments: [
41
+ { name: 'arc', description: 'Arc name', required: true },
42
+ { name: 'episode', description: 'Episode number', required: true },
43
+ ],
44
+ },
45
+ {
46
+ name: 'new-arc',
47
+ description: 'Create a new story arc',
48
+ arguments: [{ name: 'name', description: 'Arc name (lowercase, no spaces)', required: true }],
49
+ },
50
+ ];
51
+ export function listPrompts() {
52
+ return { prompts: PROMPTS };
53
+ }
54
+ export async function getPrompt(name, args, timeline, tracker) {
55
+ try {
56
+ // Validate .github repo exists
57
+ const { exists: githubExists, path: githubPath } = validateGitHubRepo();
58
+ if (!githubExists) {
59
+ throw new Error('.github repository not found.\n' +
60
+ 'Clone it as sibling: git clone https://github.com/echoes-io/.github ../.github');
61
+ }
62
+ // Read base template (required)
63
+ const basePath = join(githubPath, `${name}.md`);
64
+ if (!existsSync(basePath)) {
65
+ throw new Error(`Prompt template not found: ${name}.md\n` +
66
+ `Expected location: ../.github/.kiro/prompts/${name}.md`);
67
+ }
68
+ const basePrompt = await readFile(basePath, 'utf-8');
69
+ // Check for timeline override (optional)
70
+ const timelinePromptsPath = resolve(process.cwd(), '.kiro/prompts');
71
+ const overridePath = join(timelinePromptsPath, `${name}.md`);
72
+ let overridePrompt = '';
73
+ if (existsSync(overridePath)) {
74
+ overridePrompt = await readFile(overridePath, 'utf-8');
75
+ }
76
+ // Concatenate (base first, then override)
77
+ const combinedPrompt = overridePrompt
78
+ ? `${basePrompt}\n\n---\n\n${overridePrompt}`
79
+ : basePrompt;
80
+ // Substitute placeholders
81
+ const finalPrompt = await substitutePlaceholders(name, combinedPrompt, args, timeline, tracker);
82
+ return {
83
+ messages: [
84
+ {
85
+ role: 'user',
86
+ content: {
87
+ type: 'text',
88
+ text: finalPrompt,
89
+ },
90
+ },
91
+ ],
92
+ };
93
+ }
94
+ catch (error) {
95
+ return {
96
+ messages: [
97
+ {
98
+ role: 'user',
99
+ content: {
100
+ type: 'text',
101
+ text: `❌ Error loading prompt "${name}":\n\n${error instanceof Error ? error.message : 'Unknown error'}`,
102
+ },
103
+ },
104
+ ],
105
+ };
106
+ }
107
+ }
@@ -0,0 +1,2 @@
1
+ export { getPrompt, listPrompts } from './handlers.js';
2
+ export { validateGitHubRepo } from './validation.js';
@@ -0,0 +1,2 @@
1
+ export { getPrompt, listPrompts } from './handlers.js';
2
+ export { validateGitHubRepo } from './validation.js';
@@ -0,0 +1,2 @@
1
+ import type { Tracker } from '@echoes-io/tracker';
2
+ export declare function substitutePlaceholders(promptName: string, template: string, args: Record<string, string>, timeline: string, tracker: Tracker): Promise<string>;
@@ -0,0 +1,45 @@
1
+ import { getAvailableArcs, validateArcExists, validateArcNotExists } from './validation.js';
2
+ export async function substitutePlaceholders(promptName, template, args, timeline, tracker) {
3
+ const replacements = {
4
+ TIMELINE: timeline,
5
+ ...args,
6
+ };
7
+ // Prompt-specific validations
8
+ if (['new-chapter', 'revise-chapter', 'expand-chapter'].includes(promptName)) {
9
+ const { arc, chapter } = args;
10
+ if (!arc) {
11
+ throw new Error('Missing required argument: arc');
12
+ }
13
+ if (!chapter) {
14
+ throw new Error('Missing required argument: chapter');
15
+ }
16
+ // Validate arc exists
17
+ const arcExists = await validateArcExists(arc, tracker, timeline);
18
+ if (!arcExists) {
19
+ const available = await getAvailableArcs(tracker, timeline);
20
+ throw new Error(`Arc "${arc}" not found in tracker.\nAvailable arcs: ${available.join(', ') || 'none'}`);
21
+ }
22
+ // Validate chapter is a number
23
+ if (!/^\d+$/.test(chapter)) {
24
+ throw new Error(`Chapter must be a number, got: "${chapter}"`);
25
+ }
26
+ }
27
+ if (promptName === 'new-arc') {
28
+ const { name } = args;
29
+ if (!name) {
30
+ throw new Error('Missing required argument: name');
31
+ }
32
+ // Validate arc doesn't exist
33
+ const arcNotExists = await validateArcNotExists(name, tracker, timeline);
34
+ if (!arcNotExists) {
35
+ throw new Error(`Arc "${name}" already exists in tracker.`);
36
+ }
37
+ }
38
+ // Replace all placeholders
39
+ let result = template;
40
+ for (const [key, value] of Object.entries(replacements)) {
41
+ const placeholder = `{${key.toUpperCase()}}`;
42
+ result = result.replace(new RegExp(placeholder.replace(/[{}]/g, '\\$&'), 'g'), value);
43
+ }
44
+ return result;
45
+ }
@@ -0,0 +1,8 @@
1
+ import type { Tracker } from '@echoes-io/tracker';
2
+ export declare function validateGitHubRepo(): {
3
+ exists: boolean;
4
+ path: string;
5
+ };
6
+ export declare function validateArcExists(arc: string, tracker: Tracker, timeline: string): Promise<boolean>;
7
+ export declare function validateArcNotExists(arc: string, tracker: Tracker, timeline: string): Promise<boolean>;
8
+ export declare function getAvailableArcs(tracker: Tracker, timeline: string): Promise<string[]>;
@@ -0,0 +1,20 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ export function validateGitHubRepo() {
4
+ const githubPath = resolve(process.cwd(), '../.github/.kiro/prompts');
5
+ return {
6
+ exists: existsSync(githubPath),
7
+ path: githubPath,
8
+ };
9
+ }
10
+ export async function validateArcExists(arc, tracker, timeline) {
11
+ const arcs = await tracker.getArcs(timeline);
12
+ return arcs.some((a) => a.name === arc);
13
+ }
14
+ export async function validateArcNotExists(arc, tracker, timeline) {
15
+ return !(await validateArcExists(arc, tracker, timeline));
16
+ }
17
+ export async function getAvailableArcs(tracker, timeline) {
18
+ const arcs = await tracker.getArcs(timeline);
19
+ return arcs.map((a) => a.name);
20
+ }
package/lib/server.d.ts CHANGED
@@ -10,9 +10,18 @@ export declare function createServer(timelines: Map<string, TimelineContext>): S
10
10
  method: string;
11
11
  params?: {
12
12
  [x: string]: unknown;
13
+ task?: {
14
+ [x: string]: unknown;
15
+ ttl?: number | null | undefined;
16
+ pollInterval?: number | undefined;
17
+ } | undefined;
13
18
  _meta?: {
14
19
  [x: string]: unknown;
15
20
  progressToken?: string | number | undefined;
21
+ "io.modelcontextprotocol/related-task"?: {
22
+ [x: string]: unknown;
23
+ taskId: string;
24
+ } | undefined;
16
25
  } | undefined;
17
26
  } | undefined;
18
27
  }, {
@@ -21,12 +30,20 @@ export declare function createServer(timelines: Map<string, TimelineContext>): S
21
30
  [x: string]: unknown;
22
31
  _meta?: {
23
32
  [x: string]: unknown;
33
+ "io.modelcontextprotocol/related-task"?: {
34
+ [x: string]: unknown;
35
+ taskId: string;
36
+ } | undefined;
24
37
  } | undefined;
25
38
  } | undefined;
26
39
  }, {
27
40
  [x: string]: unknown;
28
41
  _meta?: {
29
42
  [x: string]: unknown;
43
+ "io.modelcontextprotocol/related-task"?: {
44
+ [x: string]: unknown;
45
+ taskId: string;
46
+ } | undefined;
30
47
  } | undefined;
31
48
  }>;
32
49
  interface TimelineContext {
package/lib/server.js CHANGED
@@ -5,8 +5,9 @@ import { RAGSystem } from '@echoes-io/rag';
5
5
  import { Tracker } from '@echoes-io/tracker';
6
6
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
7
7
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
8
- import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
9
- import { zodToJsonSchema } from 'zod-to-json-schema';
8
+ import { toJsonSchemaCompat } from '@modelcontextprotocol/sdk/server/zod-json-schema-compat.js';
9
+ import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
10
+ import { getPrompt, listPrompts, validateGitHubRepo } from './prompts/index.js';
10
11
  import { bookGenerate, bookGenerateSchema, chapterDelete, chapterDeleteSchema, chapterInfo, chapterInfoSchema, chapterInsert, chapterInsertSchema, chapterRefresh, chapterRefreshSchema, episodeInfo, episodeInfoSchema, episodeUpdate, episodeUpdateSchema, ragCharacters, ragCharactersSchema, ragContext, ragContextSchema, ragIndex, ragIndexSchema, ragSearch, ragSearchSchema, stats, statsSchema, timelineSync, timelineSyncSchema, wordsCount, wordsCountSchema, } from './tools/index.js';
11
12
  const __dirname = dirname(fileURLToPath(import.meta.url));
12
13
  const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
@@ -17,6 +18,7 @@ export function createServer(timelines) {
17
18
  }, {
18
19
  capabilities: {
19
20
  tools: {},
21
+ prompts: {},
20
22
  },
21
23
  });
22
24
  server.setRequestHandler(ListToolsRequestSchema, async () => {
@@ -25,72 +27,72 @@ export function createServer(timelines) {
25
27
  {
26
28
  name: 'words-count',
27
29
  description: 'Count words and text statistics in a markdown file',
28
- inputSchema: zodToJsonSchema(wordsCountSchema),
30
+ inputSchema: toJsonSchemaCompat(wordsCountSchema),
29
31
  },
30
32
  {
31
33
  name: 'chapter-info',
32
34
  description: 'Extract chapter metadata, content preview, and statistics',
33
- inputSchema: zodToJsonSchema(chapterInfoSchema),
35
+ inputSchema: toJsonSchemaCompat(chapterInfoSchema),
34
36
  },
35
37
  {
36
38
  name: 'episode-info',
37
39
  description: 'Get episode information and list of chapters',
38
- inputSchema: zodToJsonSchema(episodeInfoSchema),
40
+ inputSchema: toJsonSchemaCompat(episodeInfoSchema),
39
41
  },
40
42
  {
41
43
  name: 'episode-update',
42
44
  description: 'Update episode metadata (description, title, slug)',
43
- inputSchema: zodToJsonSchema(episodeUpdateSchema),
45
+ inputSchema: toJsonSchemaCompat(episodeUpdateSchema),
44
46
  },
45
47
  {
46
48
  name: 'chapter-refresh',
47
49
  description: 'Refresh chapter metadata and statistics from file',
48
- inputSchema: zodToJsonSchema(chapterRefreshSchema),
50
+ inputSchema: toJsonSchemaCompat(chapterRefreshSchema),
49
51
  },
50
52
  {
51
53
  name: 'chapter-delete',
52
54
  description: 'Delete chapter from database and optionally from filesystem',
53
- inputSchema: zodToJsonSchema(chapterDeleteSchema),
55
+ inputSchema: toJsonSchemaCompat(chapterDeleteSchema),
54
56
  },
55
57
  {
56
58
  name: 'chapter-insert',
57
59
  description: 'Insert new chapter and automatically renumber subsequent chapters',
58
- inputSchema: zodToJsonSchema(chapterInsertSchema),
60
+ inputSchema: toJsonSchemaCompat(chapterInsertSchema),
59
61
  },
60
62
  {
61
63
  name: 'timeline-sync',
62
64
  description: 'Synchronize timeline content with database',
63
- inputSchema: zodToJsonSchema(timelineSyncSchema),
65
+ inputSchema: toJsonSchemaCompat(timelineSyncSchema),
64
66
  },
65
67
  {
66
68
  name: 'stats',
67
69
  description: 'Get statistics for timeline, arc, episode, or POV',
68
- inputSchema: zodToJsonSchema(statsSchema),
70
+ inputSchema: toJsonSchemaCompat(statsSchema),
69
71
  },
70
72
  {
71
73
  name: 'rag-index',
72
74
  description: 'Index chapters into RAG vector database for semantic search',
73
- inputSchema: zodToJsonSchema(ragIndexSchema),
75
+ inputSchema: toJsonSchemaCompat(ragIndexSchema),
74
76
  },
75
77
  {
76
78
  name: 'rag-search',
77
79
  description: 'Semantic search across timeline content',
78
- inputSchema: zodToJsonSchema(ragSearchSchema),
80
+ inputSchema: toJsonSchemaCompat(ragSearchSchema),
79
81
  },
80
82
  {
81
83
  name: 'rag-context',
82
84
  description: 'Retrieve relevant context for AI interactions',
83
- inputSchema: zodToJsonSchema(ragContextSchema),
85
+ inputSchema: toJsonSchemaCompat(ragContextSchema),
84
86
  },
85
87
  {
86
88
  name: 'rag-characters',
87
89
  description: 'Get all characters that appear in chapters with a specific character',
88
- inputSchema: zodToJsonSchema(ragCharactersSchema),
90
+ inputSchema: toJsonSchemaCompat(ragCharactersSchema),
89
91
  },
90
92
  {
91
93
  name: 'book-generate',
92
94
  description: 'Generate PDF book from timeline content using LaTeX',
93
- inputSchema: zodToJsonSchema(bookGenerateSchema),
95
+ inputSchema: toJsonSchemaCompat(bookGenerateSchema),
94
96
  },
95
97
  ],
96
98
  };
@@ -177,16 +179,39 @@ export function createServer(timelines) {
177
179
  throw new Error(`Unknown tool: ${name}`);
178
180
  }
179
181
  });
182
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
183
+ return listPrompts();
184
+ });
185
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
186
+ const { name, arguments: args } = request.params;
187
+ // Get timeline from first available timeline (single-timeline mode)
188
+ // or require timeline in args for multi-timeline mode
189
+ const timelineNames = Array.from(timelines.keys());
190
+ if (timelineNames.length === 0) {
191
+ throw new Error('No timelines available');
192
+ }
193
+ // For single-timeline mode, use the only timeline
194
+ // For multi-timeline mode, this would need timeline in args
195
+ const timeline = timelineNames[0];
196
+ const { tracker } = timelines.get(timeline);
197
+ return await getPrompt(name, args || {}, timeline, tracker);
198
+ });
180
199
  return server;
181
200
  }
182
201
  export async function runServer() {
183
- // Validate we're running from .github directory
184
- if (process.env.NODE_ENV !== 'test' && !process.cwd().endsWith('/.github')) {
185
- throw new Error('Server must be run from .github directory');
186
- }
202
+ const { readdirSync, existsSync } = await import('node:fs');
203
+ const { join, basename } = await import('node:path');
204
+ const cwd = process.cwd();
205
+ const cwdName = basename(cwd);
187
206
  const timelines = new Map();
207
+ const isTest = process.env.NODE_ENV === 'test' || process.env.VITEST === 'true';
208
+ const log = (...args) => {
209
+ if (!isTest)
210
+ log(...args);
211
+ };
212
+ log(`[DEBUG] Starting from: ${cwd}`);
188
213
  if (process.env.NODE_ENV === 'test') {
189
- // Test mode: single in-memory database
214
+ // Test mode: in-memory databases
190
215
  const tracker = new Tracker(':memory:');
191
216
  await tracker.init();
192
217
  const rag = new RAGSystem({
@@ -194,29 +219,60 @@ export async function runServer() {
194
219
  dbPath: ':memory:',
195
220
  });
196
221
  timelines.set('test', { tracker, rag, contentPath: './test-content' });
197
- console.error('Test mode: in-memory databases');
222
+ log('[DEBUG] Mode: test (in-memory)');
223
+ }
224
+ else if (cwdName.startsWith('timeline-')) {
225
+ // Single timeline mode: running from timeline directory
226
+ const timelineName = cwdName.replace('timeline-', '');
227
+ const contentPath = join(cwd, 'content');
228
+ if (!existsSync(contentPath)) {
229
+ throw new Error(`No content directory found in ${cwd}`);
230
+ }
231
+ const trackerPath = join(cwd, 'tracker.db');
232
+ const ragPath = join(cwd, 'rag.db');
233
+ const tracker = new Tracker(trackerPath);
234
+ await tracker.init();
235
+ const provider = (process.env.ECHOES_RAG_PROVIDER || 'e5-small');
236
+ const rag = new RAGSystem({
237
+ provider,
238
+ dbPath: ragPath,
239
+ geminiApiKey: process.env.ECHOES_GEMINI_API_KEY,
240
+ });
241
+ timelines.set(timelineName, { tracker, rag, contentPath });
242
+ log(`[DEBUG] Mode: single-timeline "${timelineName}"`);
243
+ log(`[DEBUG] Content: ${contentPath}`);
244
+ log(`[DEBUG] Tracker: ${trackerPath}`);
245
+ log(`[DEBUG] RAG: ${ragPath}`);
246
+ }
247
+ else if (cwdName === 'mcp-server') {
248
+ // Test mode from mcp-server directory: in-memory
249
+ const tracker = new Tracker(':memory:');
250
+ await tracker.init();
251
+ const rag = new RAGSystem({
252
+ provider: 'e5-small',
253
+ dbPath: ':memory:',
254
+ });
255
+ timelines.set('test', { tracker, rag, contentPath: './test-content' });
256
+ log('[DEBUG] Mode: test from mcp-server (in-memory)');
198
257
  }
199
258
  else {
200
- // Production: discover timelines and create separate databases
201
- const { readdirSync, existsSync, mkdirSync } = await import('node:fs');
202
- const { join } = await import('node:path');
203
- const parentDir = join(process.cwd(), '..');
259
+ // Multi-timeline mode: discover from parent directory (backward compat for .github)
260
+ const parentDir = join(cwd, '..');
204
261
  const entries = readdirSync(parentDir, { withFileTypes: true });
262
+ log(`[DEBUG] Mode: multi-timeline (scanning ${parentDir})`);
205
263
  for (const entry of entries) {
206
264
  if (entry.isDirectory() && entry.name.startsWith('timeline-')) {
207
265
  const timelineName = entry.name.replace('timeline-', '');
208
266
  const timelinePath = join(parentDir, entry.name);
209
267
  const contentPath = join(timelinePath, 'content');
210
268
  if (!existsSync(contentPath)) {
211
- console.error(`Skipping ${entry.name}: no content directory`);
269
+ log(`[DEBUG] Skipping ${entry.name}: no content directory`);
212
270
  continue;
213
271
  }
214
- // Initialize tracker
215
272
  const trackerPath = join(timelinePath, 'tracker.db');
273
+ const ragPath = join(timelinePath, 'rag.db');
216
274
  const tracker = new Tracker(trackerPath);
217
275
  await tracker.init();
218
- // Initialize RAG
219
- const ragPath = join(timelinePath, 'rag.db');
220
276
  const provider = (process.env.ECHOES_RAG_PROVIDER || 'e5-small');
221
277
  const rag = new RAGSystem({
222
278
  provider,
@@ -224,7 +280,7 @@ export async function runServer() {
224
280
  geminiApiKey: process.env.ECHOES_GEMINI_API_KEY,
225
281
  });
226
282
  timelines.set(timelineName, { tracker, rag, contentPath });
227
- console.error(`Timeline "${timelineName}" initialized: ${trackerPath}`);
283
+ log(`[DEBUG] Timeline "${timelineName}": ${trackerPath}`);
228
284
  }
229
285
  }
230
286
  if (timelines.size === 0) {
@@ -234,5 +290,16 @@ export async function runServer() {
234
290
  const server = createServer(timelines);
235
291
  const transport = new StdioServerTransport();
236
292
  await server.connect(transport);
237
- console.error(`Echoes MCP Server running on stdio (${timelines.size} timelines)`);
293
+ log(`[DEBUG] Server ready with ${timelines.size} timeline(s)`);
294
+ // Validate .github repo for prompts
295
+ const { exists: githubExists, path: githubPath } = validateGitHubRepo();
296
+ if (!githubExists) {
297
+ log('⚠️ WARNING: .github repository not found');
298
+ log(' Expected location: ../.github/.kiro/prompts/');
299
+ log(' MCP prompts will not work until .github repo is cloned as sibling.');
300
+ log(' Clone: git clone https://github.com/echoes-io/.github ../.github');
301
+ }
302
+ else {
303
+ log('✓ .github repository found');
304
+ }
238
305
  }
@@ -3,18 +3,11 @@ export declare const bookGenerateSchema: z.ZodObject<{
3
3
  timeline: z.ZodString;
4
4
  outputPath: z.ZodString;
5
5
  episodes: z.ZodOptional<z.ZodString>;
6
- format: z.ZodOptional<z.ZodEnum<["a4", "a5"]>>;
7
- }, "strip", z.ZodTypeAny, {
8
- timeline: string;
9
- outputPath: string;
10
- episodes?: string | undefined;
11
- format?: "a4" | "a5" | undefined;
12
- }, {
13
- timeline: string;
14
- outputPath: string;
15
- episodes?: string | undefined;
16
- format?: "a4" | "a5" | undefined;
17
- }>;
6
+ format: z.ZodOptional<z.ZodEnum<{
7
+ a4: "a4";
8
+ a5: "a5";
9
+ }>>;
10
+ }, z.core.$strip>;
18
11
  type BookGenerateArgs = z.infer<typeof bookGenerateSchema> & {
19
12
  contentPath: string;
20
13
  };
@@ -6,19 +6,7 @@ export declare const chapterDeleteSchema: z.ZodObject<{
6
6
  episode: z.ZodNumber;
7
7
  chapter: z.ZodNumber;
8
8
  file: z.ZodOptional<z.ZodString>;
9
- }, "strip", z.ZodTypeAny, {
10
- timeline: string;
11
- arc: string;
12
- episode: number;
13
- chapter: number;
14
- file?: string | undefined;
15
- }, {
16
- timeline: string;
17
- arc: string;
18
- episode: number;
19
- chapter: number;
20
- file?: string | undefined;
21
- }>;
9
+ }, z.core.$strip>;
22
10
  export declare function chapterDelete(args: z.infer<typeof chapterDeleteSchema>, tracker: Tracker): Promise<{
23
11
  content: {
24
12
  type: "text";
@@ -5,17 +5,7 @@ export declare const chapterInfoSchema: z.ZodObject<{
5
5
  arc: z.ZodString;
6
6
  episode: z.ZodNumber;
7
7
  chapter: z.ZodNumber;
8
- }, "strip", z.ZodTypeAny, {
9
- timeline: string;
10
- arc: string;
11
- episode: number;
12
- chapter: number;
13
- }, {
14
- timeline: string;
15
- arc: string;
16
- episode: number;
17
- chapter: number;
18
- }>;
8
+ }, z.core.$strip>;
19
9
  export declare function chapterInfo(args: z.infer<typeof chapterInfoSchema>, tracker: Tracker): Promise<{
20
10
  content: {
21
11
  type: "text";
@@ -12,31 +12,7 @@ export declare const chapterInsertSchema: z.ZodObject<{
12
12
  outfit: z.ZodOptional<z.ZodString>;
13
13
  kink: z.ZodOptional<z.ZodString>;
14
14
  file: z.ZodOptional<z.ZodString>;
15
- }, "strip", z.ZodTypeAny, {
16
- timeline: string;
17
- arc: string;
18
- episode: number;
19
- after: number;
20
- pov: string;
21
- title: string;
22
- file?: string | undefined;
23
- summary?: string | undefined;
24
- location?: string | undefined;
25
- outfit?: string | undefined;
26
- kink?: string | undefined;
27
- }, {
28
- timeline: string;
29
- arc: string;
30
- episode: number;
31
- after: number;
32
- pov: string;
33
- title: string;
34
- file?: string | undefined;
35
- summary?: string | undefined;
36
- location?: string | undefined;
37
- outfit?: string | undefined;
38
- kink?: string | undefined;
39
- }>;
15
+ }, z.core.$strip>;
40
16
  export declare function chapterInsert(args: z.infer<typeof chapterInsertSchema>, tracker: Tracker): Promise<{
41
17
  content: {
42
18
  type: "text";
@@ -3,13 +3,7 @@ import { z } from 'zod';
3
3
  export declare const chapterRefreshSchema: z.ZodObject<{
4
4
  timeline: z.ZodString;
5
5
  file: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- timeline: string;
8
- file: string;
9
- }, {
10
- timeline: string;
11
- file: string;
12
- }>;
6
+ }, z.core.$strip>;
13
7
  export declare function chapterRefresh(args: z.infer<typeof chapterRefreshSchema>, tracker: Tracker): Promise<{
14
8
  content: {
15
9
  type: "text";
@@ -4,15 +4,7 @@ export declare const episodeInfoSchema: z.ZodObject<{
4
4
  timeline: z.ZodString;
5
5
  arc: z.ZodString;
6
6
  episode: z.ZodNumber;
7
- }, "strip", z.ZodTypeAny, {
8
- timeline: string;
9
- arc: string;
10
- episode: number;
11
- }, {
12
- timeline: string;
13
- arc: string;
14
- episode: number;
15
- }>;
7
+ }, z.core.$strip>;
16
8
  export declare function episodeInfo(args: z.infer<typeof episodeInfoSchema>, tracker: Tracker): Promise<{
17
9
  content: {
18
10
  type: "text";
@@ -7,21 +7,7 @@ export declare const episodeUpdateSchema: z.ZodObject<{
7
7
  description: z.ZodOptional<z.ZodString>;
8
8
  title: z.ZodOptional<z.ZodString>;
9
9
  slug: z.ZodOptional<z.ZodString>;
10
- }, "strip", z.ZodTypeAny, {
11
- timeline: string;
12
- arc: string;
13
- episode: number;
14
- title?: string | undefined;
15
- description?: string | undefined;
16
- slug?: string | undefined;
17
- }, {
18
- timeline: string;
19
- arc: string;
20
- episode: number;
21
- title?: string | undefined;
22
- description?: string | undefined;
23
- slug?: string | undefined;
24
- }>;
10
+ }, z.core.$strip>;
25
11
  export declare function episodeUpdate(args: z.infer<typeof episodeUpdateSchema>, tracker: Tracker): Promise<{
26
12
  content: {
27
13
  type: "text";
@@ -3,13 +3,7 @@ import { z } from 'zod';
3
3
  export declare const ragCharactersSchema: z.ZodObject<{
4
4
  timeline: z.ZodString;
5
5
  character: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- timeline: string;
8
- character: string;
9
- }, {
10
- timeline: string;
11
- character: string;
12
- }>;
6
+ }, z.core.$strip>;
13
7
  export declare function ragCharacters(args: z.infer<typeof ragCharactersSchema>, rag: RAGSystem): Promise<{
14
8
  content: {
15
9
  type: "text";
@@ -6,22 +6,8 @@ export declare const ragContextSchema: z.ZodObject<{
6
6
  arc: z.ZodOptional<z.ZodString>;
7
7
  pov: z.ZodOptional<z.ZodString>;
8
8
  maxChapters: z.ZodOptional<z.ZodNumber>;
9
- characters: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
- }, "strip", z.ZodTypeAny, {
11
- timeline: string;
12
- query: string;
13
- arc?: string | undefined;
14
- pov?: string | undefined;
15
- characters?: string[] | undefined;
16
- maxChapters?: number | undefined;
17
- }, {
18
- timeline: string;
19
- query: string;
20
- arc?: string | undefined;
21
- pov?: string | undefined;
22
- characters?: string[] | undefined;
23
- maxChapters?: number | undefined;
24
- }>;
9
+ characters: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
+ }, z.core.$strip>;
25
11
  export declare function ragContext(args: z.infer<typeof ragContextSchema>, rag: RAGSystem): Promise<{
26
12
  content: {
27
13
  type: "text";
@@ -5,15 +5,7 @@ export declare const ragIndexSchema: z.ZodObject<{
5
5
  timeline: z.ZodString;
6
6
  arc: z.ZodOptional<z.ZodString>;
7
7
  episode: z.ZodOptional<z.ZodNumber>;
8
- }, "strip", z.ZodTypeAny, {
9
- timeline: string;
10
- arc?: string | undefined;
11
- episode?: number | undefined;
12
- }, {
13
- timeline: string;
14
- arc?: string | undefined;
15
- episode?: number | undefined;
16
- }>;
8
+ }, z.core.$strip>;
17
9
  type RagIndexArgs = z.infer<typeof ragIndexSchema> & {
18
10
  contentPath: string;
19
11
  };
@@ -6,25 +6,9 @@ export declare const ragSearchSchema: z.ZodObject<{
6
6
  arc: z.ZodOptional<z.ZodString>;
7
7
  pov: z.ZodOptional<z.ZodString>;
8
8
  maxResults: z.ZodOptional<z.ZodNumber>;
9
- characters: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9
+ characters: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
10
  allCharacters: z.ZodOptional<z.ZodBoolean>;
11
- }, "strip", z.ZodTypeAny, {
12
- timeline: string;
13
- query: string;
14
- arc?: string | undefined;
15
- pov?: string | undefined;
16
- characters?: string[] | undefined;
17
- maxResults?: number | undefined;
18
- allCharacters?: boolean | undefined;
19
- }, {
20
- timeline: string;
21
- query: string;
22
- arc?: string | undefined;
23
- pov?: string | undefined;
24
- characters?: string[] | undefined;
25
- maxResults?: number | undefined;
26
- allCharacters?: boolean | undefined;
27
- }>;
11
+ }, z.core.$strip>;
28
12
  export declare function ragSearch(args: z.infer<typeof ragSearchSchema>, rag: RAGSystem): Promise<{
29
13
  content: {
30
14
  type: "text";
@@ -5,17 +5,7 @@ export declare const statsSchema: z.ZodObject<{
5
5
  arc: z.ZodOptional<z.ZodString>;
6
6
  episode: z.ZodOptional<z.ZodNumber>;
7
7
  pov: z.ZodOptional<z.ZodString>;
8
- }, "strip", z.ZodTypeAny, {
9
- timeline: string;
10
- arc?: string | undefined;
11
- episode?: number | undefined;
12
- pov?: string | undefined;
13
- }, {
14
- timeline: string;
15
- arc?: string | undefined;
16
- episode?: number | undefined;
17
- pov?: string | undefined;
18
- }>;
8
+ }, z.core.$strip>;
19
9
  export declare function stats(args: z.infer<typeof statsSchema>, tracker: Tracker): Promise<{
20
10
  content: {
21
11
  type: "text";
@@ -2,11 +2,7 @@ import type { Tracker } from '@echoes-io/tracker';
2
2
  import { z } from 'zod';
3
3
  export declare const timelineSyncSchema: z.ZodObject<{
4
4
  timeline: z.ZodString;
5
- }, "strip", z.ZodTypeAny, {
6
- timeline: string;
7
- }, {
8
- timeline: string;
9
- }>;
5
+ }, z.core.$strip>;
10
6
  type TimelineSyncArgs = z.infer<typeof timelineSyncSchema> & {
11
7
  contentPath: string;
12
8
  };
@@ -1,11 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const wordsCountSchema: z.ZodObject<{
3
3
  file: z.ZodString;
4
- }, "strip", z.ZodTypeAny, {
5
- file: string;
6
- }, {
7
- file: string;
8
- }>;
4
+ }, z.core.$strip>;
9
5
  export declare function wordsCount(args: z.infer<typeof wordsCountSchema>): Promise<{
10
6
  content: {
11
7
  type: "text";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@echoes-io/mcp-server",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "1.8.0",
5
5
  "description": "Model Context Protocol server for AI integration with Echoes storytelling platform",
6
6
  "scripts": {
7
7
  "dev": "tsx cli/index.ts",
@@ -63,30 +63,30 @@
63
63
  ]
64
64
  },
65
65
  "devDependencies": {
66
- "@biomejs/biome": "^2.3.3",
66
+ "@biomejs/biome": "^2.3.8",
67
67
  "@semantic-release/changelog": "^6.0.3",
68
68
  "@semantic-release/git": "^10.0.1",
69
- "@tsconfig/node22": "^22.0.2",
70
- "@types/node": "^24.10.0",
71
- "@vitest/coverage-v8": "^4.0.6",
69
+ "@tsconfig/node22": "^22.0.5",
70
+ "@types/node": "^24.10.1",
71
+ "@vitest/coverage-v8": "^4.0.15",
72
72
  "concurrently": "^9.2.1",
73
73
  "husky": "^9.1.7",
74
- "lint-staged": "^16.2.5",
74
+ "lint-staged": "^16.2.7",
75
75
  "lockfile-lint": "^4.14.1",
76
76
  "ls-engines": "^0.9.3",
77
77
  "publint": "^0.3.15",
78
- "rimraf": "^6.1.0",
79
- "semantic-release": "^25.0.1",
80
- "tsx": "^4.19.2",
78
+ "rimraf": "^6.1.2",
79
+ "semantic-release": "^25.0.2",
80
+ "tsx": "^4.21.0",
81
81
  "typescript": "^5.9.3",
82
- "vitest": "^4.0.6"
82
+ "vitest": "^4.0.15"
83
83
  },
84
84
  "dependencies": {
85
- "@echoes-io/books-generator": "^1.0.1",
86
- "@echoes-io/models": "^1.0.3",
85
+ "@echoes-io/books-generator": "^1.1.0",
86
+ "@echoes-io/models": "^1.1.0",
87
87
  "@echoes-io/rag": "^1.2.0",
88
- "@echoes-io/tracker": "^1.0.1",
89
- "@echoes-io/utils": "^1.2.0",
90
- "@modelcontextprotocol/sdk": "^1.0.2"
88
+ "@echoes-io/tracker": "^1.1.0",
89
+ "@echoes-io/utils": "^1.3.0",
90
+ "@modelcontextprotocol/sdk": "^1.24.2"
91
91
  }
92
92
  }