@efectoapp/mcp-server 0.1.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 +244 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/discovery.d.ts +21 -0
- package/dist/tools/discovery.d.ts.map +1 -0
- package/dist/tools/discovery.js +141 -0
- package/dist/tools/discovery.js.map +1 -0
- package/dist/tools/images.d.ts +20 -0
- package/dist/tools/images.d.ts.map +1 -0
- package/dist/tools/images.js +143 -0
- package/dist/tools/images.js.map +1 -0
- package/dist/tools/output.d.ts +21 -0
- package/dist/tools/output.d.ts.map +1 -0
- package/dist/tools/output.js +287 -0
- package/dist/tools/output.js.map +1 -0
- package/dist/tools/state.d.ts +122 -0
- package/dist/tools/state.d.ts.map +1 -0
- package/dist/tools/state.js +943 -0
- package/dist/tools/state.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Image Tools
|
|
4
|
+
*
|
|
5
|
+
* Tools for searching and discovering images:
|
|
6
|
+
* - search_images: Search for free stock images from Lummi
|
|
7
|
+
*
|
|
8
|
+
* These tools call the Efecto REST API endpoints.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.imageTools = void 0;
|
|
12
|
+
exports.handleImageTool = handleImageTool;
|
|
13
|
+
// Default API base URL (can be overridden via environment variable)
|
|
14
|
+
const API_BASE_URL = process.env.EFECTO_API_URL || 'https://efecto.app';
|
|
15
|
+
// Tool definitions
|
|
16
|
+
exports.imageTools = [
|
|
17
|
+
{
|
|
18
|
+
name: 'search_images',
|
|
19
|
+
description: 'Search for free stock images from Lummi. Returns images that can be used as backgrounds or in image layers. Use orientation "vertical" for portrait/story format (9:16), "horizontal" for landscape (16:9), or "square" for 1:1.',
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
query: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Search query (e.g., "cyberpunk", "nature", "abstract"). Leave empty for featured images.',
|
|
26
|
+
},
|
|
27
|
+
orientation: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
enum: ['square', 'horizontal', 'vertical'],
|
|
30
|
+
description: 'Image orientation: "vertical" for portrait/Instagram stories, "horizontal" for landscape, "square" for 1:1',
|
|
31
|
+
},
|
|
32
|
+
type: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
enum: ['photo', 'illustration', '3d'],
|
|
35
|
+
description: 'Image type: "photo" for photographs, "illustration" for artwork, "3d" for 3D renders',
|
|
36
|
+
},
|
|
37
|
+
luminance: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
enum: ['dark', 'neutral', 'bright'],
|
|
40
|
+
description: 'Image brightness: "dark" for moody/dark images, "bright" for light images',
|
|
41
|
+
},
|
|
42
|
+
limit: {
|
|
43
|
+
type: 'number',
|
|
44
|
+
description: 'Maximum number of images to return (default: 10, max: 50)',
|
|
45
|
+
default: 10,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: [],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Handle image tool calls
|
|
54
|
+
*/
|
|
55
|
+
async function handleImageTool(name, args) {
|
|
56
|
+
const params = args || {};
|
|
57
|
+
switch (name) {
|
|
58
|
+
case 'search_images': {
|
|
59
|
+
const query = params.query || '';
|
|
60
|
+
const orientation = params.orientation;
|
|
61
|
+
const imageType = params.type;
|
|
62
|
+
const luminance = params.luminance;
|
|
63
|
+
const limit = Math.min(50, Math.max(1, params.limit || 10));
|
|
64
|
+
try {
|
|
65
|
+
// Build URL with query parameters
|
|
66
|
+
const url = new URL(`${API_BASE_URL}/api/v1/images/search`);
|
|
67
|
+
if (query)
|
|
68
|
+
url.searchParams.set('q', query);
|
|
69
|
+
if (orientation)
|
|
70
|
+
url.searchParams.set('orientation', orientation);
|
|
71
|
+
if (imageType)
|
|
72
|
+
url.searchParams.set('type', imageType);
|
|
73
|
+
if (luminance)
|
|
74
|
+
url.searchParams.set('luminance', luminance);
|
|
75
|
+
url.searchParams.set('limit', limit.toString());
|
|
76
|
+
const response = await fetch(url.toString());
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const errorText = await response.text();
|
|
79
|
+
return {
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: JSON.stringify({
|
|
84
|
+
success: false,
|
|
85
|
+
error: `API error: ${response.status}`,
|
|
86
|
+
details: errorText,
|
|
87
|
+
}, null, 2),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const result = (await response.json());
|
|
93
|
+
// Format images for easy consumption
|
|
94
|
+
const images = result.images.map((img) => ({
|
|
95
|
+
id: img.id,
|
|
96
|
+
url: img.url, // Full resolution URL - use this for set_background
|
|
97
|
+
thumbnail: img.thumbnail,
|
|
98
|
+
width: img.width,
|
|
99
|
+
height: img.height,
|
|
100
|
+
alt: img.alt,
|
|
101
|
+
photographer: img.photographer,
|
|
102
|
+
orientation: img.orientation,
|
|
103
|
+
type: img.type,
|
|
104
|
+
}));
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: 'text',
|
|
109
|
+
text: JSON.stringify({
|
|
110
|
+
success: true,
|
|
111
|
+
query: query || '(featured)',
|
|
112
|
+
count: images.length,
|
|
113
|
+
total: result.total,
|
|
114
|
+
hasMore: result.hasMore,
|
|
115
|
+
images,
|
|
116
|
+
usage: 'Use the "url" field with set_background({ type: "image", imageUrl: "<url>" }) to set as background.',
|
|
117
|
+
}, null, 2),
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
return {
|
|
124
|
+
content: [
|
|
125
|
+
{
|
|
126
|
+
type: 'text',
|
|
127
|
+
text: JSON.stringify({
|
|
128
|
+
success: false,
|
|
129
|
+
error: 'Failed to search images',
|
|
130
|
+
details: error instanceof Error ? error.message : String(error),
|
|
131
|
+
}, null, 2),
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
default:
|
|
138
|
+
return {
|
|
139
|
+
content: [{ type: 'text', text: `Unknown image tool: ${name}` }],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../src/tools/images.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAmDH,0CAwHC;AAvKD,oEAAoE;AACpE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,oBAAoB,CAAA;AAEvE,mBAAmB;AACN,QAAA,UAAU,GAAW;IAChC;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,kOAAkO;QACpO,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,0FAA0F;iBAC7F;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC;oBAC1C,WAAW,EACT,4GAA4G;iBAC/G;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC;oBACrC,WAAW,EAAE,sFAAsF;iBACpG;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MA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CAClB;gCACE,OAAO,EAAE,IAAI;gCACb,KAAK,EAAE,KAAK,IAAI,YAAY;gCAC5B,KAAK,EAAE,MAAM,CAAC,MAAM;gCACpB,KAAK,EAAE,MAAM,CAAC,KAAK;gCACnB,OAAO,EAAE,MAAM,CAAC,OAAO;gCACvB,MAAM;gCACN,KAAK,EACH,qGAAqG;6BACxG,EACD,IAAI,EACJ,CAAC,CACF;yBACF;qBACF;iBACF,CAAA;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;gCACE,OAAO,EAAE,KAAK;gCACd,KAAK,EAAE,yBAAyB;gCAChC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;6BAChE,EACD,IAAI,EACJ,CAAC,CACF;yBACF;qBACF;iBACF,CAAA;YACH,CAAC;QACH,CAAC;QAED;YACE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,IAAI,EAAE,EAAE,CAAC;aACjE,CAAA;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for generating outputs from the poster state:
|
|
5
|
+
* - generate_url: Generate a shareable URL via REST API
|
|
6
|
+
* - render_image: Render the poster to an image via REST API
|
|
7
|
+
*
|
|
8
|
+
* These tools call the Efecto REST API endpoints to produce actual outputs.
|
|
9
|
+
*/
|
|
10
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
11
|
+
export declare const outputTools: Tool[];
|
|
12
|
+
/**
|
|
13
|
+
* Handle output tool calls
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleOutputTool(name: string, args: Record<string, unknown> | undefined): Promise<{
|
|
16
|
+
content: Array<{
|
|
17
|
+
type: string;
|
|
18
|
+
text: string;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/tools/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAO9D,eAAO,MAAM,WAAW,EAAE,IAAI,EAkD7B,CAAA;AA8CD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACxC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAwN7D"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Output Tools
|
|
4
|
+
*
|
|
5
|
+
* Tools for generating outputs from the poster state:
|
|
6
|
+
* - generate_url: Generate a shareable URL via REST API
|
|
7
|
+
* - render_image: Render the poster to an image via REST API
|
|
8
|
+
*
|
|
9
|
+
* These tools call the Efecto REST API endpoints to produce actual outputs.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.outputTools = void 0;
|
|
13
|
+
exports.handleOutputTool = handleOutputTool;
|
|
14
|
+
const state_js_1 = require("./state.js");
|
|
15
|
+
// Default API base URL (can be overridden via environment variable)
|
|
16
|
+
const API_BASE_URL = process.env.EFECTO_API_URL || 'https://efecto.app';
|
|
17
|
+
// Tool definitions
|
|
18
|
+
exports.outputTools = [
|
|
19
|
+
{
|
|
20
|
+
name: 'generate_url',
|
|
21
|
+
description: 'Generate a shareable URL for the current poster. Returns a URL that can be opened in a browser to view the poster.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
baseUrl: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Base URL for the generated link (default: https://efecto.app)',
|
|
28
|
+
default: 'https://efecto.app',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: [],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'render_image',
|
|
36
|
+
description: 'Render the current poster to an image. Returns the image URL or base64 data.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
format: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
enum: ['png', 'jpeg', 'webp'],
|
|
43
|
+
description: 'Output image format',
|
|
44
|
+
default: 'png',
|
|
45
|
+
},
|
|
46
|
+
width: {
|
|
47
|
+
type: 'number',
|
|
48
|
+
description: 'Output width in pixels (default based on aspect ratio)',
|
|
49
|
+
},
|
|
50
|
+
height: {
|
|
51
|
+
type: 'number',
|
|
52
|
+
description: 'Output height in pixels (default based on aspect ratio)',
|
|
53
|
+
},
|
|
54
|
+
quality: {
|
|
55
|
+
type: 'number',
|
|
56
|
+
description: 'JPEG/WebP quality (1-100)',
|
|
57
|
+
default: 90,
|
|
58
|
+
},
|
|
59
|
+
async: {
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
description: 'Use async rendering for large images (returns a job ID to poll)',
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: [],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* Convert internal poster state to LayerShareState format for API
|
|
71
|
+
*/
|
|
72
|
+
function convertToLayerShareState(poster) {
|
|
73
|
+
if (!poster)
|
|
74
|
+
return null;
|
|
75
|
+
// Build the state object matching LayerShareState
|
|
76
|
+
const state = {
|
|
77
|
+
canvas: poster.canvas,
|
|
78
|
+
layers: poster.layers,
|
|
79
|
+
};
|
|
80
|
+
// Add effect if present
|
|
81
|
+
if (poster.effect) {
|
|
82
|
+
state.effect = poster.effect;
|
|
83
|
+
}
|
|
84
|
+
// Add post-processes if present
|
|
85
|
+
if (poster.postProcesses && poster.postProcesses.length > 0) {
|
|
86
|
+
state.postProcesses = poster.postProcesses;
|
|
87
|
+
}
|
|
88
|
+
return state;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Calculate default dimensions based on aspect ratio
|
|
92
|
+
*/
|
|
93
|
+
function getDefaultDimensions(aspectRatio) {
|
|
94
|
+
switch (aspectRatio) {
|
|
95
|
+
case '16:9':
|
|
96
|
+
return { width: 1920, height: 1080 };
|
|
97
|
+
case '9:16':
|
|
98
|
+
return { width: 1080, height: 1920 };
|
|
99
|
+
case '1:1':
|
|
100
|
+
return { width: 1080, height: 1080 };
|
|
101
|
+
case '4:3':
|
|
102
|
+
return { width: 1440, height: 1080 };
|
|
103
|
+
case 'full':
|
|
104
|
+
default:
|
|
105
|
+
return { width: 1920, height: 1080 };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Handle output tool calls
|
|
110
|
+
*/
|
|
111
|
+
async function handleOutputTool(name, args) {
|
|
112
|
+
const params = args || {};
|
|
113
|
+
const poster = (0, state_js_1.getCurrentState)();
|
|
114
|
+
if (!poster) {
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: 'text', text: 'Error: No poster created. Use create_poster first.' }],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
switch (name) {
|
|
120
|
+
case 'generate_url': {
|
|
121
|
+
const baseUrl = params.baseUrl || 'https://efecto.app';
|
|
122
|
+
const state = convertToLayerShareState(poster);
|
|
123
|
+
if (!state) {
|
|
124
|
+
return {
|
|
125
|
+
content: [{ type: 'text', text: 'Error: Failed to convert poster state' }],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
// Call the encode API
|
|
130
|
+
const response = await fetch(`${API_BASE_URL}/api/v1/state/encode`, {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: {
|
|
133
|
+
'Content-Type': 'application/json',
|
|
134
|
+
},
|
|
135
|
+
body: JSON.stringify({ state, baseUrl }),
|
|
136
|
+
});
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
const errorText = await response.text();
|
|
139
|
+
return {
|
|
140
|
+
content: [
|
|
141
|
+
{
|
|
142
|
+
type: 'text',
|
|
143
|
+
text: JSON.stringify({
|
|
144
|
+
success: false,
|
|
145
|
+
error: `API error: ${response.status}`,
|
|
146
|
+
details: errorText,
|
|
147
|
+
}, null, 2),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const result = (await response.json());
|
|
153
|
+
return {
|
|
154
|
+
content: [
|
|
155
|
+
{
|
|
156
|
+
type: 'text',
|
|
157
|
+
text: JSON.stringify({
|
|
158
|
+
success: true,
|
|
159
|
+
url: result.url,
|
|
160
|
+
message: 'URL generated successfully. Open this URL in a browser to view the poster.',
|
|
161
|
+
}, null, 2),
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
return {
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
type: 'text',
|
|
171
|
+
text: JSON.stringify({
|
|
172
|
+
success: false,
|
|
173
|
+
error: 'Failed to call API',
|
|
174
|
+
details: error instanceof Error ? error.message : String(error),
|
|
175
|
+
// Fallback: provide the state for manual URL generation
|
|
176
|
+
fallback: {
|
|
177
|
+
note: 'You can manually call the API with this state:',
|
|
178
|
+
endpoint: `POST ${API_BASE_URL}/api/v1/state/encode`,
|
|
179
|
+
body: { state, baseUrl },
|
|
180
|
+
},
|
|
181
|
+
}, null, 2),
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
case 'render_image': {
|
|
188
|
+
const format = params.format || 'png';
|
|
189
|
+
const defaultDims = getDefaultDimensions(poster.canvas.aspectRatio);
|
|
190
|
+
const width = params.width || defaultDims.width;
|
|
191
|
+
const height = params.height || defaultDims.height;
|
|
192
|
+
const quality = params.quality || 90;
|
|
193
|
+
const asyncMode = params.async ?? true; // Default to async for MCP
|
|
194
|
+
const state = convertToLayerShareState(poster);
|
|
195
|
+
if (!state) {
|
|
196
|
+
return {
|
|
197
|
+
content: [{ type: 'text', text: 'Error: Failed to convert poster state' }],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
// Call the render API with async=true to get JSON response with job ID
|
|
202
|
+
// Sync mode returns binary which MCP cannot handle directly
|
|
203
|
+
const response = await fetch(`${API_BASE_URL}/api/v1/render`, {
|
|
204
|
+
method: 'POST',
|
|
205
|
+
headers: {
|
|
206
|
+
'Content-Type': 'application/json',
|
|
207
|
+
},
|
|
208
|
+
body: JSON.stringify({
|
|
209
|
+
state,
|
|
210
|
+
format,
|
|
211
|
+
width,
|
|
212
|
+
height,
|
|
213
|
+
quality,
|
|
214
|
+
async: true, // Always use async for MCP to get JSON response
|
|
215
|
+
}),
|
|
216
|
+
});
|
|
217
|
+
if (!response.ok) {
|
|
218
|
+
// Try to parse error as JSON first, fall back to text
|
|
219
|
+
const contentType = response.headers.get('content-type');
|
|
220
|
+
let errorDetails;
|
|
221
|
+
if (contentType?.includes('application/json')) {
|
|
222
|
+
const errorJson = await response.json();
|
|
223
|
+
errorDetails = JSON.stringify(errorJson);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
errorDetails = await response.text();
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
content: [
|
|
230
|
+
{
|
|
231
|
+
type: 'text',
|
|
232
|
+
text: JSON.stringify({
|
|
233
|
+
success: false,
|
|
234
|
+
error: `API error: ${response.status}`,
|
|
235
|
+
details: errorDetails,
|
|
236
|
+
}, null, 2),
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
// Async mode returns JSON with job info
|
|
242
|
+
const result = (await response.json());
|
|
243
|
+
return {
|
|
244
|
+
content: [
|
|
245
|
+
{
|
|
246
|
+
type: 'text',
|
|
247
|
+
text: JSON.stringify({
|
|
248
|
+
success: true,
|
|
249
|
+
jobId: result.jobId,
|
|
250
|
+
status: result.status || 'pending',
|
|
251
|
+
statusUrl: `${API_BASE_URL}${result.statusUrl}`,
|
|
252
|
+
downloadUrl: `${API_BASE_URL}${result.downloadUrl}`,
|
|
253
|
+
message: 'Render job started. Poll the status URL to check progress, then download from downloadUrl when complete.',
|
|
254
|
+
renderConfig: { format, width, height, quality },
|
|
255
|
+
}, null, 2),
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
return {
|
|
262
|
+
content: [
|
|
263
|
+
{
|
|
264
|
+
type: 'text',
|
|
265
|
+
text: JSON.stringify({
|
|
266
|
+
success: false,
|
|
267
|
+
error: 'Failed to call API',
|
|
268
|
+
details: error instanceof Error ? error.message : String(error),
|
|
269
|
+
// Fallback: provide the state for manual rendering
|
|
270
|
+
fallback: {
|
|
271
|
+
note: 'You can manually call the API with this configuration:',
|
|
272
|
+
endpoint: `POST ${API_BASE_URL}/api/v1/render`,
|
|
273
|
+
body: { state, format, width, height, quality, async: asyncMode },
|
|
274
|
+
},
|
|
275
|
+
}, null, 2),
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
default:
|
|
282
|
+
return {
|
|
283
|
+
content: [{ type: 'text', text: `Unknown output tool: ${name}` }],
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/tools/output.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA4GH,4CA2NC;AApUD,yCAA4C;AAE5C,oEAAoE;AACpE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,oBAAoB,CAAA;AAEvE,mBAAmB;AACN,QAAA,WAAW,GAAW;IACjC;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,oHAAoH;QACjI,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+DAA+D;oBAC5E,OAAO,EAAE,oBAAoB;iBAC9B;aACF;YACD,QAAQ,EAAE,EAAE;SACb;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,8EAA8E;QAC3F,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;oBAC7B,WAAW,EAAE,qBAAqB;oBAClC,OAAO,EAAE,KAAK;iBACf;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wDAAwD;iBACtE;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yDAAyD;iBACvE;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,2BAA2B;oBACxC,OAAO,EAAE,EAAE;iBACZ;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,iEAAiE;oBAC9E,OAAO,EAAE,KAAK;iBACf;aACF;YACD,QAAQ,EAAE,EAAE;SACb;KACF;CACF,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,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE;iCAClE;6BACF,EACD,IAAI,EACJ,CAAC,CACF;yBACF;qBACF;iBACF,CAAA;YACH,CAAC;QACH,CAAC;QAED;YACE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,IAAI,EAAE,EAAE,CAAC;aAClE,CAAA;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State Building Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for creating and modifying poster state:
|
|
5
|
+
* - create_poster: Initialize a new poster
|
|
6
|
+
* - set_background: Configure background layer
|
|
7
|
+
* - add_layer: Add a layer to the poster
|
|
8
|
+
* - modify_layer: Modify an existing layer
|
|
9
|
+
* - apply_effect: Apply main effect (ASCII, dither, etc.)
|
|
10
|
+
* - add_postprocess: Add post-processing effect
|
|
11
|
+
*
|
|
12
|
+
* All state follows the LayerShareState contract for API compatibility.
|
|
13
|
+
*/
|
|
14
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
15
|
+
type AspectRatio = '16:9' | '9:16' | '1:1' | '4:3' | 'full';
|
|
16
|
+
type EffectId = 'none' | 'ascii-standard' | 'ascii-blocks' | 'ascii-braille' | 'ascii-hatching' | 'ascii-matrix' | 'ascii-technical' | 'ascii-dense' | 'ascii-minimal' | 'dither-floyd-steinberg' | 'dither-atkinson' | 'dither-jarvis-judice-ninke' | 'dither-stucki' | 'dither-burkes' | 'dither-sierra' | 'dither-two-row-sierra' | 'dither-sierra-lite' | 'color-separation' | 'halftone-mono' | 'halftone-cmyk' | 'glitch-chromatic' | 'glitch-digital' | 'glitch-vhs' | 'glitch-weird' | 'art-kuwahara' | 'art-crosshatch' | 'art-lineart' | 'art-engraving' | 'art-stipple' | 'special-warp';
|
|
17
|
+
type PostProcessType = 'scanlines' | 'vignette' | 'chromatic-aberration' | 'curvature' | 'grain' | 'noise' | 'pixelate' | 'wave' | 'rgb-glitch' | 'brightness-contrast' | 'color-tint' | 'palette' | 'jitter' | 'bloom' | 'dot-screen' | 'sepia' | 'grid' | 'light-beams' | 'warp' | 'motion-blur';
|
|
18
|
+
interface LayerTransform {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
rotation: number;
|
|
24
|
+
opacity: number;
|
|
25
|
+
}
|
|
26
|
+
interface BaseLayer {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
visible: boolean;
|
|
31
|
+
locked: boolean;
|
|
32
|
+
transform: LayerTransform;
|
|
33
|
+
}
|
|
34
|
+
interface TextLayer extends BaseLayer {
|
|
35
|
+
type: 'text';
|
|
36
|
+
content: string;
|
|
37
|
+
fontFamily: string;
|
|
38
|
+
fontSize: number;
|
|
39
|
+
fontWeight: string;
|
|
40
|
+
color: string;
|
|
41
|
+
textAlign: 'left' | 'center' | 'right';
|
|
42
|
+
letterSpacing: number;
|
|
43
|
+
lineHeight: number;
|
|
44
|
+
}
|
|
45
|
+
interface ImageLayer extends BaseLayer {
|
|
46
|
+
type: 'image';
|
|
47
|
+
mediaUrl: string;
|
|
48
|
+
objectFit: 'cover' | 'contain';
|
|
49
|
+
brightness: number;
|
|
50
|
+
contrast: number;
|
|
51
|
+
saturation: number;
|
|
52
|
+
}
|
|
53
|
+
interface VideoLayer extends BaseLayer {
|
|
54
|
+
type: 'video';
|
|
55
|
+
mediaUrl: string;
|
|
56
|
+
objectFit: 'cover' | 'contain';
|
|
57
|
+
brightness: number;
|
|
58
|
+
contrast: number;
|
|
59
|
+
saturation: number;
|
|
60
|
+
loop: boolean;
|
|
61
|
+
playbackSpeed: number;
|
|
62
|
+
}
|
|
63
|
+
type BackgroundContentType = 'solid' | 'image' | 'video' | '3d' | 'shader';
|
|
64
|
+
interface BackgroundLayer extends BaseLayer {
|
|
65
|
+
type: 'background';
|
|
66
|
+
contentType: BackgroundContentType;
|
|
67
|
+
solidColor: string;
|
|
68
|
+
inputMedia?: {
|
|
69
|
+
mediaUrl: string;
|
|
70
|
+
mediaType: 'image' | 'video';
|
|
71
|
+
brightness: number;
|
|
72
|
+
contrast: number;
|
|
73
|
+
saturation: number;
|
|
74
|
+
objectFit: 'cover' | 'contain';
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
type Layer = TextLayer | ImageLayer | VideoLayer | BackgroundLayer | BaseLayer;
|
|
78
|
+
interface PostProcessInstance {
|
|
79
|
+
id: string;
|
|
80
|
+
type: PostProcessType;
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
settings: Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
interface PosterState {
|
|
85
|
+
canvas: {
|
|
86
|
+
aspectRatio: AspectRatio;
|
|
87
|
+
backgroundColor: string;
|
|
88
|
+
};
|
|
89
|
+
layers: Layer[];
|
|
90
|
+
effect?: {
|
|
91
|
+
effectId: EffectId;
|
|
92
|
+
enabled: boolean;
|
|
93
|
+
ascii?: Record<string, unknown>;
|
|
94
|
+
dither?: Record<string, unknown>;
|
|
95
|
+
halftone?: Record<string, unknown>;
|
|
96
|
+
monoHalftone?: Record<string, unknown>;
|
|
97
|
+
cmykHalftone?: Record<string, unknown>;
|
|
98
|
+
chromatic?: Record<string, unknown>;
|
|
99
|
+
glitch?: Record<string, unknown>;
|
|
100
|
+
kuwahara?: Record<string, unknown>;
|
|
101
|
+
crosshatch?: Record<string, unknown>;
|
|
102
|
+
lineart?: Record<string, unknown>;
|
|
103
|
+
engraving?: Record<string, unknown>;
|
|
104
|
+
stipple?: Record<string, unknown>;
|
|
105
|
+
sinewarp?: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
postProcesses: PostProcessInstance[];
|
|
108
|
+
}
|
|
109
|
+
export declare function resetState(): void;
|
|
110
|
+
export declare function getCurrentState(): PosterState | null;
|
|
111
|
+
export declare const stateTools: Tool[];
|
|
112
|
+
/**
|
|
113
|
+
* Handle state tool calls
|
|
114
|
+
*/
|
|
115
|
+
export declare function handleStateTool(name: string, args: Record<string, unknown> | undefined): Promise<{
|
|
116
|
+
content: Array<{
|
|
117
|
+
type: string;
|
|
118
|
+
text: string;
|
|
119
|
+
}>;
|
|
120
|
+
}>;
|
|
121
|
+
export {};
|
|
122
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/tools/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAA;AAG9D,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAA;AAG3D,KAAK,QAAQ,GACT,MAAM,GAEN,gBAAgB,GAAG,cAAc,GAAG,eAAe,GAAG,gBAAgB,GACtE,cAAc,GAAG,iBAAiB,GAAG,aAAa,GAAG,eAAe,GAEpE,wBAAwB,GAAG,iBAAiB,GAAG,4BAA4B,GAC3E,eAAe,GAAG,eAAe,GAAG,eAAe,GAAG,uBAAuB,GAC7E,oBAAoB,GAAG,kBAAkB,GAEzC,eAAe,GAAG,eAAe,GAEjC,kBAAkB,GAAG,gBAAgB,GAAG,YAAY,GAAG,cAAc,GAErE,cAAc,GAAG,gBAAgB,GAAG,aAAa,GAAG,eAAe,GAAG,aAAa,GAEnF,cAAc,CAAA;AAGlB,KAAK,eAAe,GAChB,WAAW,GAAG,UAAU,GAAG,sBAAsB,GAAG,WAAW,GAC/D,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,qBAAqB,GAC9E,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,OAAO,GACtE,MAAM,GAAG,aAAa,GAAG,MAAM,GAAG,aA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