kb_get_context
Retrieve structured personal and professional context for AI assistants to understand user identity, preferences, and projects across sessions.
Instructions
Get AI-ready context string for LLM consumption
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| categories | No | Categories to include (default: all) |
Implementation Reference
- src/index.ts:762-815 (handler)The handler for 'kb_get_context' tool. It constructs a formatted markdown context string from the user's knowledge base categories (personal, professional, preferences, projects) based on input categories, using km.getKnowledgeBase(), and returns it as MCP text content.case 'kb_get_context': { const categories = (args as any).categories || ['personal', 'professional', 'preferences', 'projects']; const kb = km.getKnowledgeBase(); let context = '=== USER CONTEXT ===\n\n'; if ((categories as any[]).includes('personal') && Object.keys(kb.personal).length > 0) { context += '**Personal Information:**\n'; if (kb.personal.name) context += `- Name: ${kb.personal.name}\n`; if (kb.personal.currentLocation) context += `- Location: ${kb.personal.currentLocation}\n`; if (kb.personal.languages?.length) context += `- Languages: ${kb.personal.languages.join(', ')}\n`; if (kb.personal.birthYear) context += `- Birth Year: ${kb.personal.birthYear}\n`; if (kb.personal.pronouns) context += `- Pronouns: ${kb.personal.pronouns}\n`; context += '\n'; } if ((categories as any[]).includes('professional') && Object.keys(kb.professional).length > 0) { context += '**Professional Background:**\n'; if (kb.professional.occupation) context += `- Occupation: ${kb.professional.occupation}\n`; if (kb.professional.yearsOfExperience) context += `- Experience: ${kb.professional.yearsOfExperience} years\n`; if (kb.professional.industry) context += `- Industry: ${kb.professional.industry}\n`; if (kb.professional.skills?.length) context += `- Skills: ${kb.professional.skills.join(', ')}\n`; if (kb.professional.specializations?.length) context += `- Specializations: ${kb.professional.specializations.join(', ')}\n`; context += '\n'; } if ((categories as any[]).includes('preferences') && Object.keys(kb.preferences).length > 0) { context += '**Communication Preferences:**\n'; if (kb.preferences.communicationStyle) context += `- Style: ${kb.preferences.communicationStyle}\n`; if (kb.preferences.responseDetail) context += `- Response Detail: ${kb.preferences.responseDetail}\n`; if (kb.preferences.technicalLevel) context += `- Technical Level: ${kb.preferences.technicalLevel}\n`; if (kb.preferences.favoriteTools?.length) context += `- Favorite Tools: ${kb.preferences.favoriteTools.join(', ')}\n`; context += '\n'; } if ((categories as any[]).includes('projects') && Object.keys(kb.projects).length > 0) { context += '**Current Projects:**\n'; if (kb.projects.currentProjects?.length) context += `- Projects: ${kb.projects.currentProjects.join(', ')}\n`; if (kb.projects.technologies?.length) context += `- Technologies: ${kb.projects.technologies.join(', ')}\n`; if (kb.projects.goals?.length) context += `- Goals: ${kb.projects.goals.join(', ')}\n`; context += '\n'; } context += '=== END CONTEXT ==='; return { content: [ { type: 'text', text: context } ] }; }
- src/index.ts:271-285 (schema)The schema definition for the 'kb_get_context' tool, including name, description, and input schema specifying optional 'categories' array.{ name: 'kb_get_context', description: 'Get AI-ready context string for LLM consumption', inputSchema: { type: 'object', properties: { categories: { type: 'array', items: { type: 'string' }, description: 'Categories to include (default: all)', default: ['personal', 'professional', 'preferences', 'projects'] } } } },
- src/index.ts:423-425 (registration)The tool list registration handler that returns the static 'tools' array containing 'kb_get_context', making it discoverable via MCP ListTools.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });