Skip to main content
Glama
marlondivino

OpenCode MCP Server

by marlondivino

learn_context

Store preferences, rules, or context to reuse later, reducing token cost and enriching future prompts.

Instructions

Memorizes important information (preference, technical rule, context) for future use.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
informationYesThe information to be remembered.
categoryNoInformation category (e.g., 'preference', 'architecture', 'style').

Implementation Reference

  • src/index.ts:89-108 (registration)
    Tool registration for 'learn_context' with description and inputSchema (information: string, category: optional string)
        {
          name: "learn_context",
          description: "Memorizes important information (preference, technical rule, context) for future use.",
          inputSchema: {
            type: "object",
            properties: {
              information: {
                type: "string",
                description: "The information to be remembered.",
              },
              category: {
                type: "string",
                description: "Information category (e.g., 'preference', 'architecture', 'style').",
              },
            },
            required: ["information"],
          },
        },
      ],
    };
  • Handler for 'learn_context' tool: extracts 'information' and optional 'category' args, generates an embedding via Ollama, stores the vector + text + category + timestamp into a LanceDB table, and returns a confirmation message.
    if (name === "learn_context") {
      const info = args?.information as string;
      const category = (args?.category as string) || "general";
      
      const vector = await getEmbedding(info);
      
      const data = [{
        vector,
        text: info,
        category,
        timestamp: new Date().toISOString()
      }];
    
      if (!table) {
        table = await db.createTable(TABLE_NAME, data);
      } else {
        await table.add(data);
      }
    
      return {
        content: [{ type: "text", text: `Learned and stored in semantic memory: "${info}"` }],
      };
    }
  • getEmbedding helper function that calls Ollama's embed API with 'nomic-embed-text' model to convert text to a vector.
    async function getEmbedding(text: string): Promise<number[]> {
      const response = await ollama.embed({
        model: EMBEDDING_MODEL,
        input: text,
      });
      return response.embeddings[0]!;
    }
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It says 'memorizes... for future use' but lacks details on persistence, scope, or retrieval, leaving significant ambiguity about the tool's behavior.

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

Conciseness5/5

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

The description is a single, concise sentence with no redundant words. Every part serves to define the tool's purpose efficiently.

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

Completeness4/5

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

For a simple tool with two parameters and no output schema, the description covers the core functionality. However, it lacks context about when to prefer this over the sibling tool, which slightly reduces completeness.

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 coverage is 100% (both parameters have descriptions). The description adds minimal value beyond the schema, citing examples like 'preference, technical rule, context', which weakly maps to the 'category' parameter. Baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the verb 'memorizes' and the resource 'important information', listing examples like preferences and technical rules. It effectively distinguishes from the sibling tool 'refine_prompt' which has a different purpose.

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?

The description gives no guidance on when to use this tool versus alternatives, nor does it specify when not to use it. It only implies usage for storing information without context about trade-offs.

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/marlondivino/open-code-as-mcp'

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