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
| Name | Required | Description | Default |
|---|---|---|---|
| current_context | Yes | A summary of what you're currently working on or discussing. The more specific, the better the recalled memories will be. | |
| agent_id | No | Identifier for this agent instance | default |
| user_id | No | User identifier to include user-scoped memories | |
| max_memories | No | Maximum number of memories to return |
Implementation Reference
- packages/mcp-server/src/index.ts:237-265 (handler)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.", }, ], }; } - packages/mcp-server/src/index.ts:211-236 (registration)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"), },