UNPKG

hackmd-mcp

Version:

[![smithery badge](https://smithery.ai/badge/@yuna0x0/hackmd-mcp)](https://smithery.ai/server/@yuna0x0/hackmd-mcp)

97 lines (96 loc) 3.27 kB
import { z } from "zod"; import { CreateNoteOptionsSchema, UpdateNoteOptionsSchema, } from "../utils/schemas.js"; export function registerTeamNotesApiTools(server, client) { // Tool: List team notes server.tool("list_team_notes", "List all notes in a team", { teamPath: z.string().describe("Team path"), }, async ({ teamPath }) => { try { const notes = await client.getTeamNotes(teamPath); return { content: [ { type: "text", text: JSON.stringify(notes, null, 2), }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }); // Tool: Create a team note server.tool("create_team_note", "Create a new note in a team", { teamPath: z.string().describe("Team path"), payload: CreateNoteOptionsSchema.describe("Create note options"), }, async ({ teamPath, payload }) => { try { const note = await client.createTeamNote(teamPath, payload); return { content: [ { type: "text", text: `Team note created successfully:\n${JSON.stringify(note, null, 2)}`, }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }); // Tool: Update a team note server.tool("update_team_note", "Update an existing note in a team", { teamPath: z.string().describe("Team path"), noteId: z.string().describe("Note ID"), options: UpdateNoteOptionsSchema.describe("Update note options"), }, async ({ teamPath, noteId, options }) => { try { await client.updateTeamNote(teamPath, noteId, options); return { content: [ { type: "text", text: `Team note ${noteId} updated successfully`, }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }); // Tool: Delete a team note server.tool("delete_team_note", "Delete a note in a team", { teamPath: z.string().describe("Team path"), noteId: z.string().describe("Note ID"), }, async ({ teamPath, noteId }) => { try { await client.deleteTeamNote(teamPath, noteId); return { content: [ { type: "text", text: `Team note ${noteId} deleted successfully`, }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }); }