Skip to main content
Glama

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
NameRequiredDescriptionDefault
categoriesNoCategories to include (default: all)

Implementation Reference

  • 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
          }
        ]
      };
    }
  • 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 };
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'AI-ready context string' but doesn't disclose behavioral traits such as format, size limits, freshness, or whether it's cached. For a tool with no annotation coverage, this leaves significant gaps in understanding its operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function. It's front-loaded with the core purpose, though it could be slightly more specific to improve clarity without adding unnecessary length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what the 'AI-ready context string' contains, its structure, or how it differs from sibling tools. For a tool with one parameter but significant contextual ambiguity, more detail is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'categories' documented as 'Categories to include (default: all)' and a default list. The description adds no additional meaning beyond what the schema provides, so it meets the baseline for high coverage without compensating further.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get AI-ready context string for LLM consumption' states the action ('Get') and resource ('context string'), but it's vague about what specific context is retrieved. It doesn't distinguish from sibling tools like kb_get_personal or kb_get_professional, which likely fetch more specific context subsets.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. With siblings like kb_get_personal and kb_get_professional that fetch specific categories, the description lacks any indication of scope, prerequisites, or comparative use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/hlsitechio/mcp-instruct'

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