Skip to main content
Glama
Dinesh-Satram

Health & Fitness Coach MCP

context-viewer.ts2.83 kB
import { z } from "zod"; import { memoryStore } from "../utils/memoryStore"; export const contextViewerTool = { name: "view-context", description: "View your complete fitness and nutrition history and weekly targets", schema: { userId: z.string().describe("Unique user identifier"), }, handler: async ({ userId }: { userId: string }) => { try { const context = memoryStore.getContext(userId); let contextSummary = "📊 **Your Health & Fitness Summary**\n\n"; // Weekly targets if (context.weeklyTarget) { contextSummary += `🎯 **Weekly Targets (Week of ${context.weeklyTarget.weekStart}):**\n`; contextSummary += `- Target runs: ${context.weeklyTarget.targetRuns} per week\n`; contextSummary += `- Daily calorie budget: ${context.weeklyTarget.calorieBudget} calories\n\n`; } // Workouts if (context.workouts.length > 0) { contextSummary += `💪 **Recent Workouts (${context.workouts.length} total):**\n`; context.workouts.slice(-5).forEach(workout => { contextSummary += `- ${workout.date}: ${workout.type} (${workout.duration} min${workout.distance ? `, ${workout.distance} km` : ''})\n`; }); contextSummary += "\n"; } else { contextSummary += "💪 **Workouts:** No workouts logged yet\n\n"; } // Nutrition if (context.nutrition.length > 0) { contextSummary += `🍽️ **Recent Nutrition (${context.nutrition.length} entries):**\n`; context.nutrition.slice(-5).forEach(entry => { contextSummary += `- ${entry.date} (${entry.meal}): ${entry.items.join(', ')} - ${entry.calories} cal\n`; }); contextSummary += "\n"; } else { contextSummary += "🍽️ **Nutrition:** No meals logged yet\n\n"; } // Feedback if (context.feedback.length > 0) { contextSummary += `💭 **Recent Feedback (${context.feedback.length} entries):**\n`; context.feedback.slice(-3).forEach(feedback => { contextSummary += `- ${feedback.date}: ${feedback.notes}\n`; }); contextSummary += "\n"; } else { contextSummary += "💭 **Feedback:** No feedback logged yet\n\n"; } contextSummary += "---\n*Use the other tools to log workouts, nutrition, or generate a personalized plan!*"; return { content: [ { type: "text" as const, text: contextSummary, }, ], }; } catch (error) { console.error('Error viewing context:', error); return { content: [ { type: "text" as const, text: `❌ Error retrieving your data: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }, };

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/Dinesh-Satram/fitness_coach_MCP'

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