Skip to main content
Glama

capture

Capture and route text input through an ADHD-friendly AI system for automatic context detection and intelligent task organization, reducing cognitive overhead.

Instructions

Capture and route text input using ChurnFlow ADHD-friendly AI system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoOptional context hint for routing (business, personal, project, system)
priorityNoPriority level for the captured content
textYesText to capture and route (can contain multiple items)

Implementation Reference

  • The MCP 'capture' tool handler function. Initializes the CaptureEngine, processes input arguments into CaptureInput, executes capture, and returns formatted MCP CallToolResult with success summary or error.
    /** * Handle capture tool requests */ async function handleCapture(args: any): Promise<CallToolResult> { try { await initializeCaptureEngine(); if (!captureEngine) { throw new Error('Failed to initialize capture engine'); } const input: CaptureInput = { text: args.text, inputType: 'text', forceContext: args.context, }; const result: CaptureResult = await captureEngine.capture(input); if (!result.success) { return { content: [ { type: 'text', text: `Capture failed: ${result.error}`, }, ], isError: true, }; } // Format successful capture result const summary = [ `βœ… Capture Successful!`, `πŸ“ Primary Tracker: ${result.primaryTracker}`, `🎯 Confidence: ${Math.round(result.confidence * 100)}%`, `πŸ“Š Generated ${result.itemResults?.length || 0} items`, '', ]; if (result.itemResults && result.itemResults.length > 0) { summary.push('πŸ“ Items Generated:'); result.itemResults.forEach(item => { summary.push(` βœ… ${item.itemType} β†’ ${item.tracker}`); summary.push(` ${item.formattedEntry}`); }); } if (result.completedTasks && result.completedTasks.length > 0) { summary.push(''); summary.push('🎯 Task Completions:'); result.completedTasks.forEach(completion => { summary.push(` βœ… completion in ${completion.tracker}`); summary.push(` ${completion.description}`); }); } return { content: [ { type: 'text', text: summary.join('\n'), }, ], isError: false, }; } catch (error) { return { content: [ { type: 'text', text: `Error during capture: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • JSON schema definition for the 'capture' tool input, including required 'text' field and optional 'priority' and 'context'.
    { name: 'capture', description: 'Capture and route text input using ChurnFlow ADHD-friendly AI system', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Text to capture and route (can contain multiple items)', }, priority: { type: 'string', enum: ['high', 'medium', 'low'], description: 'Priority level for the captured content', }, context: { type: 'string', description: 'Optional context hint for routing (business, personal, project, system)', }, }, required: ['text'], }, },
  • src/index.ts:334-350 (registration)
    Registration of CallToolRequestHandler with switch statement that dispatches calls to 'capture' tool to the handleCapture function.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; switch (name) { case 'capture': return await handleCapture(args); case 'status': return await handleStatus(); case 'list_trackers': return await handleListTrackers(args); default: throw new Error(`Unknown tool: ${name}`); } });
  • src/index.ts:329-331 (registration)
    Registration of ListToolsRequestHandler that returns the list of available tools including 'capture'.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS }; });
  • Core implementation of capture logic in CaptureEngine class: AI inference, item/task processing, routing to trackers, database save, error handling with review/emergency fallbacks.
    async capture(input: string | CaptureInput): Promise<CaptureResult> { if (!this.initialized) { await this.initialize(); } // Normalize input const captureInput: CaptureInput = typeof input === "string" ? { text: input, inputType: "text" } : input; console.log(`🎯 Capturing: "${captureInput.text}"`); try { // Use AI to infer routing and generate multiple items const inference = await this.inferenceEngine.inferCapture(captureInput); console.log( `πŸ€– AI inference: ${inference.primaryTracker} (${inference.confidence * 100}% confidence)`, ); console.log(`πŸ“ Analysis: ${inference.overallReasoning}`); console.log( `πŸ”’ Generated ${inference.generatedItems.length} items, ${inference.taskCompletions.length} completions`, ); // Handle low confidence - route to review if (inference.requiresReview) { return await this.routeToReview(captureInput, inference); } // Process task completions first const completedTasks = []; for (const completion of inference.taskCompletions) { console.log(`βœ… Task completion detected: ${completion.description} in ${completion.tracker}`); // Actually mark the task as complete in the tracker file const success = await this.trackerManager.markTaskComplete( completion.tracker, completion.description ); completedTasks.push({ ...completion, success }); if (success) { console.log(`βœ… Successfully marked task as complete: ${completion.description}`); } else { console.error(`❌ Failed to mark task as complete: ${completion.description}`); } } // Process generated items const itemResults = []; for (const item of inference.generatedItems) { console.log( `πŸ“ Processing ${item.itemType} for ${item.tracker}: ${item.reasoning}`, ); let success: boolean; if (item.itemType === "activity") { success = await this.trackerManager.appendActivityToTracker( item.tracker, item.content, ); } else { success = await this.trackerManager.appendToTracker( item.tracker, item.content, ); } itemResults.push({ success, tracker: item.tracker, itemType: item.itemType, formattedEntry: item.content, error: success ? undefined : `Failed to write to ${item.tracker}`, }); if (success) { console.log( `βœ… ${item.itemType} successfully added to ${item.tracker}`, ); } else { console.error(`❌ Failed to add ${item.itemType} to ${item.tracker}`); } } // Determine overall success const overallSuccess = itemResults.some((result) => result.success); // Save to database if available (optional - doesn't affect capture success) if (overallSuccess && this.databaseAvailable) { try { await this.saveCaptureToDatabase(captureInput, inference, itemResults, overallSuccess); } catch (dbError) { console.warn("⚠️ Failed to save to database (file saved successfully):", dbError); } } return { success: overallSuccess, primaryTracker: inference.primaryTracker, confidence: inference.confidence, itemResults, completedTasks, requiresReview: false, }; } catch (error) { console.error("❌ Capture failed:", error); // Emergency fallback - try to save somewhere return await this.emergencyCapture(captureInput, error as Error); } }

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jgsteeler/churnflow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server