@kolbo/mcp 1.15.1 → 1.16.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/package.json +1 -1
- package/src/tools/chat.js +140 -140
- package/src/tools/generate.js +979 -979
package/package.json
CHANGED
package/src/tools/chat.js
CHANGED
|
@@ -1,140 +1,140 @@
|
|
|
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 { z } = require('zod');
|
|
7
|
-
const { pollUntilDone } = require('../polling');
|
|
8
|
-
const { creditFields } = require('./_shared');
|
|
9
|
-
|
|
10
|
-
function registerChatTools(server, client) {
|
|
11
|
-
// ─── chat_send_message ─────────────────────────────────────
|
|
12
|
-
server.tool(
|
|
13
|
-
'chat_send_message',
|
|
14
|
-
'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 image/video/audio analysis via media_urls — pass public URLs and the model auto-routes to a vision-capable model (e.g. Gemini) when media is detected. Supports web search and deep think modes.',
|
|
15
|
-
{
|
|
16
|
-
message: z.string().describe('The user message to send'),
|
|
17
|
-
model: z.string().optional().describe('Model identifier (e.g. "gpt-4o", "claude-sonnet-4-6"). Omit for Smart Select (auto) — recommended default. When media_urls contains video or audio, Smart Select automatically routes to a Gemini vision model regardless of this field.'),
|
|
18
|
-
session_id: z.string().optional().describe('Existing chat session ID to continue. Omit to start a new conversation.'),
|
|
19
|
-
system_prompt: z.string().optional().describe('System prompt for the conversation. Only applied when creating a new session.'),
|
|
20
|
-
web_search: z.boolean().optional().describe('Enable web search for this message. Default: false'),
|
|
21
|
-
deep_think: z.boolean().optional().describe('Enable deep think (extended reasoning). Default: false'),
|
|
22
|
-
enhance_prompt: z.boolean().optional().describe('
|
|
23
|
-
media_urls: z.array(z.string()).optional().describe('Public URLs of images, videos, or audio files to analyze. The model auto-routes to a vision-capable model when media is present. Use upload_media first to get a public URL for local files.')
|
|
24
|
-
},
|
|
25
|
-
async ({ message, model, session_id, system_prompt, web_search, deep_think, enhance_prompt, media_urls }) => {
|
|
26
|
-
const gen = await client.post('/v1/chat', {
|
|
27
|
-
message,
|
|
28
|
-
model,
|
|
29
|
-
session_id,
|
|
30
|
-
system_prompt,
|
|
31
|
-
web_search,
|
|
32
|
-
deep_think,
|
|
33
|
-
enhance_prompt,
|
|
34
|
-
media_urls
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Deep think reasoning can run far longer than normal chat. Also grant
|
|
38
|
-
// extra time when web_search is on (may fetch + analyze multiple pages).
|
|
39
|
-
const timeout = deep_think ? 600000 : (web_search ? 240000 : 120000);
|
|
40
|
-
|
|
41
|
-
const result = await pollUntilDone(client, gen.message_id, {
|
|
42
|
-
interval: (gen.poll_interval_hint || 2) * 1000,
|
|
43
|
-
timeout
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Chat status shape (from extractResult in kolbo-api sdk/controller.js):
|
|
47
|
-
// { content, reasoning_content, image_urls?, video_urls?, audio_urls?, model, created_at }
|
|
48
|
-
const r = result.result || {};
|
|
49
|
-
return {
|
|
50
|
-
content: [{
|
|
51
|
-
type: 'text',
|
|
52
|
-
text: JSON.stringify({
|
|
53
|
-
...creditFields(result),
|
|
54
|
-
session_id: gen.session_id,
|
|
55
|
-
message_id: gen.message_id,
|
|
56
|
-
model: r.model || gen.model,
|
|
57
|
-
content: r.content || '',
|
|
58
|
-
reasoning_content: r.reasoning_content || null,
|
|
59
|
-
image_urls: r.image_urls || null,
|
|
60
|
-
video_urls: r.video_urls || null,
|
|
61
|
-
audio_urls: r.audio_urls || null
|
|
62
|
-
}, null, 2)
|
|
63
|
-
}]
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// ─── chat_list_conversations ───────────────────────────────
|
|
69
|
-
server.tool(
|
|
70
|
-
'chat_list_conversations',
|
|
71
|
-
'List your SDK chat conversations, most-recent first. Returns session_id, name, and activity timestamps.',
|
|
72
|
-
{
|
|
73
|
-
page: z.number().optional().describe('Page number, 1-indexed. Default: 1'),
|
|
74
|
-
limit: z.number().optional().describe('Results per page, max 50. Default: 20')
|
|
75
|
-
},
|
|
76
|
-
async ({ page, limit }) => {
|
|
77
|
-
const params = new URLSearchParams();
|
|
78
|
-
if (page) params.set('page', String(page));
|
|
79
|
-
if (limit) params.set('limit', String(limit));
|
|
80
|
-
|
|
81
|
-
const qs = params.toString();
|
|
82
|
-
const result = await client.get(`/v1/chat/conversations${qs ? '?' + qs : ''}`);
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
content: [{
|
|
86
|
-
type: 'text',
|
|
87
|
-
text: JSON.stringify({
|
|
88
|
-
conversations: result.conversations || [],
|
|
89
|
-
pagination: result.pagination || null
|
|
90
|
-
}, null, 2)
|
|
91
|
-
}]
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
// ─── chat_get_messages ─────────────────────────────────────
|
|
97
|
-
server.tool(
|
|
98
|
-
'chat_get_messages',
|
|
99
|
-
'Fetch messages in a chat conversation. Returns role, content, model, and any media URLs attached to each message.',
|
|
100
|
-
{
|
|
101
|
-
session_id: z.string().describe('The chat session ID'),
|
|
102
|
-
page: z.number().optional().describe('Page number, 1-indexed. Default: 1'),
|
|
103
|
-
limit: z.number().optional().describe('Messages per page, max 100. Default: 50')
|
|
104
|
-
},
|
|
105
|
-
async ({ session_id, page, limit }) => {
|
|
106
|
-
const params = new URLSearchParams();
|
|
107
|
-
if (page) params.set('page', String(page));
|
|
108
|
-
if (limit) params.set('limit', String(limit));
|
|
109
|
-
|
|
110
|
-
const qs = params.toString();
|
|
111
|
-
const result = await client.get(
|
|
112
|
-
`/v1/chat/conversations/${encodeURIComponent(session_id)}/messages${qs ? '?' + qs : ''}`
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// Trim each message to avoid flooding context.
|
|
116
|
-
const messages = (result.messages || []).map(m => ({
|
|
117
|
-
role: m.role,
|
|
118
|
-
content: m.content,
|
|
119
|
-
model: m.model?.name || m.model?.identifier || null,
|
|
120
|
-
status: m.status,
|
|
121
|
-
created_at: m.createdAt || m.created_at,
|
|
122
|
-
image_url: m.image_url || null,
|
|
123
|
-
video_url: m.video_url || null,
|
|
124
|
-
audio_url: m.audio_url || null
|
|
125
|
-
}));
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
content: [{
|
|
129
|
-
type: 'text',
|
|
130
|
-
text: JSON.stringify({
|
|
131
|
-
messages,
|
|
132
|
-
pagination: result.pagination || null
|
|
133
|
-
}, null, 2)
|
|
134
|
-
}]
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
module.exports = { registerChatTools };
|
|
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 { z } = require('zod');
|
|
7
|
+
const { pollUntilDone } = require('../polling');
|
|
8
|
+
const { creditFields } = require('./_shared');
|
|
9
|
+
|
|
10
|
+
function registerChatTools(server, client) {
|
|
11
|
+
// ─── chat_send_message ─────────────────────────────────────
|
|
12
|
+
server.tool(
|
|
13
|
+
'chat_send_message',
|
|
14
|
+
'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 image/video/audio analysis via media_urls — pass public URLs and the model auto-routes to a vision-capable model (e.g. Gemini) when media is detected. Supports web search and deep think modes.',
|
|
15
|
+
{
|
|
16
|
+
message: z.string().describe('The user message to send'),
|
|
17
|
+
model: z.string().optional().describe('Model identifier (e.g. "gpt-4o", "claude-sonnet-4-6"). Omit for Smart Select (auto) — recommended default. When media_urls contains video or audio, Smart Select automatically routes to a Gemini vision model regardless of this field.'),
|
|
18
|
+
session_id: z.string().optional().describe('Existing chat session ID to continue. Omit to start a new conversation.'),
|
|
19
|
+
system_prompt: z.string().optional().describe('System prompt for the conversation. Only applied when creating a new session.'),
|
|
20
|
+
web_search: z.boolean().optional().describe('Enable web search for this message. Default: false'),
|
|
21
|
+
deep_think: z.boolean().optional().describe('Enable deep think (extended reasoning). Default: false'),
|
|
22
|
+
enhance_prompt: z.boolean().optional().describe('Set true to ask the API to rewrite your prompt for richer detail. Default: false — by default we send your prompt as-is.'),
|
|
23
|
+
media_urls: z.array(z.string()).optional().describe('Public URLs of images, videos, or audio files to analyze. The model auto-routes to a vision-capable model when media is present. Use upload_media first to get a public URL for local files.')
|
|
24
|
+
},
|
|
25
|
+
async ({ message, model, session_id, system_prompt, web_search, deep_think, enhance_prompt = false, media_urls }) => {
|
|
26
|
+
const gen = await client.post('/v1/chat', {
|
|
27
|
+
message,
|
|
28
|
+
model,
|
|
29
|
+
session_id,
|
|
30
|
+
system_prompt,
|
|
31
|
+
web_search,
|
|
32
|
+
deep_think,
|
|
33
|
+
enhance_prompt,
|
|
34
|
+
media_urls
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Deep think reasoning can run far longer than normal chat. Also grant
|
|
38
|
+
// extra time when web_search is on (may fetch + analyze multiple pages).
|
|
39
|
+
const timeout = deep_think ? 600000 : (web_search ? 240000 : 120000);
|
|
40
|
+
|
|
41
|
+
const result = await pollUntilDone(client, gen.message_id, {
|
|
42
|
+
interval: (gen.poll_interval_hint || 2) * 1000,
|
|
43
|
+
timeout
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Chat status shape (from extractResult in kolbo-api sdk/controller.js):
|
|
47
|
+
// { content, reasoning_content, image_urls?, video_urls?, audio_urls?, model, created_at }
|
|
48
|
+
const r = result.result || {};
|
|
49
|
+
return {
|
|
50
|
+
content: [{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: JSON.stringify({
|
|
53
|
+
...creditFields(result),
|
|
54
|
+
session_id: gen.session_id,
|
|
55
|
+
message_id: gen.message_id,
|
|
56
|
+
model: r.model || gen.model,
|
|
57
|
+
content: r.content || '',
|
|
58
|
+
reasoning_content: r.reasoning_content || null,
|
|
59
|
+
image_urls: r.image_urls || null,
|
|
60
|
+
video_urls: r.video_urls || null,
|
|
61
|
+
audio_urls: r.audio_urls || null
|
|
62
|
+
}, null, 2)
|
|
63
|
+
}]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// ─── chat_list_conversations ───────────────────────────────
|
|
69
|
+
server.tool(
|
|
70
|
+
'chat_list_conversations',
|
|
71
|
+
'List your SDK chat conversations, most-recent first. Returns session_id, name, and activity timestamps.',
|
|
72
|
+
{
|
|
73
|
+
page: z.number().optional().describe('Page number, 1-indexed. Default: 1'),
|
|
74
|
+
limit: z.number().optional().describe('Results per page, max 50. Default: 20')
|
|
75
|
+
},
|
|
76
|
+
async ({ page, limit }) => {
|
|
77
|
+
const params = new URLSearchParams();
|
|
78
|
+
if (page) params.set('page', String(page));
|
|
79
|
+
if (limit) params.set('limit', String(limit));
|
|
80
|
+
|
|
81
|
+
const qs = params.toString();
|
|
82
|
+
const result = await client.get(`/v1/chat/conversations${qs ? '?' + qs : ''}`);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
content: [{
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: JSON.stringify({
|
|
88
|
+
conversations: result.conversations || [],
|
|
89
|
+
pagination: result.pagination || null
|
|
90
|
+
}, null, 2)
|
|
91
|
+
}]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// ─── chat_get_messages ─────────────────────────────────────
|
|
97
|
+
server.tool(
|
|
98
|
+
'chat_get_messages',
|
|
99
|
+
'Fetch messages in a chat conversation. Returns role, content, model, and any media URLs attached to each message.',
|
|
100
|
+
{
|
|
101
|
+
session_id: z.string().describe('The chat session ID'),
|
|
102
|
+
page: z.number().optional().describe('Page number, 1-indexed. Default: 1'),
|
|
103
|
+
limit: z.number().optional().describe('Messages per page, max 100. Default: 50')
|
|
104
|
+
},
|
|
105
|
+
async ({ session_id, page, limit }) => {
|
|
106
|
+
const params = new URLSearchParams();
|
|
107
|
+
if (page) params.set('page', String(page));
|
|
108
|
+
if (limit) params.set('limit', String(limit));
|
|
109
|
+
|
|
110
|
+
const qs = params.toString();
|
|
111
|
+
const result = await client.get(
|
|
112
|
+
`/v1/chat/conversations/${encodeURIComponent(session_id)}/messages${qs ? '?' + qs : ''}`
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Trim each message to avoid flooding context.
|
|
116
|
+
const messages = (result.messages || []).map(m => ({
|
|
117
|
+
role: m.role,
|
|
118
|
+
content: m.content,
|
|
119
|
+
model: m.model?.name || m.model?.identifier || null,
|
|
120
|
+
status: m.status,
|
|
121
|
+
created_at: m.createdAt || m.created_at,
|
|
122
|
+
image_url: m.image_url || null,
|
|
123
|
+
video_url: m.video_url || null,
|
|
124
|
+
audio_url: m.audio_url || null
|
|
125
|
+
}));
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
content: [{
|
|
129
|
+
type: 'text',
|
|
130
|
+
text: JSON.stringify({
|
|
131
|
+
messages,
|
|
132
|
+
pagination: result.pagination || null
|
|
133
|
+
}, null, 2)
|
|
134
|
+
}]
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = { registerChatTools };
|