@dayby/mcp-server 0.1.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +90 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -117,6 +117,7 @@ async function main() {
117
117
  sanitizedTitle: titleResult.clean,
118
118
  sanitizedContent: contentResult.clean,
119
119
  strippedItems: allStripped,
120
+ visibility,
120
121
  createdAt: new Date(),
121
122
  };
122
123
  drafts.set(draftId, draft);
@@ -149,7 +150,8 @@ async function main() {
149
150
  draft_id: zod_1.z.string().describe('The draft ID from draft_post'),
150
151
  title: zod_1.z.string().optional().describe('Updated title (will be re-sanitized)'),
151
152
  content: zod_1.z.string().optional().describe('Updated content (will be re-sanitized)'),
152
- }, async ({ draft_id, title, content }) => {
153
+ visibility: zod_1.z.enum(['published', 'draft']).optional().describe('Updated visibility'),
154
+ }, async ({ draft_id, title, content, visibility }) => {
153
155
  const draft = drafts.get(draft_id);
154
156
  if (!draft) {
155
157
  return {
@@ -167,9 +169,13 @@ async function main() {
167
169
  draft.originalContent = content;
168
170
  draft.strippedItems.push(...result.stripped);
169
171
  }
172
+ if (visibility) {
173
+ draft.visibility = visibility;
174
+ }
170
175
  let response = `✏️ **Draft Updated** (ID: ${draft_id})\n\n`;
171
176
  response += `**Title:** ${draft.sanitizedTitle}\n\n`;
172
177
  response += `**Content:**\n${draft.sanitizedContent}\n\n`;
178
+ response += `**Visibility:** ${draft.visibility}\n`;
173
179
  response += `\n👉 Use **publish_post** with draft ID: \`${draft_id}\` when ready.`;
174
180
  return { content: [{ type: 'text', text: response }] };
175
181
  });
@@ -200,6 +206,7 @@ async function main() {
200
206
  const result = await client.createPost({
201
207
  title: draft.sanitizedTitle,
202
208
  content: draft.sanitizedContent,
209
+ visibility: draft.visibility,
203
210
  });
204
211
  let response = `✅ **Published to DayBy!**\n\n`;
205
212
  response += `**Title:** ${result.post.title}\n`;
@@ -259,6 +266,88 @@ async function main() {
259
266
  }
260
267
  });
261
268
  // ========================================
269
+ // Tool: get_post
270
+ // ========================================
271
+ server.tool('get_post', 'Get a single DayBy post by its slug.', {
272
+ slug: zod_1.z.string().describe('The post slug'),
273
+ }, async ({ slug }) => {
274
+ if (!config.apiKey) {
275
+ return { content: [{ type: 'text', text: '❌ No API key configured.' }] };
276
+ }
277
+ try {
278
+ const result = await client.getPost(slug);
279
+ const post = result.post;
280
+ let response = `📄 **${post.title}**\n\n`;
281
+ response += `**Slug:** ${post.slug}\n`;
282
+ response += `**URL:** ${post.url}\n`;
283
+ response += `**Visibility:** ${post.visibility}\n`;
284
+ response += `**Created:** ${post.created_at.slice(0, 10)}\n\n`;
285
+ response += post.content;
286
+ return { content: [{ type: 'text', text: response }] };
287
+ }
288
+ catch (e) {
289
+ return {
290
+ content: [{ type: 'text', text: `❌ Failed to get post: ${e instanceof Error ? e.message : 'Unknown error'}` }],
291
+ };
292
+ }
293
+ });
294
+ // ========================================
295
+ // Tool: update_post
296
+ // ========================================
297
+ server.tool('update_post', 'Update an existing DayBy post by slug. Content is sanitized locally before sending.', {
298
+ slug: zod_1.z.string().describe('The post slug to update'),
299
+ title: zod_1.z.string().optional().describe('New title (will be sanitized)'),
300
+ content: zod_1.z.string().optional().describe('New content (will be sanitized)'),
301
+ visibility: zod_1.z.enum(['published', 'draft']).optional().describe('New visibility'),
302
+ }, async ({ slug, title, content, visibility }) => {
303
+ if (!config.apiKey) {
304
+ return { content: [{ type: 'text', text: '❌ No API key configured.' }] };
305
+ }
306
+ const params = {};
307
+ if (title)
308
+ params.title = sanitizer.sanitize(title).clean;
309
+ if (content)
310
+ params.content = sanitizer.sanitize(content).clean;
311
+ if (visibility)
312
+ params.visibility = visibility;
313
+ if (Object.keys(params).length === 0) {
314
+ return { content: [{ type: 'text', text: '❌ Provide at least one field to update (title, content, or visibility).' }] };
315
+ }
316
+ try {
317
+ const result = await client.updatePost(slug, params);
318
+ const post = result.post;
319
+ let response = `✅ **Post Updated**\n\n`;
320
+ response += `**Title:** ${post.title}\n`;
321
+ response += `**URL:** ${post.url}\n`;
322
+ response += `**Visibility:** ${post.visibility}\n`;
323
+ return { content: [{ type: 'text', text: response }] };
324
+ }
325
+ catch (e) {
326
+ return {
327
+ content: [{ type: 'text', text: `❌ Failed to update post: ${e instanceof Error ? e.message : 'Unknown error'}` }],
328
+ };
329
+ }
330
+ });
331
+ // ========================================
332
+ // Tool: delete_post
333
+ // ========================================
334
+ server.tool('delete_post', 'Permanently delete a DayBy post by its slug.', {
335
+ slug: zod_1.z.string().describe('The post slug to delete'),
336
+ }, async ({ slug }) => {
337
+ if (!config.apiKey) {
338
+ return { content: [{ type: 'text', text: '❌ No API key configured.' }] };
339
+ }
340
+ try {
341
+ const result = await client.deletePost(slug);
342
+ return { content: [{ type: 'text', text: `✅ ${result.message || 'Post deleted.'}` }] };
343
+ }
344
+ catch (e) {
345
+ return {
346
+ content: [{ type: 'text', text: `❌ Failed to delete post: ${e instanceof Error ? e.message : 'Unknown error'}` }],
347
+ };
348
+ }
349
+ });
350
+ // ========================================
262
351
  // Tool: check_content
263
352
  // Dry-run sanitization — see what would get stripped without creating a draft.
264
353
  // ========================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dayby/mcp-server",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "DayBy MCP Server — Post your dev progress from Claude, Cursor, or any MCP client. Local sanitization built in.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {