Skip to content
agentics.you

Docs

Memory for Vercel AI SDK agents

Give every Vercel AI SDK agent the same memory. The agent saves what it learns with remember, and any agent in your workspace finds it later with recall. Each memory is a receipt you can check. The connection is the agentics.you MCP server, so there is no extra package to install from us.

Before you start

  1. Create an account at agentics.you/signup.
  2. In the console, open API keys. Under Agent keys, choose Create agent key, pick the agent this code acts as, and copy the key. It starts agk_mcp_ and is shown once.
  3. Keep it in an environment variable, never in code:
bash
export AGENTICS_AGENT_KEY="agk_mcp_..."

Install

bash
npm install ai @ai-sdk/mcp @ai-sdk/openai

The code

experimental_createMCPClient from @ai-sdk/mcp connects over HTTP with the key in headers. callTool runs one tool, and tools() returns the set to pass to generateText or streamText. Close the client when you are done.

js
import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";

const AGENTICS_MCP_URL = process.env.AGENTICS_MCP_URL ?? "https://agentics.you/mcp";

const agentics = await createMCPClient({
  transport: {
    type: "http",
    url: AGENTICS_MCP_URL,
    headers: { Authorization: `Bearer ${process.env.AGENTICS_AGENT_KEY}` },
  },
});

try {
  const tools = await agentics.tools();

  // Save a memory, then find it again. Any agent in the workspace can recall it.
  await agentics.callTool({ name: "remember", arguments: { content: "The customer prefers email over phone calls." } });
  const found = await agentics.callTool({ name: "recall", arguments: { query: "How does the customer like to be contacted?" } });
  console.log(found.content[0].text);

  // Give the same tools to a model. It recalls before it answers and remembers what it learns.
  if (process.env.OPENAI_API_KEY) {
    const { generateText, stepCountIs } = await import("ai");
    const { openai } = await import("@ai-sdk/openai");
    const { text } = await generateText({
      model: openai("gpt-4.1"),
      tools,
      stopWhen: stepCountIs(5),
      system: "Call recall before you answer. Call remember to save anything worth keeping.",
      prompt: "How should we contact the customer?",
    });
    console.log(text);
  }
} finally {
  await agentics.close();
}

Run it

bash
node vercel-ai-memory.mjs

It prints the memory recall found, with its receipt_hash and a verify_url anyone can open. With OPENAI_API_KEY set, it then asks an agent the same question, and the agent can call recall itself.

Next

  • MCP tool reference: every argument remember and recall take, and the other memory tools.
  • Scoping: which memories an agent key can read.
  • Lifecycle: how a newer memory replaces an older one.

This code runs in CI on every change, against a stand-in for the MCP server (examples/guides/ in the repository).