@evolinkai/mcp 0.0.0-stage → 1.3.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.
Files changed (103) hide show
  1. package/LICENSE +178 -0
  2. package/README.md +67 -2
  3. package/dist/core/src/config.d.ts +19 -0
  4. package/dist/core/src/config.d.ts.map +1 -0
  5. package/dist/core/src/config.js +88 -0
  6. package/dist/core/src/config.js.map +1 -0
  7. package/dist/core/src/data/model-params.d.ts +49 -0
  8. package/dist/core/src/data/model-params.d.ts.map +1 -0
  9. package/dist/core/src/data/model-params.generated.d.ts +2 -0
  10. package/dist/core/src/data/model-params.generated.d.ts.map +1 -0
  11. package/dist/core/src/data/model-params.generated.js +3 -0
  12. package/dist/core/src/data/model-params.generated.js.map +1 -0
  13. package/dist/core/src/data/model-params.js +22 -0
  14. package/dist/core/src/data/model-params.js.map +1 -0
  15. package/dist/core/src/request-context.d.ts +60 -0
  16. package/dist/core/src/request-context.d.ts.map +1 -0
  17. package/dist/core/src/request-context.js +39 -0
  18. package/dist/core/src/request-context.js.map +1 -0
  19. package/dist/core/src/server.d.ts +18 -0
  20. package/dist/core/src/server.d.ts.map +1 -0
  21. package/dist/core/src/server.js +84 -0
  22. package/dist/core/src/server.js.map +1 -0
  23. package/dist/core/src/services/api-client.d.ts +129 -0
  24. package/dist/core/src/services/api-client.d.ts.map +1 -0
  25. package/dist/core/src/services/api-client.js +163 -0
  26. package/dist/core/src/services/api-client.js.map +1 -0
  27. package/dist/core/src/services/error-handler.d.ts +51 -0
  28. package/dist/core/src/services/error-handler.d.ts.map +1 -0
  29. package/dist/core/src/services/error-handler.js +390 -0
  30. package/dist/core/src/services/error-handler.js.map +1 -0
  31. package/dist/core/src/services/file-client.d.ts +24 -0
  32. package/dist/core/src/services/file-client.d.ts.map +1 -0
  33. package/dist/core/src/services/file-client.js +100 -0
  34. package/dist/core/src/services/file-client.js.map +1 -0
  35. package/dist/core/src/services/http-policy.d.ts +40 -0
  36. package/dist/core/src/services/http-policy.d.ts.map +1 -0
  37. package/dist/core/src/services/http-policy.js +120 -0
  38. package/dist/core/src/services/http-policy.js.map +1 -0
  39. package/dist/core/src/services/model-catalog.d.ts +24 -0
  40. package/dist/core/src/services/model-catalog.d.ts.map +1 -0
  41. package/dist/core/src/services/model-catalog.js +45 -0
  42. package/dist/core/src/services/model-catalog.js.map +1 -0
  43. package/dist/core/src/services/param-validator.d.ts +21 -0
  44. package/dist/core/src/services/param-validator.d.ts.map +1 -0
  45. package/dist/core/src/services/param-validator.js +164 -0
  46. package/dist/core/src/services/param-validator.js.map +1 -0
  47. package/dist/core/src/services/pricing-client.d.ts +77 -0
  48. package/dist/core/src/services/pricing-client.d.ts.map +1 -0
  49. package/dist/core/src/services/pricing-client.js +332 -0
  50. package/dist/core/src/services/pricing-client.js.map +1 -0
  51. package/dist/core/src/services/upload-policy.d.ts +17 -0
  52. package/dist/core/src/services/upload-policy.d.ts.map +1 -0
  53. package/dist/core/src/services/upload-policy.js +160 -0
  54. package/dist/core/src/services/upload-policy.js.map +1 -0
  55. package/dist/core/src/tools/check-balance.d.ts +4 -0
  56. package/dist/core/src/tools/check-balance.d.ts.map +1 -0
  57. package/dist/core/src/tools/check-balance.js +78 -0
  58. package/dist/core/src/tools/check-balance.js.map +1 -0
  59. package/dist/core/src/tools/estimate-cost.d.ts +4 -0
  60. package/dist/core/src/tools/estimate-cost.d.ts.map +1 -0
  61. package/dist/core/src/tools/estimate-cost.js +127 -0
  62. package/dist/core/src/tools/estimate-cost.js.map +1 -0
  63. package/dist/core/src/tools/generate.d.ts +4 -0
  64. package/dist/core/src/tools/generate.d.ts.map +1 -0
  65. package/dist/core/src/tools/generate.js +178 -0
  66. package/dist/core/src/tools/generate.js.map +1 -0
  67. package/dist/core/src/tools/get-model.d.ts +5 -0
  68. package/dist/core/src/tools/get-model.d.ts.map +1 -0
  69. package/dist/core/src/tools/get-model.js +109 -0
  70. package/dist/core/src/tools/get-model.js.map +1 -0
  71. package/dist/core/src/tools/get-task.d.ts +7 -0
  72. package/dist/core/src/tools/get-task.d.ts.map +1 -0
  73. package/dist/core/src/tools/get-task.js +55 -0
  74. package/dist/core/src/tools/get-task.js.map +1 -0
  75. package/dist/core/src/tools/list-tasks.d.ts +6 -0
  76. package/dist/core/src/tools/list-tasks.d.ts.map +1 -0
  77. package/dist/core/src/tools/list-tasks.js +142 -0
  78. package/dist/core/src/tools/list-tasks.js.map +1 -0
  79. package/dist/core/src/tools/search-models.d.ts +5 -0
  80. package/dist/core/src/tools/search-models.d.ts.map +1 -0
  81. package/dist/core/src/tools/search-models.js +96 -0
  82. package/dist/core/src/tools/search-models.js.map +1 -0
  83. package/dist/core/src/tools/shared.d.ts +50 -0
  84. package/dist/core/src/tools/shared.d.ts.map +1 -0
  85. package/dist/core/src/tools/shared.js +129 -0
  86. package/dist/core/src/tools/shared.js.map +1 -0
  87. package/dist/core/src/tools/task-format.d.ts +32 -0
  88. package/dist/core/src/tools/task-format.d.ts.map +1 -0
  89. package/dist/core/src/tools/task-format.js +138 -0
  90. package/dist/core/src/tools/task-format.js.map +1 -0
  91. package/dist/core/src/tools/upload-file.d.ts +7 -0
  92. package/dist/core/src/tools/upload-file.d.ts.map +1 -0
  93. package/dist/core/src/tools/upload-file.js +104 -0
  94. package/dist/core/src/tools/upload-file.js.map +1 -0
  95. package/dist/core/src/version.d.ts +3 -0
  96. package/dist/core/src/version.d.ts.map +1 -0
  97. package/dist/core/src/version.js +3 -0
  98. package/dist/core/src/version.js.map +1 -0
  99. package/dist/evolink-media/src/index.d.ts +3 -0
  100. package/dist/evolink-media/src/index.d.ts.map +1 -0
  101. package/dist/evolink-media/src/index.js +16 -0
  102. package/dist/evolink-media/src/index.js.map +1 -0
  103. package/package.json +46 -4
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ import { READ_ONLY, errorResult, ok, progressReporter } from './shared.js';
3
+ import { TERMINAL_STATUSES, describeTask, waitForTask } from './task-format.js';
4
+ export const TASK_ID = /^[A-Za-z0-9._:-]{4,128}$/;
5
+ /** Codex and Cursor drop a tool call after about 60 s; the reply also needs time to travel. */
6
+ export const MAX_WAIT_SECONDS = 45;
7
+ const REPLY_MARGIN_MS = 2_000;
8
+ const PROGRESS_EVERY_SECONDS = 10;
9
+ export function registerGetTask(server, config) {
10
+ server.registerTool('get_task', {
11
+ title: 'Get task status and results',
12
+ description: [
13
+ 'Check one generation task and, while it is still running, wait up to wait_seconds (max 45) for it to finish. Free.',
14
+ 'Returns the status, progress, result links (they expire after 24 hours, so give them to the user right away), the final charge, or the error with a next step.',
15
+ 'If the task is still running when this returns, call get_task again.',
16
+ 'Never call generate_image, generate_video or generate_audio again to check progress: that creates and charges a new task.',
17
+ ].join(' '),
18
+ inputSchema: {
19
+ task_id: z.string().regex(TASK_ID).describe('task_id returned by generate_image, generate_video or generate_audio'),
20
+ wait_seconds: z.number().int().min(0).max(MAX_WAIT_SECONDS).default(30)
21
+ .describe('How long this call may wait for the task to finish (0–45 s, default 30). Use 0 for a quick check.'),
22
+ },
23
+ annotations: { title: 'Get task status and results', ...READ_ONLY },
24
+ }, async ({ task_id, wait_seconds }, extra) => {
25
+ const started = Date.now();
26
+ const waitSeconds = Math.min(wait_seconds ?? 30, MAX_WAIT_SECONDS);
27
+ const report = progressReporter(extra, waitSeconds);
28
+ let lastReport = -PROGRESS_EVERY_SECONDS;
29
+ try {
30
+ const task = await waitForTask(config, task_id, {
31
+ deadline: started + waitSeconds * 1000 - REPLY_MARGIN_MS,
32
+ tool: 'get_task',
33
+ signal: extra.signal,
34
+ onPoll: async (current) => {
35
+ const elapsed = (Date.now() - started) / 1000;
36
+ if (elapsed - lastReport < PROGRESS_EVERY_SECONDS)
37
+ return;
38
+ lastReport = elapsed;
39
+ await report(elapsed, `${current.status}, ${current.progress ?? 0}%`);
40
+ },
41
+ });
42
+ const view = describeTask(task);
43
+ if (!TERMINAL_STATUSES.has(task.status) && waitSeconds > 0) {
44
+ const waited = Math.round((Date.now() - started) / 1000);
45
+ view.lines.splice(1, 0, `Still running after waiting ${waited} s.`);
46
+ view.structured.waited_seconds = waited;
47
+ }
48
+ return ok(view.lines.join('\n'), view.structured);
49
+ }
50
+ catch (error) {
51
+ return errorResult(error);
52
+ }
53
+ });
54
+ }
55
+ //# sourceMappingURL=get-task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-task.js","sourceRoot":"","sources":["../../../../../core/src/tools/get-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,UAAU,eAAe,CAAC,MAAiB,EAAE,MAAoB;IACrE,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE;QAC9B,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE;YACX,oHAAoH;YACpH,gKAAgK;YAChK,sEAAsE;YACtE,2HAA2H;SAC5H,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,sEAAsE,CAAC;YACnH,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;iBACpE,QAAQ,CAAC,mGAAmG,CAA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GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;gBACzD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,+BAA+B,MAAM,KAAK,CAAC,CAAC;gBACpE,IAAI,CAAC,UAAU,CAAC,cAAc,GAAG,MAAM,CAAC;YAC1C,CAAC;YACD,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { ServerConfig } from '../config.js';
3
+ /** ISO 8601, unix seconds, or relative such as 30m, 2h, 1d. */
4
+ export declare function parseSince(value: string, now?: number): number | undefined;
5
+ export declare function registerListTasks(server: McpServer, config: ServerConfig): void;
6
+ //# sourceMappingURL=list-tasks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-tasks.d.ts","sourceRoot":"","sources":["../../../../../core/src/tools/list-tasks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAQjD,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,MAAM,GAAG,SAAS,CAY9E;AAuCD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAmF/E"}
@@ -0,0 +1,142 @@
1
+ import { z } from 'zod';
2
+ import { listTasks, queryTasks } from '../services/api-client.js';
3
+ import { READ_ONLY, errorResult, failure, money, ok, usdOf } from './shared.js';
4
+ import { TASK_ID } from './get-task.js';
5
+ import { RESULT_LINK_HOURS, resultLinks } from './task-format.js';
6
+ const MAX_IDS = 50;
7
+ /** ISO 8601, unix seconds, or relative such as 30m, 2h, 1d. */
8
+ export function parseSince(value, now = Date.now()) {
9
+ const trimmed = value.trim();
10
+ const relative = /^(\d+)\s*(m|min|mins|minutes?|h|hours?|d|days?)$/i.exec(trimmed);
11
+ if (relative) {
12
+ const amount = Number(relative[1]);
13
+ const unit = relative[2][0].toLowerCase();
14
+ const factor = unit === 'm' ? 60_000 : unit === 'h' ? 3_600_000 : 86_400_000;
15
+ return now - amount * factor;
16
+ }
17
+ if (/^\d{9,11}$/.test(trimmed))
18
+ return Number(trimmed) * 1000;
19
+ const parsed = Date.parse(trimmed);
20
+ return Number.isFinite(parsed) ? parsed : undefined;
21
+ }
22
+ function rowFromTask(task) {
23
+ const row = { task_id: task.id, status: task.status, model: task.model, type: task.type, progress: task.progress };
24
+ if (task.created)
25
+ row.created_at = new Date(task.created * 1000).toISOString();
26
+ const links = resultLinks(task);
27
+ if (links.length > 0)
28
+ row.results = links;
29
+ const used = task.usage?.credits_used ?? task.usage?.cost?.credits;
30
+ if (task.status === 'completed' && typeof used === 'number') {
31
+ row.charged_credits = used;
32
+ row.charged_usd = task.usage?.cost?.usd ?? usdOf(used);
33
+ }
34
+ if (task.error?.code)
35
+ row.error_code = task.error.code;
36
+ return row;
37
+ }
38
+ function rowLine(row) {
39
+ const parts = [`- ${row.task_id}`, row.status === 'completed' || row.status === 'failed' ? row.status : `${row.status} ${row.progress ?? 0}%`, row.model];
40
+ if (row.created_at)
41
+ parts.push(row.created_at);
42
+ if (row.charged_credits !== undefined)
43
+ parts.push(`charged ${money(row.charged_credits)}`);
44
+ if (row.error_code)
45
+ parts.push(`error ${row.error_code}`);
46
+ const lines = [parts.join(' · ')];
47
+ for (const link of row.results ?? [])
48
+ lines.push(` ${link.kind}: ${link.url}`);
49
+ return lines.join('\n');
50
+ }
51
+ export function registerListTasks(server, config) {
52
+ server.registerTool('list_tasks', {
53
+ title: 'List generation tasks',
54
+ description: [
55
+ 'Read several tasks at once by task_ids (up to 50, with result links), or find recent tasks by status, type and since. Free.',
56
+ 'Use it to recover tasks after a lost connection or a timed-out submit before submitting anything again.',
57
+ 'Recent tasks cover the whole EvoLink account, newest first.',
58
+ ].join(' '),
59
+ inputSchema: {
60
+ task_ids: z.array(z.string().regex(TASK_ID)).min(1).max(MAX_IDS).optional()
61
+ .describe('Task IDs to read in one call (max 50).'),
62
+ status: z.enum(['processing', 'completed', 'failed', 'cancelled']).optional()
63
+ .describe('Without task_ids: only tasks in this state ("processing" includes queued tasks).'),
64
+ type: z.enum(['image', 'video', 'audio']).optional()
65
+ .describe('Without task_ids: only this kind of task.'),
66
+ since: z.string().max(40).optional()
67
+ .describe('Without task_ids: only tasks created after this time, as ISO 8601 (2026-10-05T08:00:00Z) or relative (30m, 2h, 1d).'),
68
+ limit: z.number().int().min(1).max(MAX_IDS).default(20)
69
+ .describe('Without task_ids: how many recent tasks to return (1–50, default 20).'),
70
+ },
71
+ annotations: { title: 'List generation tasks', ...READ_ONLY },
72
+ }, async ({ task_ids, status, type, since, limit }) => {
73
+ try {
74
+ if (task_ids && task_ids.length > 0) {
75
+ const unique = [...new Set(task_ids)];
76
+ const tasks = await queryTasks(config, unique);
77
+ const rows = tasks.map(rowFromTask);
78
+ const found = new Set(rows.map(row => row.task_id));
79
+ const missing = unique.filter(id => !found.has(id));
80
+ const lines = [`${rows.length} of ${unique.length} tasks found.`, ...rows.map(rowLine)];
81
+ if (missing.length > 0)
82
+ lines.push(`Not found (wrong ID, expired, or another account): ${missing.join(', ')}`);
83
+ if (rows.some(row => row.results))
84
+ lines.push(`Result links expire after ${RESULT_LINK_HOURS} hours.`);
85
+ return ok(lines.join('\n'), { tasks: rows, missing });
86
+ }
87
+ let sinceMs;
88
+ if (since) {
89
+ sinceMs = parseSince(since);
90
+ if (sinceMs === undefined) {
91
+ return failure(`since "${since}" is not a time. Use ISO 8601 (2026-10-05T08:00:00Z) or a relative value such as 30m, 2h or 1d.`, {
92
+ error: { category: 'invalid_request', param: 'since' },
93
+ });
94
+ }
95
+ }
96
+ const pageSize = limit ?? 20;
97
+ const page = await listTasks(config, { status, type, pageSize });
98
+ let items = page.data;
99
+ if (sinceMs !== undefined)
100
+ items = items.filter(item => item.created_at * 1000 >= sinceMs);
101
+ // The list endpoint omits result links; read finished tasks in one batch to include them.
102
+ const finished = items.filter(item => item.status === 'completed' && item.has_results).map(item => item.id).slice(0, MAX_IDS);
103
+ const details = new Map();
104
+ if (finished.length > 0) {
105
+ for (const task of await queryTasks(config, finished))
106
+ details.set(task.id, task);
107
+ }
108
+ const rows = items.map(item => {
109
+ const detailed = details.get(item.id);
110
+ if (detailed)
111
+ return rowFromTask(detailed);
112
+ const row = {
113
+ task_id: item.id,
114
+ status: item.status,
115
+ model: item.model,
116
+ type: item.type,
117
+ progress: item.progress,
118
+ created_at: new Date(item.created_at * 1000).toISOString(),
119
+ };
120
+ if (typeof item.credits_used === 'number' && item.status === 'completed') {
121
+ row.charged_credits = item.credits_used;
122
+ row.charged_usd = usdOf(item.credits_used);
123
+ }
124
+ if (item.has_error)
125
+ row.error_code = 'failed';
126
+ return row;
127
+ });
128
+ const filters = [status && `status ${status}`, type && `type ${type}`, since && `since ${since}`].filter(Boolean).join(', ');
129
+ const lines = [`${rows.length} recent task${rows.length === 1 ? '' : 's'} on this account${filters ? ` (${filters})` : ''}, newest first:`];
130
+ lines.push(...(rows.length > 0 ? rows.map(rowLine) : ['(none)']));
131
+ if (page.total > page.data.length)
132
+ lines.push(`${page.total} tasks match in total; raise limit or narrow the filters to see others.`);
133
+ if (rows.some(row => row.results))
134
+ lines.push(`Result links expire after ${RESULT_LINK_HOURS} hours.`);
135
+ return ok(lines.join('\n'), { tasks: rows, total: page.total });
136
+ }
137
+ catch (error) {
138
+ return errorResult(error);
139
+ }
140
+ });
141
+ }
142
+ //# sourceMappingURL=list-tasks.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C;YACtI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,6BAA6B,iBAAiB,SAAS,CAAC,CAAC;YACvG,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { type CatalogEntry } from '../services/model-catalog.js';
3
+ export declare function modelTitle(entry: CatalogEntry): string | undefined;
4
+ export declare function registerSearchModels(server: McpServer): void;
5
+ //# sourceMappingURL=search-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-models.d.ts","sourceRoot":"","sources":["../../../../../core/src/tools/search-models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAI9E,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAGlE;AAqBD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAyD5D"}
@@ -0,0 +1,96 @@
1
+ import { z } from 'zod';
2
+ import { loadCatalog } from '../services/model-catalog.js';
3
+ import { formatPrice, startingPrice } from '../services/pricing-client.js';
4
+ import { READ_ONLY, errorResult, ok } from './shared.js';
5
+ export function modelTitle(entry) {
6
+ const title = entry.spec?.title?.replace(/\s+(interface|api)$/i, '').trim();
7
+ return title || entry.priced?.description?.slice(0, 120) || undefined;
8
+ }
9
+ /** Every term must appear somewhere; matches in the model ID count most. */
10
+ function score(entry, terms) {
11
+ if (terms.length === 0)
12
+ return 0;
13
+ const id = entry.id.toLowerCase();
14
+ const haystack = [id, modelTitle(entry), entry.priced?.description, entry.priced?.vendor, entry.kind]
15
+ .filter(Boolean)
16
+ .join(' ')
17
+ .toLowerCase();
18
+ let total = 0;
19
+ for (const term of terms) {
20
+ if (id === term)
21
+ total += 10;
22
+ else if (id.startsWith(term))
23
+ total += 6;
24
+ else if (id.includes(term))
25
+ total += 4;
26
+ else if (haystack.includes(term))
27
+ total += 1;
28
+ else
29
+ return undefined;
30
+ }
31
+ return total;
32
+ }
33
+ export function registerSearchModels(server) {
34
+ server.registerTool('search_models', {
35
+ title: 'Search models',
36
+ description: [
37
+ 'Find EvoLink image, video and audio models by type and keywords. Free.',
38
+ 'Returns model IDs with a starting price; call get_model for a model\'s parameters and full pricing before generating.',
39
+ 'Prices are in USD (68 credits ≈ $1).',
40
+ ].join(' '),
41
+ inputSchema: {
42
+ type: z.enum(['image', 'video', 'audio', 'all']).default('all').describe('Kind of output to look for.'),
43
+ query: z.string().max(100).optional().describe('Keywords, e.g. "seedance", "image-to-video", "kling", "music".'),
44
+ limit: z.number().int().min(1).max(50).default(20).describe('Maximum number of models to return (1–50, default 20).'),
45
+ },
46
+ annotations: { title: 'Search models', ...READ_ONLY },
47
+ }, async ({ type, query, limit }) => {
48
+ try {
49
+ const catalog = await loadCatalog();
50
+ const terms = (query ?? '').toLowerCase().split(/[\s,]+/).filter(Boolean);
51
+ const matches = catalog.entries
52
+ .filter(entry => type === 'all' || entry.kind === type)
53
+ .map(entry => ({ entry, score: score(entry, terms), start: entry.priced ? startingPrice(entry.priced) : undefined }))
54
+ .filter((item) => item.score !== undefined)
55
+ .sort((a, b) => b.score - a.score || Number(!!b.start) - Number(!!a.start) || a.entry.id.localeCompare(b.entry.id));
56
+ const shown = matches.slice(0, limit ?? 20);
57
+ const models = shown.map(({ entry, start }) => ({
58
+ id: entry.id,
59
+ type: entry.kind,
60
+ title: modelTitle(entry),
61
+ from_usd: start?.min_usd,
62
+ from_unit: start?.unit,
63
+ parameters_documented: !!entry.spec,
64
+ docs: entry.spec?.docs,
65
+ }));
66
+ const lines = [
67
+ `${matches.length} model${matches.length === 1 ? '' : 's'} match${terms.length ? ` "${query}"` : ''}${type !== 'all' ? ` (${type})` : ''}${matches.length > shown.length ? `; showing ${shown.length}` : ''}:`,
68
+ ...shown.map(({ entry, start }) => {
69
+ const parts = [`- ${entry.id} [${entry.kind}]`];
70
+ const title = modelTitle(entry);
71
+ if (title)
72
+ parts.push(title);
73
+ parts.push(start ? `from ${formatPrice(start)}` : 'price not published');
74
+ if (!entry.spec)
75
+ parts.push('parameters not documented');
76
+ return parts.join(' · ');
77
+ }),
78
+ ];
79
+ if (matches.length === 0)
80
+ lines.push('No model matched. Try fewer or broader keywords, or type "all".');
81
+ else
82
+ lines.push('', 'Next: get_model with one of these IDs for its parameters and pricing.');
83
+ if (catalog.pricingWarning)
84
+ lines.push(`Note: ${catalog.pricingWarning}`);
85
+ return ok(lines.join('\n'), {
86
+ models,
87
+ total_matches: matches.length,
88
+ ...(catalog.pricingWarning ? { pricing_warning: catalog.pricingWarning } : {}),
89
+ });
90
+ }
91
+ catch (error) {
92
+ return errorResult(error);
93
+ }
94
+ });
95
+ }
96
+ //# sourceMappingURL=search-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-models.js","sourceRoot":"","sources":["../../../../../core/src/tools/search-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAqB,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,UAAU,UAAU,CAAC,KAAmB;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AC,MAAM;gBAC7B,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC/E,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
2
+ import type { CallToolResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
3
+ import { type CreditsResponse } from '../services/api-client.js';
4
+ export type ToolExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
5
+ /** Free lookups: clients can run them without asking. */
6
+ export declare const READ_ONLY: {
7
+ readonly readOnlyHint: true;
8
+ readonly destructiveHint: false;
9
+ readonly idempotentHint: true;
10
+ readonly openWorldHint: false;
11
+ };
12
+ /** Spends the user's balance and cannot be undone: clients ask before running it. */
13
+ export declare const PAID: {
14
+ readonly readOnlyHint: false;
15
+ readonly destructiveHint: true;
16
+ readonly idempotentHint: false;
17
+ readonly openWorldHint: false;
18
+ };
19
+ /** Changes stored state without spending money (uploads). */
20
+ export declare const WRITES: {
21
+ readonly readOnlyHint: false;
22
+ readonly destructiveHint: false;
23
+ readonly idempotentHint: false;
24
+ readonly openWorldHint: false;
25
+ };
26
+ /** Text and structured content carry the same facts: some clients show the model only one of them. */
27
+ export declare function ok(text: string, structured: Record<string, unknown>): CallToolResult;
28
+ export declare function failure(text: string, structured: Record<string, unknown>): CallToolResult;
29
+ export declare function money(credits: number | undefined): string | undefined;
30
+ export interface DailyLimit {
31
+ used: number;
32
+ limit: number;
33
+ left: number;
34
+ zone?: string;
35
+ }
36
+ /** The calling key's daily limit, when the gateway reports one (none means no daily limit is set). */
37
+ export declare function dailyLimitOf(token: CreditsResponse['token']): DailyLimit | undefined;
38
+ export declare function usdOf(credits: number | undefined): number | undefined;
39
+ export interface ErrorContext {
40
+ /** The call may have created a paid task. */
41
+ paid?: boolean;
42
+ /** Idempotency key the paid call used; repeating it cannot create a second task once the gateway ledger is live. */
43
+ clientRequestId?: string;
44
+ }
45
+ /** Converts a thrown error into a tool error with a category and a concrete next step. */
46
+ export declare function errorResult(error: unknown, context?: ErrorContext): CallToolResult;
47
+ /** Sends a progress notification when the client asked for them; failures are ignored. */
48
+ export declare function progressReporter(extra: ToolExtra | undefined, totalSeconds: number): (elapsedSeconds: number, message: string) => Promise<void>;
49
+ export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
50
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../core/src/tools/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAE5G,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI/E,MAAM,MAAM,SAAS,GAAG,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAE/E,yDAAyD;AACzD,eAAO,MAAM,SAAS;;;;;CAAsG,CAAC;AAC7H,qFAAqF;AACrF,eAAO,MAAM,IAAI;;;;;CAAuG,CAAC;AACzH,6DAA6D;AAC7D,eAAO,MAAM,MAAM;;;;;CAAwG,CAAC;AAE5H,sGAAsG;AACtG,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAEpF;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAEzF;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGrE;AAED,MAAM,WAAW,UAAU;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;AAExF,sGAAsG;AACtG,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,UAAU,GAAG,SAAS,CAOpF;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGrE;AAED,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oHAAoH;IACpH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAiCD,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,cAAc,CAyBtF;AAED,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAY/I;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrE"}
@@ -0,0 +1,129 @@
1
+ import { processCredentialsAllowed } from '../request-context.js';
2
+ import { ApiHttpError } from '../services/api-client.js';
3
+ import { CREDITS_PER_USD, formatCredits, formatUsd } from '../services/error-handler.js';
4
+ import { PaidRequestOutcomeUnknownError, RequestTimeoutError } from '../services/http-policy.js';
5
+ /** Free lookups: clients can run them without asking. */
6
+ export const READ_ONLY = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
7
+ /** Spends the user's balance and cannot be undone: clients ask before running it. */
8
+ export const PAID = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
9
+ /** Changes stored state without spending money (uploads). */
10
+ export const WRITES = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
11
+ /** Text and structured content carry the same facts: some clients show the model only one of them. */
12
+ export function ok(text, structured) {
13
+ return { content: [{ type: 'text', text }], structuredContent: { ok: true, ...structured } };
14
+ }
15
+ export function failure(text, structured) {
16
+ return { content: [{ type: 'text', text }], structuredContent: { ok: false, ...structured }, isError: true };
17
+ }
18
+ export function money(credits) {
19
+ if (typeof credits !== 'number' || !Number.isFinite(credits))
20
+ return undefined;
21
+ return `${formatCredits(credits)} credits (≈$${formatUsd(credits / CREDITS_PER_USD)})`;
22
+ }
23
+ /** The calling key's daily limit, when the gateway reports one (none means no daily limit is set). */
24
+ export function dailyLimitOf(token) {
25
+ const limit = token.daily_limit_credits;
26
+ if (typeof limit !== 'number' || !Number.isFinite(limit) || limit <= 0)
27
+ return undefined;
28
+ const raw = token.daily_used_credits;
29
+ const used = typeof raw === 'number' && Number.isFinite(raw) ? Math.max(0, raw) : 0;
30
+ const zone = typeof token.reset_timezone === 'string' && token.reset_timezone.trim() ? token.reset_timezone.trim() : undefined;
31
+ return { used, limit, left: Math.max(0, limit - used), zone };
32
+ }
33
+ export function usdOf(credits) {
34
+ if (typeof credits !== 'number' || !Number.isFinite(credits))
35
+ return undefined;
36
+ return Number((credits / CREDITS_PER_USD).toFixed(6));
37
+ }
38
+ function infoFor(error) {
39
+ if (error instanceof ApiHttpError && error.info)
40
+ return error.info;
41
+ if (error instanceof ApiHttpError) {
42
+ return { status: error.status, category: 'server_error', message: error.message, next_step: 'Retry in a minute.', retryable: true, request_id: error.requestId };
43
+ }
44
+ if (error instanceof PaidRequestOutcomeUnknownError) {
45
+ return {
46
+ status: 0,
47
+ category: 'outcome_unknown',
48
+ message: 'The submission timed out or the connection dropped, so it is unknown whether a task was created.',
49
+ next_step: 'Do not submit again with a new client_request_id. Look for the task with list_tasks (status processing), or retry with the same client_request_id.',
50
+ retryable: true,
51
+ };
52
+ }
53
+ if (error instanceof RequestTimeoutError || error instanceof TypeError) {
54
+ return { status: 0, category: 'server_error', message: 'EvoLink did not respond in time.', next_step: 'Retry in a minute.', retryable: true };
55
+ }
56
+ const message = error instanceof Error ? error.message : 'Unknown error';
57
+ // Credential problems surface as plain errors from getApiKey(): no key in this scope, or a
58
+ // signed-in connection that cannot use the hosted service channel.
59
+ return {
60
+ status: 0,
61
+ category: 'unauthorized',
62
+ message,
63
+ next_step: processCredentialsAllowed()
64
+ ? 'Set EVOLINK_API_KEY (create a key at https://evolink.ai/dashboard/keys), or run `evolink login`.'
65
+ : 'Ask the user to reconnect EvoLink in this client. If it keeps failing, retry in a few minutes.',
66
+ retryable: false,
67
+ };
68
+ }
69
+ /** Converts a thrown error into a tool error with a category and a concrete next step. */
70
+ export function errorResult(error, context = {}) {
71
+ const info = infoFor(error);
72
+ const label = `${info.category}${info.code ? `, ${info.code}` : ''}${info.status ? `, HTTP ${info.status}` : ''}`;
73
+ // A headline names the limit in plain words first, so every client shows the user which one stopped the call.
74
+ const lines = info.headline ? [info.headline] : [`Error (${label}): ${info.message}`];
75
+ lines.push(`Next step: ${info.next_step}`);
76
+ let charged;
77
+ if (context.paid) {
78
+ if (info.category === 'outcome_unknown' || info.category === 'server_error') {
79
+ charged = 'unknown';
80
+ lines.push(context.clientRequestId
81
+ ? `It is unclear whether a task was created. To retry this exact request safely, pass client_request_id "${context.clientRequestId}".`
82
+ : 'It is unclear whether a task was created; check list_tasks before submitting again.');
83
+ }
84
+ else {
85
+ charged = 'no';
86
+ lines.push('Nothing was submitted or charged.');
87
+ }
88
+ }
89
+ if (info.headline)
90
+ lines.push(`Error: ${label}`);
91
+ if (info.request_id)
92
+ lines.push(`Request ID: ${info.request_id}`);
93
+ return failure(lines.join('\n'), {
94
+ error: info,
95
+ ...(charged ? { charged } : {}),
96
+ ...(context.clientRequestId && charged === 'unknown' ? { client_request_id: context.clientRequestId } : {}),
97
+ });
98
+ }
99
+ /** Sends a progress notification when the client asked for them; failures are ignored. */
100
+ export function progressReporter(extra, totalSeconds) {
101
+ const token = extra?._meta?.progressToken;
102
+ let last = -1;
103
+ return async (elapsedSeconds, message) => {
104
+ if (token === undefined || !extra)
105
+ return;
106
+ const progress = Math.max(last + 1, Math.round(elapsedSeconds));
107
+ last = progress;
108
+ await extra.sendNotification({
109
+ method: 'notifications/progress',
110
+ params: { progressToken: token, progress, total: Math.max(totalSeconds, progress), message },
111
+ }).catch(() => undefined);
112
+ };
113
+ }
114
+ export function sleep(ms, signal) {
115
+ return new Promise(resolve => {
116
+ if (signal?.aborted) {
117
+ resolve();
118
+ return;
119
+ }
120
+ const timer = setTimeout(done, ms);
121
+ function done() {
122
+ clearTimeout(timer);
123
+ signal?.removeEventListener('abort', done);
124
+ resolve();
125
+ }
126
+ signal?.addEventListener('abort', done, { once: true });
127
+ });
128
+ }
129
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../core/src/tools/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAwB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAyB,MAAM,8BAA8B,CAAC;AAChH,OAAO,EAAE,8BAA8B,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjG,yDAAyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAW,CAAC;AAC7H,qFAAqF;AACrF,MAAM,CAAC,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AE,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { ServerConfig } from '../config.js';
2
+ import { type TaskResponse } from '../services/api-client.js';
3
+ /** Result links from the gateway stay downloadable for this long. */
4
+ export declare const RESULT_LINK_HOURS = 24;
5
+ export declare const TERMINAL_STATUSES: Set<string>;
6
+ export interface TaskResultLink {
7
+ url: string;
8
+ kind: 'image' | 'video' | 'audio' | 'file';
9
+ }
10
+ export declare function resultLinks(task: TaskResponse): TaskResultLink[];
11
+ export interface TaskView {
12
+ lines: string[];
13
+ structured: Record<string, unknown>;
14
+ }
15
+ /** One task as text lines and the same facts as structured content. */
16
+ export declare function describeTask(task: TaskResponse): TaskView;
17
+ /** Tests only: shorten the pause between task reads. */
18
+ export declare function setPollIntervalForTests(ms: number | undefined): void;
19
+ /** Pause between task reads: each read of an unfinished task makes the gateway ask the provider. */
20
+ export declare function pollIntervalMs(type: string | undefined): number;
21
+ export interface WaitOptions {
22
+ /** Absolute time (ms) by which to return, finished or not. */
23
+ deadline: number;
24
+ tool: string;
25
+ signal?: AbortSignal;
26
+ onPoll?: (task: TaskResponse) => Promise<void>;
27
+ /** A task already read by the caller; the first read is skipped when given. */
28
+ initial?: TaskResponse;
29
+ }
30
+ /** Reads a task until it finishes or the deadline passes, pacing reads by task type. */
31
+ export declare function waitForTask(config: ServerConfig, taskId: string, options: WaitOptions): Promise<TaskResponse>;
32
+ //# sourceMappingURL=task-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-format.d.ts","sourceRoot":"","sources":["../../../../../core/src/tools/task-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9F,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,iBAAiB,aAAgD,CAAC;A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