klamdo-mcp 1.0.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/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +303 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -0
- package/src/index.ts +360 -0
- package/tsconfig.json +18 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Klamdo MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes Klamdo's AI content generation to Claude Desktop and other
|
|
6
|
+
* MCP-compatible clients. Lets AI assistants generate identity-locked
|
|
7
|
+
* 4K images and 5-second vertical videos on behalf of the user.
|
|
8
|
+
*
|
|
9
|
+
* Setup:
|
|
10
|
+
* 1. Create a Klamdo account at https://klamdo.app
|
|
11
|
+
* 2. Get your API key from your profile page
|
|
12
|
+
* 3. Add to Claude Desktop config:
|
|
13
|
+
* { "mcpServers": { "klamdo": { "command": "npx", "args": ["klamdo-mcp"], "env": { "KLAMDO_API_KEY": "<your-key>" } } } }
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Klamdo MCP Server
|
|
5
|
+
*
|
|
6
|
+
* Exposes Klamdo's AI content generation to Claude Desktop and other
|
|
7
|
+
* MCP-compatible clients. Lets AI assistants generate identity-locked
|
|
8
|
+
* 4K images and 5-second vertical videos on behalf of the user.
|
|
9
|
+
*
|
|
10
|
+
* Setup:
|
|
11
|
+
* 1. Create a Klamdo account at https://klamdo.app
|
|
12
|
+
* 2. Get your API key from your profile page
|
|
13
|
+
* 3. Add to Claude Desktop config:
|
|
14
|
+
* { "mcpServers": { "klamdo": { "command": "npx", "args": ["klamdo-mcp"], "env": { "KLAMDO_API_KEY": "<your-key>" } } } }
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
18
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
19
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
20
|
+
const BASE_URL = process.env.KLAMDO_BASE_URL ?? "https://klamdo.app";
|
|
21
|
+
const API_KEY = process.env.KLAMDO_API_KEY ?? "";
|
|
22
|
+
if (!API_KEY) {
|
|
23
|
+
process.stderr.write("[klamdo-mcp] Warning: KLAMDO_API_KEY is not set. All API calls will fail. " +
|
|
24
|
+
"Set it in your MCP client config.\n");
|
|
25
|
+
}
|
|
26
|
+
async function klamdo(path, body) {
|
|
27
|
+
const res = await fetch(`${BASE_URL}/api/mcp${path}`, {
|
|
28
|
+
method: body ? "POST" : "GET",
|
|
29
|
+
headers: {
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
"Authorization": `Bearer ${API_KEY}`
|
|
32
|
+
},
|
|
33
|
+
body: body ? JSON.stringify(body) : undefined
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
const text = await res.text().catch(() => "");
|
|
37
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Klamdo API error ${res.status}: ${text.slice(0, 200)}`);
|
|
38
|
+
}
|
|
39
|
+
return res.json();
|
|
40
|
+
}
|
|
41
|
+
// ── Tool definitions ─────────────────────────────────────────────────────────
|
|
42
|
+
const TOOLS = [
|
|
43
|
+
{
|
|
44
|
+
name: "generate_image",
|
|
45
|
+
description: "Generate a 4K identity-locked image using the user's reference photo on Klamdo. " +
|
|
46
|
+
"Returns a job ID — use check_job to poll for the result. Costs 3 credits.",
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
prompt: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: "Describe the content you want to generate. Be specific about setting, mood, style, and purpose. " +
|
|
53
|
+
"Example: 'A confident coach standing in a modern co-working space, window light, suited, holding a coffee, editorial style'"
|
|
54
|
+
},
|
|
55
|
+
aspectRatio: {
|
|
56
|
+
type: "string",
|
|
57
|
+
enum: ["1:1", "16:9", "9:16"],
|
|
58
|
+
description: "Output aspect ratio. Default: 1:1 (square, social-optimized).",
|
|
59
|
+
default: "1:1"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
required: ["prompt"]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "generate_video",
|
|
67
|
+
description: "Generate a 5-second vertical identity-locked video from the user's reference photo on Klamdo. " +
|
|
68
|
+
"Returns a job ID — use check_job to poll for the result. Aspect ratio is locked to 9:16. Costs 6 credits.",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: {
|
|
72
|
+
prompt: {
|
|
73
|
+
type: "string",
|
|
74
|
+
description: "Describe the video content. Include motion cues for best results. " +
|
|
75
|
+
"Example: 'A confident entrepreneur walking through a city street, slow zoom, cinematic lighting'"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
required: ["prompt"]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "check_job",
|
|
83
|
+
description: "Check the status of a Klamdo generation job. Returns status and download URLs when complete.",
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
jobId: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description: "The job ID returned from generate_image or generate_video"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
required: ["jobId"]
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "get_account",
|
|
97
|
+
description: "Get current Klamdo account status: credit balance, plan, and recent jobs.",
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: "object",
|
|
100
|
+
properties: {}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "list_jobs",
|
|
105
|
+
description: "List recent Klamdo generation jobs for this account.",
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: "object",
|
|
108
|
+
properties: {
|
|
109
|
+
limit: {
|
|
110
|
+
type: "number",
|
|
111
|
+
description: "Maximum jobs to return (default: 10, max: 50)",
|
|
112
|
+
default: 10
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
];
|
|
118
|
+
// ── MCP Server ───────────────────────────────────────────────────────────────
|
|
119
|
+
const server = new index_js_1.Server({ name: "klamdo", version: "1.0.0" }, { capabilities: { tools: {}, resources: {} } });
|
|
120
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({ tools: TOOLS }));
|
|
121
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
122
|
+
const { name, arguments: args } = request.params;
|
|
123
|
+
const input = (args ?? {});
|
|
124
|
+
try {
|
|
125
|
+
switch (name) {
|
|
126
|
+
case "generate_image": {
|
|
127
|
+
const result = await klamdo("/jobs", {
|
|
128
|
+
prompt: input.prompt,
|
|
129
|
+
mode: "image",
|
|
130
|
+
aspectRatio: input.aspectRatio ?? "4:5"
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
content: [
|
|
134
|
+
{
|
|
135
|
+
type: "text",
|
|
136
|
+
text: `Image generation started.\n\nJob ID: ${result.jobId}\nStatus: ${result.status}\nCredits reserved: ${result.creditsReserved}\n\nUse check_job("${result.jobId}") to get the result. Images typically complete in 30–90 seconds.`
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
case "generate_video": {
|
|
142
|
+
const result = await klamdo("/jobs", {
|
|
143
|
+
prompt: input.prompt,
|
|
144
|
+
mode: "video",
|
|
145
|
+
aspectRatio: "9:16"
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
content: [
|
|
149
|
+
{
|
|
150
|
+
type: "text",
|
|
151
|
+
text: `Video generation started.\n\nJob ID: ${result.jobId}\nStatus: ${result.status}\nCredits reserved: ${result.creditsReserved}\n\nUse check_job("${result.jobId}") to get the result. Videos typically complete in 2–5 minutes.`
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
case "check_job": {
|
|
157
|
+
const jobId = String(input.jobId ?? "");
|
|
158
|
+
if (!jobId)
|
|
159
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, "jobId is required");
|
|
160
|
+
const result = await klamdo(`/jobs/${jobId}`);
|
|
161
|
+
if (result.status === "completed") {
|
|
162
|
+
const imageAsset = result.assets.find((a) => a.kind === "image");
|
|
163
|
+
const videoAsset = result.assets.find((a) => a.kind === "video");
|
|
164
|
+
const lines = [
|
|
165
|
+
`Job ${jobId} — Completed ✓`,
|
|
166
|
+
"",
|
|
167
|
+
imageAsset ? `Image URL: ${imageAsset.url}` : null,
|
|
168
|
+
videoAsset ? `Video URL: ${videoAsset.url}` : null,
|
|
169
|
+
result.caption ? `\nSuggested caption:\n${result.caption}` : null,
|
|
170
|
+
"",
|
|
171
|
+
`Share page: ${BASE_URL}/share/${jobId}`
|
|
172
|
+
].filter(Boolean);
|
|
173
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
174
|
+
}
|
|
175
|
+
if (result.status === "failed") {
|
|
176
|
+
return {
|
|
177
|
+
content: [
|
|
178
|
+
{
|
|
179
|
+
type: "text",
|
|
180
|
+
text: `Job ${jobId} failed: ${result.errorMessage ?? "Unknown error"}. Credits have been refunded.`
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
content: [
|
|
187
|
+
{
|
|
188
|
+
type: "text",
|
|
189
|
+
text: `Job ${jobId} is still running (status: ${result.status}). Check again in 15–30 seconds.`
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
case "get_account": {
|
|
195
|
+
const result = await klamdo("/account");
|
|
196
|
+
return {
|
|
197
|
+
content: [
|
|
198
|
+
{
|
|
199
|
+
type: "text",
|
|
200
|
+
text: [
|
|
201
|
+
`Klamdo Account: ${result.name} (${result.email})`,
|
|
202
|
+
`Plan: ${result.planTier}`,
|
|
203
|
+
`Credits: ${result.availableCredits}`,
|
|
204
|
+
result.freeSampleEligible ? "Free sample: available" : ""
|
|
205
|
+
].filter(Boolean).join("\n")
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
case "list_jobs": {
|
|
211
|
+
const limit = Math.min(Number(input.limit ?? 10), 50);
|
|
212
|
+
const result = await klamdo(`/jobs?limit=${limit}`);
|
|
213
|
+
const lines = result.jobs.map((j) => `[${j.status}] ${j.id} — ${j.mode} — "${j.prompt.slice(0, 60)}" (${j.createdAt.slice(0, 10)})`);
|
|
214
|
+
return {
|
|
215
|
+
content: [
|
|
216
|
+
{
|
|
217
|
+
type: "text",
|
|
218
|
+
text: lines.length ? lines.join("\n") : "No jobs found."
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
default:
|
|
224
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
if (err instanceof types_js_1.McpError)
|
|
229
|
+
throw err;
|
|
230
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, err instanceof Error ? err.message : String(err));
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
// Resources: expose the API docs as a readable resource
|
|
234
|
+
server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => ({
|
|
235
|
+
resources: [
|
|
236
|
+
{
|
|
237
|
+
uri: "klamdo://docs",
|
|
238
|
+
name: "Klamdo API Documentation",
|
|
239
|
+
description: "How to use Klamdo's MCP tools and what each parameter does",
|
|
240
|
+
mimeType: "text/plain"
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}));
|
|
244
|
+
server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => {
|
|
245
|
+
if (request.params.uri === "klamdo://docs") {
|
|
246
|
+
return {
|
|
247
|
+
contents: [
|
|
248
|
+
{
|
|
249
|
+
uri: "klamdo://docs",
|
|
250
|
+
mimeType: "text/plain",
|
|
251
|
+
text: `# Klamdo MCP Server
|
|
252
|
+
|
|
253
|
+
Klamdo generates identity-locked 4K images and 5-second vertical videos for coaches and creator-founders.
|
|
254
|
+
|
|
255
|
+
## Tools
|
|
256
|
+
|
|
257
|
+
### generate_image
|
|
258
|
+
Generate a 4K image from the user's reference photo. Costs 3 credits.
|
|
259
|
+
- prompt (required): Describe the content, setting, mood, and style
|
|
260
|
+
- aspectRatio (optional): "1:1" | "16:9" | "9:16" — default "1:1"
|
|
261
|
+
|
|
262
|
+
### generate_video
|
|
263
|
+
Generate a 5-second 9:16 vertical video. Costs 6 credits.
|
|
264
|
+
- prompt (required): Describe the video content with motion cues
|
|
265
|
+
|
|
266
|
+
### check_job
|
|
267
|
+
Poll a generation job for results.
|
|
268
|
+
- jobId (required): Job ID from generate_image or generate_video
|
|
269
|
+
|
|
270
|
+
### get_account
|
|
271
|
+
Get account status: credits, plan tier, free sample eligibility.
|
|
272
|
+
|
|
273
|
+
### list_jobs
|
|
274
|
+
List recent jobs.
|
|
275
|
+
- limit (optional): Number of jobs to return (default 10, max 50)
|
|
276
|
+
|
|
277
|
+
## Pricing
|
|
278
|
+
- $19.99/month for 120 credits
|
|
279
|
+
- 3 credits per 4K image (~40/mo)
|
|
280
|
+
- 6 credits per 5-sec video (~20/mo)
|
|
281
|
+
- Free sample on first sign-up
|
|
282
|
+
|
|
283
|
+
## Links
|
|
284
|
+
- Sign up: https://klamdo.app/sign-up
|
|
285
|
+
- Pricing: https://klamdo.app/pricing
|
|
286
|
+
`
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidRequest, `Resource not found: ${request.params.uri}`);
|
|
292
|
+
});
|
|
293
|
+
// ── Start ────────────────────────────────────────────────────────────────────
|
|
294
|
+
async function main() {
|
|
295
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
296
|
+
await server.connect(transport);
|
|
297
|
+
process.stderr.write("[klamdo-mcp] Klamdo MCP server running on stdio\n");
|
|
298
|
+
}
|
|
299
|
+
main().catch((err) => {
|
|
300
|
+
process.stderr.write(`[klamdo-mcp] Fatal error: ${err}\n`);
|
|
301
|
+
process.exit(1);
|
|
302
|
+
});
|
|
303
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;GAYG;;AAEH,wEAAmE;AACnE,wEAAiF;AACjF,iEAO4C;AAE5C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,oBAAoB,CAAC;AACrE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;AAEjD,IAAI,CAAC,OAAO,EAAE,CAAC;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,4EAA4E;QAC5E,qCAAqC,CACtC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,MAAM,CAAI,IAAY,EAAE,IAA8B;IACnE,MAAM,GAAG,GAAG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iBACQ;aACF;SACF,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,mBAAQ,CAAC,oBAAS,CAAC,cAAc,EAAE,uBAAuB,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC5F,CAAC,CAAC,CAAC;AAEH,gFAAgF;AAEhF,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;AAC5E,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "klamdo-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for Klamdo — AI content generation for coaches and creator-founders. Generate 4K images and 5-second vertical videos from a reference photo via Claude Desktop or any MCP-compatible client.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"klamdo-mcp": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"start": "node dist/index.js",
|
|
12
|
+
"dev": "ts-node src/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"keywords": ["mcp", "klamdo", "ai-content", "image-generation", "video-generation", "creator-tools"],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^20.0.0",
|
|
21
|
+
"typescript": "^5.4.0"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Klamdo MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes Klamdo's AI content generation to Claude Desktop and other
|
|
6
|
+
* MCP-compatible clients. Lets AI assistants generate identity-locked
|
|
7
|
+
* 4K images and 5-second vertical videos on behalf of the user.
|
|
8
|
+
*
|
|
9
|
+
* Setup:
|
|
10
|
+
* 1. Create a Klamdo account at https://klamdo.app
|
|
11
|
+
* 2. Get your API key from your profile page
|
|
12
|
+
* 3. Add to Claude Desktop config:
|
|
13
|
+
* { "mcpServers": { "klamdo": { "command": "npx", "args": ["klamdo-mcp"], "env": { "KLAMDO_API_KEY": "<your-key>" } } } }
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
17
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
18
|
+
import {
|
|
19
|
+
CallToolRequestSchema,
|
|
20
|
+
ErrorCode,
|
|
21
|
+
ListResourcesRequestSchema,
|
|
22
|
+
ListToolsRequestSchema,
|
|
23
|
+
McpError,
|
|
24
|
+
ReadResourceRequestSchema
|
|
25
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
26
|
+
|
|
27
|
+
const BASE_URL = process.env.KLAMDO_BASE_URL ?? "https://klamdo.app";
|
|
28
|
+
const API_KEY = process.env.KLAMDO_API_KEY ?? "";
|
|
29
|
+
|
|
30
|
+
if (!API_KEY) {
|
|
31
|
+
process.stderr.write(
|
|
32
|
+
"[klamdo-mcp] Warning: KLAMDO_API_KEY is not set. All API calls will fail. " +
|
|
33
|
+
"Set it in your MCP client config.\n"
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function klamdo<T>(path: string, body?: Record<string, unknown>): Promise<T> {
|
|
38
|
+
const res = await fetch(`${BASE_URL}/api/mcp${path}`, {
|
|
39
|
+
method: body ? "POST" : "GET",
|
|
40
|
+
headers: {
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
"Authorization": `Bearer ${API_KEY}`
|
|
43
|
+
},
|
|
44
|
+
body: body ? JSON.stringify(body) : undefined
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!res.ok) {
|
|
48
|
+
const text = await res.text().catch(() => "");
|
|
49
|
+
throw new McpError(
|
|
50
|
+
ErrorCode.InternalError,
|
|
51
|
+
`Klamdo API error ${res.status}: ${text.slice(0, 200)}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return res.json() as Promise<T>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ── Tool definitions ─────────────────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
const TOOLS = [
|
|
61
|
+
{
|
|
62
|
+
name: "generate_image",
|
|
63
|
+
description:
|
|
64
|
+
"Generate a 4K identity-locked image using the user's reference photo on Klamdo. " +
|
|
65
|
+
"Returns a job ID — use check_job to poll for the result. Costs 3 credits.",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
prompt: {
|
|
70
|
+
type: "string",
|
|
71
|
+
description:
|
|
72
|
+
"Describe the content you want to generate. Be specific about setting, mood, style, and purpose. " +
|
|
73
|
+
"Example: 'A confident coach standing in a modern co-working space, window light, suited, holding a coffee, editorial style'"
|
|
74
|
+
},
|
|
75
|
+
aspectRatio: {
|
|
76
|
+
type: "string",
|
|
77
|
+
enum: ["1:1", "16:9", "9:16"],
|
|
78
|
+
description: "Output aspect ratio. Default: 1:1 (square, social-optimized).",
|
|
79
|
+
default: "1:1"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
required: ["prompt"]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "generate_video",
|
|
87
|
+
description:
|
|
88
|
+
"Generate a 5-second vertical identity-locked video from the user's reference photo on Klamdo. " +
|
|
89
|
+
"Returns a job ID — use check_job to poll for the result. Aspect ratio is locked to 9:16. Costs 6 credits.",
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: "object",
|
|
92
|
+
properties: {
|
|
93
|
+
prompt: {
|
|
94
|
+
type: "string",
|
|
95
|
+
description:
|
|
96
|
+
"Describe the video content. Include motion cues for best results. " +
|
|
97
|
+
"Example: 'A confident entrepreneur walking through a city street, slow zoom, cinematic lighting'"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
required: ["prompt"]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "check_job",
|
|
105
|
+
description:
|
|
106
|
+
"Check the status of a Klamdo generation job. Returns status and download URLs when complete.",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
jobId: {
|
|
111
|
+
type: "string",
|
|
112
|
+
description: "The job ID returned from generate_image or generate_video"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
required: ["jobId"]
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "get_account",
|
|
120
|
+
description: "Get current Klamdo account status: credit balance, plan, and recent jobs.",
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "list_jobs",
|
|
128
|
+
description: "List recent Klamdo generation jobs for this account.",
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: "object",
|
|
131
|
+
properties: {
|
|
132
|
+
limit: {
|
|
133
|
+
type: "number",
|
|
134
|
+
description: "Maximum jobs to return (default: 10, max: 50)",
|
|
135
|
+
default: 10
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
// ── MCP Server ───────────────────────────────────────────────────────────────
|
|
143
|
+
|
|
144
|
+
const server = new Server(
|
|
145
|
+
{ name: "klamdo", version: "1.0.0" },
|
|
146
|
+
{ capabilities: { tools: {}, resources: {} } }
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
|
|
150
|
+
|
|
151
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
152
|
+
const { name, arguments: args } = request.params;
|
|
153
|
+
const input = (args ?? {}) as Record<string, unknown>;
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
switch (name) {
|
|
157
|
+
case "generate_image": {
|
|
158
|
+
const result = await klamdo<{ jobId: string; status: string; creditsReserved: number }>("/jobs", {
|
|
159
|
+
prompt: input.prompt,
|
|
160
|
+
mode: "image",
|
|
161
|
+
aspectRatio: input.aspectRatio ?? "4:5"
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
type: "text",
|
|
167
|
+
text: `Image generation started.\n\nJob ID: ${result.jobId}\nStatus: ${result.status}\nCredits reserved: ${result.creditsReserved}\n\nUse check_job("${result.jobId}") to get the result. Images typically complete in 30–90 seconds.`
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
case "generate_video": {
|
|
174
|
+
const result = await klamdo<{ jobId: string; status: string; creditsReserved: number }>("/jobs", {
|
|
175
|
+
prompt: input.prompt,
|
|
176
|
+
mode: "video",
|
|
177
|
+
aspectRatio: "9:16"
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
content: [
|
|
181
|
+
{
|
|
182
|
+
type: "text",
|
|
183
|
+
text: `Video generation started.\n\nJob ID: ${result.jobId}\nStatus: ${result.status}\nCredits reserved: ${result.creditsReserved}\n\nUse check_job("${result.jobId}") to get the result. Videos typically complete in 2–5 minutes.`
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
case "check_job": {
|
|
190
|
+
const jobId = String(input.jobId ?? "");
|
|
191
|
+
if (!jobId) throw new McpError(ErrorCode.InvalidParams, "jobId is required");
|
|
192
|
+
|
|
193
|
+
const result = await klamdo<{
|
|
194
|
+
status: string;
|
|
195
|
+
assets: Array<{ kind: string; url: string }>;
|
|
196
|
+
errorMessage?: string;
|
|
197
|
+
caption?: string;
|
|
198
|
+
}>(`/jobs/${jobId}`);
|
|
199
|
+
|
|
200
|
+
if (result.status === "completed") {
|
|
201
|
+
const imageAsset = result.assets.find((a) => a.kind === "image");
|
|
202
|
+
const videoAsset = result.assets.find((a) => a.kind === "video");
|
|
203
|
+
const lines = [
|
|
204
|
+
`Job ${jobId} — Completed ✓`,
|
|
205
|
+
"",
|
|
206
|
+
imageAsset ? `Image URL: ${imageAsset.url}` : null,
|
|
207
|
+
videoAsset ? `Video URL: ${videoAsset.url}` : null,
|
|
208
|
+
result.caption ? `\nSuggested caption:\n${result.caption}` : null,
|
|
209
|
+
"",
|
|
210
|
+
`Share page: ${BASE_URL}/share/${jobId}`
|
|
211
|
+
].filter(Boolean);
|
|
212
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (result.status === "failed") {
|
|
216
|
+
return {
|
|
217
|
+
content: [
|
|
218
|
+
{
|
|
219
|
+
type: "text",
|
|
220
|
+
text: `Job ${jobId} failed: ${result.errorMessage ?? "Unknown error"}. Credits have been refunded.`
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
content: [
|
|
228
|
+
{
|
|
229
|
+
type: "text",
|
|
230
|
+
text: `Job ${jobId} is still running (status: ${result.status}). Check again in 15–30 seconds.`
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
case "get_account": {
|
|
237
|
+
const result = await klamdo<{
|
|
238
|
+
name: string;
|
|
239
|
+
email: string;
|
|
240
|
+
availableCredits: number;
|
|
241
|
+
planTier: string;
|
|
242
|
+
freeSampleEligible: boolean;
|
|
243
|
+
}>("/account");
|
|
244
|
+
return {
|
|
245
|
+
content: [
|
|
246
|
+
{
|
|
247
|
+
type: "text",
|
|
248
|
+
text: [
|
|
249
|
+
`Klamdo Account: ${result.name} (${result.email})`,
|
|
250
|
+
`Plan: ${result.planTier}`,
|
|
251
|
+
`Credits: ${result.availableCredits}`,
|
|
252
|
+
result.freeSampleEligible ? "Free sample: available" : ""
|
|
253
|
+
].filter(Boolean).join("\n")
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
case "list_jobs": {
|
|
260
|
+
const limit = Math.min(Number(input.limit ?? 10), 50);
|
|
261
|
+
const result = await klamdo<{ jobs: Array<{ id: string; status: string; mode: string; prompt: string; createdAt: string }> }>(`/jobs?limit=${limit}`);
|
|
262
|
+
const lines = result.jobs.map(
|
|
263
|
+
(j) => `[${j.status}] ${j.id} — ${j.mode} — "${j.prompt.slice(0, 60)}" (${j.createdAt.slice(0, 10)})`
|
|
264
|
+
);
|
|
265
|
+
return {
|
|
266
|
+
content: [
|
|
267
|
+
{
|
|
268
|
+
type: "text",
|
|
269
|
+
text: lines.length ? lines.join("\n") : "No jobs found."
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
default:
|
|
276
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
277
|
+
}
|
|
278
|
+
} catch (err) {
|
|
279
|
+
if (err instanceof McpError) throw err;
|
|
280
|
+
throw new McpError(
|
|
281
|
+
ErrorCode.InternalError,
|
|
282
|
+
err instanceof Error ? err.message : String(err)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Resources: expose the API docs as a readable resource
|
|
288
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
289
|
+
resources: [
|
|
290
|
+
{
|
|
291
|
+
uri: "klamdo://docs",
|
|
292
|
+
name: "Klamdo API Documentation",
|
|
293
|
+
description: "How to use Klamdo's MCP tools and what each parameter does",
|
|
294
|
+
mimeType: "text/plain"
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
}));
|
|
298
|
+
|
|
299
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
300
|
+
if (request.params.uri === "klamdo://docs") {
|
|
301
|
+
return {
|
|
302
|
+
contents: [
|
|
303
|
+
{
|
|
304
|
+
uri: "klamdo://docs",
|
|
305
|
+
mimeType: "text/plain",
|
|
306
|
+
text: `# Klamdo MCP Server
|
|
307
|
+
|
|
308
|
+
Klamdo generates identity-locked 4K images and 5-second vertical videos for coaches and creator-founders.
|
|
309
|
+
|
|
310
|
+
## Tools
|
|
311
|
+
|
|
312
|
+
### generate_image
|
|
313
|
+
Generate a 4K image from the user's reference photo. Costs 3 credits.
|
|
314
|
+
- prompt (required): Describe the content, setting, mood, and style
|
|
315
|
+
- aspectRatio (optional): "1:1" | "16:9" | "9:16" — default "1:1"
|
|
316
|
+
|
|
317
|
+
### generate_video
|
|
318
|
+
Generate a 5-second 9:16 vertical video. Costs 6 credits.
|
|
319
|
+
- prompt (required): Describe the video content with motion cues
|
|
320
|
+
|
|
321
|
+
### check_job
|
|
322
|
+
Poll a generation job for results.
|
|
323
|
+
- jobId (required): Job ID from generate_image or generate_video
|
|
324
|
+
|
|
325
|
+
### get_account
|
|
326
|
+
Get account status: credits, plan tier, free sample eligibility.
|
|
327
|
+
|
|
328
|
+
### list_jobs
|
|
329
|
+
List recent jobs.
|
|
330
|
+
- limit (optional): Number of jobs to return (default 10, max 50)
|
|
331
|
+
|
|
332
|
+
## Pricing
|
|
333
|
+
- $19.99/month for 120 credits
|
|
334
|
+
- 3 credits per 4K image (~40/mo)
|
|
335
|
+
- 6 credits per 5-sec video (~20/mo)
|
|
336
|
+
- Free sample on first sign-up
|
|
337
|
+
|
|
338
|
+
## Links
|
|
339
|
+
- Sign up: https://klamdo.app/sign-up
|
|
340
|
+
- Pricing: https://klamdo.app/pricing
|
|
341
|
+
`
|
|
342
|
+
}
|
|
343
|
+
]
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
throw new McpError(ErrorCode.InvalidRequest, `Resource not found: ${request.params.uri}`);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
// ── Start ────────────────────────────────────────────────────────────────────
|
|
350
|
+
|
|
351
|
+
async function main() {
|
|
352
|
+
const transport = new StdioServerTransport();
|
|
353
|
+
await server.connect(transport);
|
|
354
|
+
process.stderr.write("[klamdo-mcp] Klamdo MCP server running on stdio\n");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
main().catch((err) => {
|
|
358
|
+
process.stderr.write(`[klamdo-mcp] Fatal error: ${err}\n`);
|
|
359
|
+
process.exit(1);
|
|
360
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|