klamdo-mcp 1.0.0 → 1.2.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/http.d.ts +14 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +119 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -284
- package/dist/index.js.map +1 -1
- package/dist/tools.d.ts +123 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +258 -0
- package/dist/tools.js.map +1 -0
- package/package.json +7 -3
- package/smithery.yaml +30 -0
- package/src/http.ts +135 -0
- package/src/index.ts +21 -336
- package/src/tools.ts +317 -0
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Klamdo MCP Server — Streamable HTTP transport
|
|
4
|
+
*
|
|
5
|
+
* Runs as a hosted service on mark-mini-s, exposed via Cloudflare Tunnel at:
|
|
6
|
+
* https://mcp.klamdo.app
|
|
7
|
+
*
|
|
8
|
+
* Each request is stateless. API key is read from Authorization: Bearer <key> header.
|
|
9
|
+
* Users get their key from https://klamdo.app/profile
|
|
10
|
+
*
|
|
11
|
+
* Smithery URL: https://mcp.klamdo.app/mcp
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Klamdo MCP Server — Streamable HTTP transport
|
|
5
|
+
*
|
|
6
|
+
* Runs as a hosted service on mark-mini-s, exposed via Cloudflare Tunnel at:
|
|
7
|
+
* https://mcp.klamdo.app
|
|
8
|
+
*
|
|
9
|
+
* Each request is stateless. API key is read from Authorization: Bearer <key> header.
|
|
10
|
+
* Users get their key from https://klamdo.app/profile
|
|
11
|
+
*
|
|
12
|
+
* Smithery URL: https://mcp.klamdo.app/mcp
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
16
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
17
|
+
const http_1 = require("http");
|
|
18
|
+
const tools_js_1 = require("./tools.js");
|
|
19
|
+
const PORT = parseInt(process.env.PORT ?? "3838", 10);
|
|
20
|
+
const HOST = process.env.HOST ?? "127.0.0.1";
|
|
21
|
+
function extractApiKey(req) {
|
|
22
|
+
const auth = req.headers["authorization"] ?? "";
|
|
23
|
+
if (auth.startsWith("Bearer "))
|
|
24
|
+
return auth.slice(7).trim();
|
|
25
|
+
// Also allow x-api-key header for clients that don't support Bearer
|
|
26
|
+
const xApiKey = req.headers["x-api-key"];
|
|
27
|
+
if (typeof xApiKey === "string")
|
|
28
|
+
return xApiKey.trim();
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
async function readBody(req) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const chunks = [];
|
|
34
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
35
|
+
req.on("end", () => resolve(Buffer.concat(chunks)));
|
|
36
|
+
req.on("error", reject);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function createMcpServer(apiKey) {
|
|
40
|
+
const server = new index_js_1.Server({ name: "klamdo", version: "1.1.0" }, { capabilities: { tools: {}, resources: {} } });
|
|
41
|
+
(0, tools_js_1.registerHandlers)(server, () => apiKey);
|
|
42
|
+
return server;
|
|
43
|
+
}
|
|
44
|
+
const httpServer = (0, http_1.createServer)(async (req, res) => {
|
|
45
|
+
const url = new URL(req.url ?? "/", `http://${req.headers.host}`);
|
|
46
|
+
// Health check
|
|
47
|
+
if (req.method === "GET" && url.pathname === "/health") {
|
|
48
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
49
|
+
res.end(JSON.stringify({ ok: true, service: "klamdo-mcp", version: "1.1.0" }));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// CORS preflight
|
|
53
|
+
if (req.method === "OPTIONS") {
|
|
54
|
+
res.writeHead(204, {
|
|
55
|
+
"Access-Control-Allow-Origin": "*",
|
|
56
|
+
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
57
|
+
"Access-Control-Allow-Headers": "Authorization, Content-Type, x-api-key, mcp-session-id"
|
|
58
|
+
});
|
|
59
|
+
res.end();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// MCP endpoint
|
|
63
|
+
if (url.pathname === "/mcp") {
|
|
64
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
65
|
+
res.setHeader("Access-Control-Allow-Headers", "Authorization, Content-Type, x-api-key, mcp-session-id");
|
|
66
|
+
const apiKey = extractApiKey(req);
|
|
67
|
+
// Require auth — return 401 so Smithery knows OAuth is expected
|
|
68
|
+
if (!apiKey) {
|
|
69
|
+
res.writeHead(401, {
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
"WWW-Authenticate": 'Bearer realm="Klamdo MCP", error="missing_token"'
|
|
72
|
+
});
|
|
73
|
+
res.end(JSON.stringify({
|
|
74
|
+
error: "missing_api_key",
|
|
75
|
+
message: "Get your API key at https://klamdo.app/profile"
|
|
76
|
+
}));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const body = req.method === "POST" ? await readBody(req) : undefined;
|
|
81
|
+
// Stateless: new server+transport per request
|
|
82
|
+
const mcpServer = createMcpServer(apiKey);
|
|
83
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
|
|
84
|
+
sessionIdGenerator: undefined // stateless mode
|
|
85
|
+
});
|
|
86
|
+
await mcpServer.connect(transport);
|
|
87
|
+
await transport.handleRequest(req, res, body ? JSON.parse(body.toString()) : undefined);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
if (!res.headersSent) {
|
|
91
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
92
|
+
res.end(JSON.stringify({ error: "internal_error", message: String(err) }));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Root — basic info page
|
|
98
|
+
if (url.pathname === "/" || url.pathname === "") {
|
|
99
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
100
|
+
res.end(JSON.stringify({
|
|
101
|
+
service: "Klamdo MCP Server",
|
|
102
|
+
version: "1.1.0",
|
|
103
|
+
mcpEndpoint: "/mcp",
|
|
104
|
+
docs: "https://klamdo.app/answers",
|
|
105
|
+
getApiKey: "https://klamdo.app/profile"
|
|
106
|
+
}));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
110
|
+
res.end(JSON.stringify({ error: "not_found" }));
|
|
111
|
+
});
|
|
112
|
+
httpServer.listen(PORT, HOST, () => {
|
|
113
|
+
process.stdout.write(`[klamdo-mcp:http] Listening on http://${HOST}:${PORT}/mcp\n`);
|
|
114
|
+
});
|
|
115
|
+
httpServer.on("error", (err) => {
|
|
116
|
+
process.stderr.write(`[klamdo-mcp:http] Server error: ${err}\n`);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;GAUG;;AAEH,wEAAmE;AACnE,0FAAmG;AACnG,+BAA+E;AAC/E,yCAA8C;AAE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3
|
+
* Klamdo MCP Server — stdio transport (for Claude Desktop local use)
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
5
|
+
* Setup in Claude Desktop config:
|
|
6
|
+
* {
|
|
7
|
+
* "mcpServers": {
|
|
8
|
+
* "klamdo": {
|
|
9
|
+
* "command": "npx",
|
|
10
|
+
* "args": ["klamdo-mcp"],
|
|
11
|
+
* "env": { "KLAMDO_API_KEY": "<your-key-from-klamdo.app/profile>" }
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
14
15
|
*/
|
|
15
16
|
export {};
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG"}
|
package/dist/index.js
CHANGED
|
@@ -1,303 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
* Klamdo MCP Server
|
|
4
|
+
* Klamdo MCP Server — stdio transport (for Claude Desktop local use)
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
6
|
+
* Setup in Claude Desktop config:
|
|
7
|
+
* {
|
|
8
|
+
* "mcpServers": {
|
|
9
|
+
* "klamdo": {
|
|
10
|
+
* "command": "npx",
|
|
11
|
+
* "args": ["klamdo-mcp"],
|
|
12
|
+
* "env": { "KLAMDO_API_KEY": "<your-key-from-klamdo.app/profile>" }
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
15
16
|
*/
|
|
16
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
18
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
18
19
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
19
|
-
const
|
|
20
|
-
const BASE_URL = process.env.KLAMDO_BASE_URL ?? "https://klamdo.app";
|
|
20
|
+
const tools_js_1 = require("./tools.js");
|
|
21
21
|
const API_KEY = process.env.KLAMDO_API_KEY ?? "";
|
|
22
22
|
if (!API_KEY) {
|
|
23
|
-
process.stderr.write("[klamdo-mcp] Warning: KLAMDO_API_KEY is not set.
|
|
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();
|
|
23
|
+
process.stderr.write("[klamdo-mcp] Warning: KLAMDO_API_KEY is not set. Set it in your MCP client config.\n");
|
|
40
24
|
}
|
|
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
25
|
async function main() {
|
|
26
|
+
const server = new index_js_1.Server({ name: "klamdo", version: "1.1.0" }, { capabilities: { tools: {}, resources: {} } });
|
|
27
|
+
(0, tools_js_1.registerHandlers)(server, () => API_KEY);
|
|
295
28
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
296
29
|
await server.connect(transport);
|
|
297
|
-
process.stderr.write("[klamdo-mcp]
|
|
30
|
+
process.stderr.write("[klamdo-mcp] Running via stdio\n");
|
|
298
31
|
}
|
|
299
32
|
main().catch((err) => {
|
|
300
|
-
process.stderr.write(`[klamdo-mcp] Fatal
|
|
33
|
+
process.stderr.write(`[klamdo-mcp] Fatal: ${err}\n`);
|
|
301
34
|
process.exit(1);
|
|
302
35
|
});
|
|
303
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;GAaG;;AAEH,wEAAmE;AACnE,wEAAiF;AACjF,yCAA8C;AAE9C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;AAEjD,IAAI,CAAC,OAAO,EAAE,CAAC;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,sFAAsF,CACvF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,iBAAM,CACvB,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EACpC,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAC/C,CAAC;IAEF,IAAA,2BAAgB,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAExC,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAC3D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared tool definitions and implementations for both stdio and HTTP transports.
|
|
3
|
+
* The apiKey is per-request in HTTP mode, per-process in stdio mode.
|
|
4
|
+
*/
|
|
5
|
+
import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
|
+
export declare const BASE_URL: string;
|
|
7
|
+
export declare function klamdo<T>(path: string, apiKey: string, body?: Record<string, unknown>): Promise<T>;
|
|
8
|
+
export declare const TOOLS: ({
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: boolean;
|
|
13
|
+
destructiveHint: boolean;
|
|
14
|
+
idempotentHint: boolean;
|
|
15
|
+
openWorldHint: boolean;
|
|
16
|
+
};
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: string;
|
|
19
|
+
properties: {
|
|
20
|
+
prompt: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
aspectRatio: {
|
|
25
|
+
type: string;
|
|
26
|
+
enum: string[];
|
|
27
|
+
description: string;
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
30
|
+
jobId?: undefined;
|
|
31
|
+
limit?: undefined;
|
|
32
|
+
};
|
|
33
|
+
required: string[];
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
annotations: {
|
|
39
|
+
readOnlyHint: boolean;
|
|
40
|
+
destructiveHint: boolean;
|
|
41
|
+
idempotentHint: boolean;
|
|
42
|
+
openWorldHint: boolean;
|
|
43
|
+
};
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: string;
|
|
46
|
+
properties: {
|
|
47
|
+
prompt: {
|
|
48
|
+
type: string;
|
|
49
|
+
description: string;
|
|
50
|
+
};
|
|
51
|
+
aspectRatio?: undefined;
|
|
52
|
+
jobId?: undefined;
|
|
53
|
+
limit?: undefined;
|
|
54
|
+
};
|
|
55
|
+
required: string[];
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
annotations: {
|
|
61
|
+
readOnlyHint: boolean;
|
|
62
|
+
destructiveHint: boolean;
|
|
63
|
+
idempotentHint: boolean;
|
|
64
|
+
openWorldHint: boolean;
|
|
65
|
+
};
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: string;
|
|
68
|
+
properties: {
|
|
69
|
+
jobId: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
prompt?: undefined;
|
|
74
|
+
aspectRatio?: undefined;
|
|
75
|
+
limit?: undefined;
|
|
76
|
+
};
|
|
77
|
+
required: string[];
|
|
78
|
+
};
|
|
79
|
+
} | {
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
annotations: {
|
|
83
|
+
readOnlyHint: boolean;
|
|
84
|
+
destructiveHint: boolean;
|
|
85
|
+
idempotentHint: boolean;
|
|
86
|
+
openWorldHint: boolean;
|
|
87
|
+
};
|
|
88
|
+
inputSchema: {
|
|
89
|
+
type: string;
|
|
90
|
+
properties: {
|
|
91
|
+
prompt?: undefined;
|
|
92
|
+
aspectRatio?: undefined;
|
|
93
|
+
jobId?: undefined;
|
|
94
|
+
limit?: undefined;
|
|
95
|
+
};
|
|
96
|
+
required?: undefined;
|
|
97
|
+
};
|
|
98
|
+
} | {
|
|
99
|
+
name: string;
|
|
100
|
+
description: string;
|
|
101
|
+
annotations: {
|
|
102
|
+
readOnlyHint: boolean;
|
|
103
|
+
destructiveHint: boolean;
|
|
104
|
+
idempotentHint: boolean;
|
|
105
|
+
openWorldHint: boolean;
|
|
106
|
+
};
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: string;
|
|
109
|
+
properties: {
|
|
110
|
+
limit: {
|
|
111
|
+
type: string;
|
|
112
|
+
description: string;
|
|
113
|
+
default: number;
|
|
114
|
+
};
|
|
115
|
+
prompt?: undefined;
|
|
116
|
+
aspectRatio?: undefined;
|
|
117
|
+
jobId?: undefined;
|
|
118
|
+
};
|
|
119
|
+
required?: undefined;
|
|
120
|
+
};
|
|
121
|
+
})[];
|
|
122
|
+
export declare function registerHandlers(server: Server, getApiKey: () => string): void;
|
|
123
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAExE,eAAO,MAAM,QAAQ,QAAsD,CAAC;AAE5E,wBAAsB,MAAM,CAAC,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CAyBZ;AAED,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoGjB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,QAsKvE"}
|