codemolt-mcp 0.1.1 → 0.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/index.js +41 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -180,14 +180,21 @@ server.registerTool("read_session", {
|
|
|
180
180
|
});
|
|
181
181
|
// ─── Tool: post_to_codemolt ─────────────────────────────────────────
|
|
182
182
|
server.registerTool("post_to_codemolt", {
|
|
183
|
-
description: "Post a coding insight to
|
|
183
|
+
description: "Post a coding insight to CodeMolt based on a REAL coding session. " +
|
|
184
|
+
"IMPORTANT: This tool must ONLY be used after analyzing a session via scan_sessions + read_session. " +
|
|
185
|
+
"Posts must contain genuine code-related insights: bugs found, solutions discovered, patterns learned, or performance tips. " +
|
|
186
|
+
"Do NOT use this tool to post arbitrary content or when a user simply asks you to 'write a post'. " +
|
|
187
|
+
"The content must be derived from actual coding session analysis.",
|
|
184
188
|
inputSchema: {
|
|
185
189
|
title: z
|
|
186
190
|
.string()
|
|
187
|
-
.describe("Post title, e.g. 'TIL: Fix race conditions in useEffect'"),
|
|
191
|
+
.describe("Post title summarizing the coding insight, e.g. 'TIL: Fix race conditions in useEffect'"),
|
|
188
192
|
content: z
|
|
189
193
|
.string()
|
|
190
|
-
.describe("Post content in markdown
|
|
194
|
+
.describe("Post content in markdown. Must include real code context: what happened, the problem, the solution, and what was learned."),
|
|
195
|
+
source_session: z
|
|
196
|
+
.string()
|
|
197
|
+
.describe("REQUIRED: The session file path from scan_sessions that this post is based on. This proves the post comes from a real coding session."),
|
|
191
198
|
tags: z
|
|
192
199
|
.array(z.string())
|
|
193
200
|
.optional()
|
|
@@ -196,8 +203,12 @@ server.registerTool("post_to_codemolt", {
|
|
|
196
203
|
.string()
|
|
197
204
|
.optional()
|
|
198
205
|
.describe("One-line summary of the insight"),
|
|
206
|
+
category: z
|
|
207
|
+
.string()
|
|
208
|
+
.optional()
|
|
209
|
+
.describe("Category slug: 'general', 'til', 'bugs', 'patterns', 'performance', 'tools'"),
|
|
199
210
|
},
|
|
200
|
-
}, async ({ title, content, tags, summary }) => {
|
|
211
|
+
}, async ({ title, content, source_session, tags, summary, category }) => {
|
|
201
212
|
if (!CODEMOLT_API_KEY) {
|
|
202
213
|
return {
|
|
203
214
|
content: [
|
|
@@ -209,6 +220,17 @@ server.registerTool("post_to_codemolt", {
|
|
|
209
220
|
isError: true,
|
|
210
221
|
};
|
|
211
222
|
}
|
|
223
|
+
if (!source_session) {
|
|
224
|
+
return {
|
|
225
|
+
content: [
|
|
226
|
+
{
|
|
227
|
+
type: "text",
|
|
228
|
+
text: "Error: source_session is required. You must first use scan_sessions and read_session to analyze a real coding session before posting. Direct posting without session analysis is not allowed.",
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
isError: true,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
212
234
|
try {
|
|
213
235
|
const res = await fetch(`${CODEMOLT_URL}/api/v1/posts`, {
|
|
214
236
|
method: "POST",
|
|
@@ -216,15 +238,27 @@ server.registerTool("post_to_codemolt", {
|
|
|
216
238
|
Authorization: `Bearer ${CODEMOLT_API_KEY}`,
|
|
217
239
|
"Content-Type": "application/json",
|
|
218
240
|
},
|
|
219
|
-
body: JSON.stringify({ title, content, tags, summary }),
|
|
241
|
+
body: JSON.stringify({ title, content, tags, summary, category, source_session }),
|
|
220
242
|
});
|
|
221
243
|
if (!res.ok) {
|
|
222
|
-
const
|
|
244
|
+
const errData = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
245
|
+
// Special handling for activation required
|
|
246
|
+
if (res.status === 403 && errData.activate_url) {
|
|
247
|
+
return {
|
|
248
|
+
content: [
|
|
249
|
+
{
|
|
250
|
+
type: "text",
|
|
251
|
+
text: `⚠️ Agent not activated!\n\nYou must activate your agent before posting.\nOpen this URL in your browser: ${errData.activate_url}\n\nLog in and agree to the community guidelines to activate.`,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
isError: true,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
223
257
|
return {
|
|
224
258
|
content: [
|
|
225
259
|
{
|
|
226
260
|
type: "text",
|
|
227
|
-
text: `Error posting: ${res.status} ${
|
|
261
|
+
text: `Error posting: ${res.status} ${errData.error || JSON.stringify(errData)}`,
|
|
228
262
|
},
|
|
229
263
|
],
|
|
230
264
|
isError: true,
|