@kolbo/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/README.md +59 -11
- package/package.json +14 -5
- package/src/client.js +85 -2
- package/src/index.js +68 -0
- package/src/polling.js +32 -6
- package/src/tools/_shared.js +212 -0
- package/src/tools/chat.js +135 -0
- package/src/tools/generate.js +723 -224
- package/src/tools/media.js +77 -0
- package/src/tools/models.js +5 -0
- package/src/tools/moodboards.js +45 -0
- package/src/tools/presets.js +34 -0
- package/src/tools/visual_dna.js +134 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* ⛔ BACKWARD COMPATIBILITY: Tool names and arg names below are a PUBLIC
|
|
2
|
+
* CONTRACT. Never rename, remove, or break an existing tool/arg — old cached
|
|
3
|
+
* `npx @kolbo/mcp` installs in the wild will break silently. Add new tools or
|
|
4
|
+
* new OPTIONAL args only. Full rules: ../index.js top-of-file and CLAUDE.md. */
|
|
5
|
+
|
|
6
|
+
const { pollUntilDone } = require('../polling');
|
|
7
|
+
|
|
8
|
+
function registerChatTools(server, client) {
|
|
9
|
+
// ─── chat_send_message ─────────────────────────────────────
|
|
10
|
+
server.tool(
|
|
11
|
+
'chat_send_message',
|
|
12
|
+
'Send a chat message to Kolbo AI. Starts a new conversation (omit session_id) or continues an existing one. Returns the assistant response when complete. Supports web search and deep think modes.',
|
|
13
|
+
{
|
|
14
|
+
message: { type: 'string', description: 'The user message to send' },
|
|
15
|
+
model: { type: 'string', description: 'Model identifier (e.g. "gpt-4o", "claude-sonnet-4-5"). Omit for Smart Select (auto).' },
|
|
16
|
+
session_id: { type: 'string', description: 'Existing chat session ID to continue. Omit to start a new conversation.' },
|
|
17
|
+
system_prompt: { type: 'string', description: 'System prompt for the conversation. Only applied when creating a new session.' },
|
|
18
|
+
web_search: { type: 'boolean', description: 'Enable web search for this message. Default: false' },
|
|
19
|
+
deep_think: { type: 'boolean', description: 'Enable deep think (extended reasoning). Default: false' },
|
|
20
|
+
enhance_prompt: { type: 'boolean', description: 'Enhance the prompt. Default: true' }
|
|
21
|
+
},
|
|
22
|
+
async ({ message, model, session_id, system_prompt, web_search, deep_think, enhance_prompt }) => {
|
|
23
|
+
const gen = await client.post('/v1/chat', {
|
|
24
|
+
message,
|
|
25
|
+
model,
|
|
26
|
+
session_id,
|
|
27
|
+
system_prompt,
|
|
28
|
+
web_search,
|
|
29
|
+
deep_think,
|
|
30
|
+
enhance_prompt
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Deep think reasoning can run far longer than normal chat. Also grant
|
|
34
|
+
// extra time when web_search is on (may fetch + analyze multiple pages).
|
|
35
|
+
const timeout = deep_think ? 600000 : (web_search ? 240000 : 120000);
|
|
36
|
+
|
|
37
|
+
const result = await pollUntilDone(client, gen.message_id, {
|
|
38
|
+
interval: (gen.poll_interval_hint || 2) * 1000,
|
|
39
|
+
timeout
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Chat status shape (from extractResult in kolbo-api sdk/controller.js):
|
|
43
|
+
// { content, reasoning_content, image_urls?, video_urls?, audio_urls?, model, created_at }
|
|
44
|
+
const r = result.result || {};
|
|
45
|
+
return {
|
|
46
|
+
content: [{
|
|
47
|
+
type: 'text',
|
|
48
|
+
text: JSON.stringify({
|
|
49
|
+
session_id: gen.session_id,
|
|
50
|
+
message_id: gen.message_id,
|
|
51
|
+
model: r.model || gen.model,
|
|
52
|
+
content: r.content || '',
|
|
53
|
+
reasoning_content: r.reasoning_content || null,
|
|
54
|
+
image_urls: r.image_urls || null,
|
|
55
|
+
video_urls: r.video_urls || null,
|
|
56
|
+
audio_urls: r.audio_urls || null
|
|
57
|
+
}, null, 2)
|
|
58
|
+
}]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// ─── chat_list_conversations ───────────────────────────────
|
|
64
|
+
server.tool(
|
|
65
|
+
'chat_list_conversations',
|
|
66
|
+
'List your SDK chat conversations, most-recent first. Returns session_id, name, and activity timestamps.',
|
|
67
|
+
{
|
|
68
|
+
page: { type: 'number', description: 'Page number, 1-indexed. Default: 1' },
|
|
69
|
+
limit: { type: 'number', description: 'Results per page, max 50. Default: 20' }
|
|
70
|
+
},
|
|
71
|
+
async ({ page, limit }) => {
|
|
72
|
+
const params = new URLSearchParams();
|
|
73
|
+
if (page) params.set('page', String(page));
|
|
74
|
+
if (limit) params.set('limit', String(limit));
|
|
75
|
+
|
|
76
|
+
const qs = params.toString();
|
|
77
|
+
const result = await client.get(`/v1/chat/conversations${qs ? '?' + qs : ''}`);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
content: [{
|
|
81
|
+
type: 'text',
|
|
82
|
+
text: JSON.stringify({
|
|
83
|
+
conversations: result.conversations || [],
|
|
84
|
+
pagination: result.pagination || null
|
|
85
|
+
}, null, 2)
|
|
86
|
+
}]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// ─── chat_get_messages ─────────────────────────────────────
|
|
92
|
+
server.tool(
|
|
93
|
+
'chat_get_messages',
|
|
94
|
+
'Fetch messages in a chat conversation. Returns role, content, model, and any media URLs attached to each message.',
|
|
95
|
+
{
|
|
96
|
+
session_id: { type: 'string', description: 'The chat session ID' },
|
|
97
|
+
page: { type: 'number', description: 'Page number, 1-indexed. Default: 1' },
|
|
98
|
+
limit: { type: 'number', description: 'Messages per page, max 100. Default: 50' }
|
|
99
|
+
},
|
|
100
|
+
async ({ session_id, page, limit }) => {
|
|
101
|
+
const params = new URLSearchParams();
|
|
102
|
+
if (page) params.set('page', String(page));
|
|
103
|
+
if (limit) params.set('limit', String(limit));
|
|
104
|
+
|
|
105
|
+
const qs = params.toString();
|
|
106
|
+
const result = await client.get(
|
|
107
|
+
`/v1/chat/conversations/${encodeURIComponent(session_id)}/messages${qs ? '?' + qs : ''}`
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// Trim each message to avoid flooding context.
|
|
111
|
+
const messages = (result.messages || []).map(m => ({
|
|
112
|
+
role: m.role,
|
|
113
|
+
content: m.content,
|
|
114
|
+
model: m.model?.name || m.model?.identifier || null,
|
|
115
|
+
status: m.status,
|
|
116
|
+
created_at: m.createdAt || m.created_at,
|
|
117
|
+
image_url: m.image_url || null,
|
|
118
|
+
video_url: m.video_url || null,
|
|
119
|
+
audio_url: m.audio_url || null
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
content: [{
|
|
124
|
+
type: 'text',
|
|
125
|
+
text: JSON.stringify({
|
|
126
|
+
messages,
|
|
127
|
+
pagination: result.pagination || null
|
|
128
|
+
}, null, 2)
|
|
129
|
+
}]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
module.exports = { registerChatTools };
|