UNPKG

@hauptsache.net/clickup-mcp

Version:

Search, create, and retrieve tasks, add comments, and track time through natural language commands.

134 lines (129 loc) 7.53 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.serverPromise = void 0; const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js"); const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js"); const config_1 = require("./shared/config"); const utils_1 = require("./shared/utils"); // Import tool registration functions const task_tools_1 = require("./tools/task-tools"); const task_write_tools_1 = require("./tools/task-write-tools"); const search_tools_1 = require("./tools/search-tools"); const space_tools_1 = require("./tools/space-tools"); const list_tools_1 = require("./tools/list-tools"); const time_tools_1 = require("./tools/time-tools"); const doc_tools_1 = require("./tools/doc-tools"); const space_resources_1 = require("./resources/space-resources"); // Create server variable that will be initialized later let server; // Register tools based on mode with user data for enhanced documentation async function initializeServer() { console.error(`Starting ClickUp MCP in ${config_1.CONFIG.mode} mode`); // Fetch current user and spaces for enhanced tool documentation and API health check const [userData, spacesIndex] = await Promise.all([ (0, utils_1.getCurrentUser)(), (0, utils_1.getSpaceSearchIndex)() ]); const spaces = spacesIndex._docs || []; console.error(`Connected as: ${userData.user.username} (${userData.user.email})`); // Filter out archived spaces and format as simple list const activeSpaces = spaces.filter((s) => !s.archived); const formattedSpaces = activeSpaces .map((s) => `- ${s.name} (space_id: ${s.id})`) .join('\n'); const instructions = [ `ClickUp is a Ticket system. It is used to track tasks, bugs, and other work items.`, `Is you are asked for infos about projects or tasks, search for tasks or documents in ClickUp (this MCP) first.`, `The following spaces/projects are available:`, formattedSpaces ].join('\n'); console.error(`Pre-loaded ${activeSpaces.length} active spaces`); // Create the MCP server with instructions server = new mcp_js_1.McpServer({ name: "Clickup MCP", version: require('../package.json').version, }, { instructions }); // Register prompts const lang = config_1.CONFIG.primaryLanguageHint === 'de' ? 'de' : 'en'; // Register "my-todos" prompt server.registerPrompt("my-todos", { title: lang === 'de' ? "Meine TODOs" : "My TODOs", description: lang === 'de' ? "Meine aktuellen TODO-Aufgaben aus ClickUp abrufen und nach Priorität kategorisiert analysieren" : "Get and analyze my current TODO tasks from ClickUp, categorized by priority" }, () => { const messages = [{ role: "user", content: { type: "text", text: lang === 'de' ? `Kannst du in ClickUp nachsehen, was meine aktuellen TODOs sind? Bitte suche nach allen offenen Aufgaben, die mir zugewiesen sind, analysiere deren Inhalt und kategorisiere sie nach erkennbarer Priorität (dringend, hoch, normal, niedrig). Für jede Kategorie gib eine kurze Zusammenfassung dessen, was getan werden muss und hebe Fälligkeitstermine oder wichtige Details aus den Aufgabenbeschreibungen hervor. Bitte strukturiere deine Antwort mit: 1. **Zusammenfassung**: Gesamtanzahl der Aufgaben und allgemeine Prioritätsverteilung 2. **Dringende Aufgaben**: Aufgaben, die sofortige Aufmerksamkeit benötigen (heute fällig, überfällig oder als dringend markiert) 3. **Hohe Priorität**: Wichtige Aufgaben, die bald erledigt werden sollten 4. **Normale Priorität**: Regelmäßige Aufgaben, die später geplant werden können 5. **Niedrige Priorität**: Aufgaben, die erledigt werden können, wenn Zeit vorhanden ist 6. **Empfehlungen**: Vorgeschlagene Maßnahmen oder Prioritäten für den kommenden Zeitraum Verwende die ClickUp-Suchtools, um mir zugewiesene Aufgaben zu finden, und hole detaillierte Informationen über die wichtigsten mit getTaskById.` : `Can you look into ClickUp and check what my current TODO's are? Please search for all open tasks assigned to me, analyze their content, and categorize them by apparent priority (urgent, high, normal, low). For each category, provide a brief summary of what needs to be done and highlight any due dates or important details from the task descriptions. Please structure your response with: 1. **Summary**: Total number of tasks and overall priority distribution 2. **Urgent Tasks**: Tasks that need immediate attention (due today, overdue, or marked as urgent) 3. **High Priority**: Important tasks that should be addressed soon 4. **Normal Priority**: Regular tasks that can be scheduled for later 5. **Low Priority**: Tasks that can be done when time permits 6. **Recommendations**: Suggested actions or priorities for the upcoming period Use the ClickUp search tools to find tasks assigned to me, and get detailed information about the most important ones using getTaskById.` } }]; return { messages }; }); if (config_1.CONFIG.mode === 'read-minimal') { // Core task context tools for AI coding assistance // Only getTaskById and searchTasks (0, task_tools_1.registerTaskToolsRead)(server, userData); (0, search_tools_1.registerSearchTools)(server, userData); } else if (config_1.CONFIG.mode === 'read') { // All read-only tools (0, task_tools_1.registerTaskToolsRead)(server, userData); (0, search_tools_1.registerSearchTools)(server, userData); (0, space_tools_1.registerSpaceTools)(server); (0, space_resources_1.registerSpaceResources)(server); (0, list_tools_1.registerListToolsRead)(server); (0, time_tools_1.registerTimeToolsRead)(server); (0, doc_tools_1.registerDocumentToolsRead)(server); } else if (config_1.CONFIG.mode === 'write') { // All tools (full functionality) (0, task_tools_1.registerTaskToolsRead)(server, userData); (0, task_write_tools_1.registerTaskToolsWrite)(server, userData); (0, search_tools_1.registerSearchTools)(server, userData); (0, space_tools_1.registerSpaceTools)(server); (0, space_resources_1.registerSpaceResources)(server); (0, list_tools_1.registerListToolsRead)(server); (0, list_tools_1.registerListToolsWrite)(server); (0, time_tools_1.registerTimeToolsRead)(server); (0, time_tools_1.registerTimeToolsWrite)(server); (0, doc_tools_1.registerDocumentToolsRead)(server); (0, doc_tools_1.registerDocumentToolsWrite)(server); } return server; } // Initialize server with enhanced documentation and export const serverPromise = initializeServer(); exports.serverPromise = serverPromise; // Only connect to the transport if this file is being run directly (not imported) // OR if not being imported by CLI (to support Claude Desktop's module loading) const isCliMode = process.argv.some(arg => arg.includes('cli.ts') || arg.includes('cli.js')); if (require.main === module || !isCliMode) { // Start receiving messages on stdin and sending messages on stdout after initialization serverPromise.then(() => { const transport = new stdio_js_1.StdioServerTransport(); server.connect(transport); }).catch(console.error); }