Skip to main content
Glama

context

Retrieve relevant past memories based on current work context to maintain continuity across AI agent sessions.

Instructions

Automatically retrieve relevant memories based on what you're currently working on. Use at the start of a session or when switching tasks to load relevant past context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
current_contextYesA summary of what you're currently working on or discussing. The more specific, the better the recalled memories will be.
agent_idNoIdentifier for this agent instancedefault
user_idNoUser identifier to include user-scoped memories
max_memoriesNoMaximum number of memories to return

Implementation Reference

  • The handler function for the 'context' tool, which calls the '/memories/context' API endpoint.
    async ({ current_context, agent_id, user_id, max_memories }) => {
      const result = await apiCall("/memories/context", "POST", {
        agent_id,
        user_id,
        current_context,
        max_memories,
      });
    
      const memories = (
        result as {
          memories: Array<{
            id: string;
            content: string;
            relevance_score: number;
            scope: string;
          }>;
        }
      ).memories;
    
      if (memories.length === 0) {
        return {
          content: [
            {
              type: "text" as const,
              text: "No relevant past context found. This appears to be a new topic.",
            },
          ],
        };
      }
  • The registration of the 'context' tool including its schema definition.
    // Tool 4: context
    server.tool(
      "context",
      "Automatically retrieve relevant memories based on what you're currently working on. Use at the start of a session or when switching tasks to load relevant past context.",
      {
        current_context: z
          .string()
          .describe(
            "A summary of what you're currently working on or discussing. The more specific, the better the recalled memories will be.",
          ),
        agent_id: z
          .string()
          .default("default")
          .describe("Identifier for this agent instance"),
        user_id: z
          .string()
          .optional()
          .describe("User identifier to include user-scoped memories"),
        max_memories: z
          .number()
          .int()
          .min(1)
          .max(20)
          .default(5)
          .describe("Maximum number of memories to return"),
      },
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/AlekseiMarchenko/central-intelligence'

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