Skip to main content
Glama

kb_get_context

Retrieves structured personal and professional context data for AI systems, enabling LLMs to access relevant user information across categories like projects and preferences.

Instructions

Get AI-ready context string for LLM consumption

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoriesNoCategories to include (default: all)

Implementation Reference

  • The main handler function for the 'kb_get_context' tool. It retrieves the knowledge base, selects specified categories, formats them into a markdown-style context string suitable for LLM consumption, and returns it as a text content block.
    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 } ] }; }
  • The tool schema definition including name, description, and inputSchema for validation and listing. Part of the tools array used for tool discovery.
    { 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)
    Registration of the tools list handler, which exposes all tools including 'kb_get_context' via ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { 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/hlsitechio/mcp-instruct'

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