Connect to Agentic Memory through a plugin

Updated at:

Agentic Memory integrates with AI coding assistants and agent frameworks as a plugin to add persistent cross-session memory. This topic describes how to install and configure the Agentic Memory plugin in Claude Code, Claude Cowork, Cursor, Codex, QoderWork, and Hermes.

Prerequisites

  • You have obtained an API key. For more information, see Create and manage API keys.

  • You have obtained the service access address (the access domain, or base URL). For more information, see Obtain a service endpoint.

  • git and python3 are installed on your local machine.

  • jq is installed on your local machine. The lifecycle hook scripts of the plugin use jq to parse input. If jq is missing, the hook features degrade.

Supported clients and capabilities

Client

Installation method

MCP server

Lifecycle hooks

Skill

Claude Code (CLI)

Install from the plugin marketplace

Supported

Supported, 6 events

Not included

Claude Cowork (desktop app)

Install from the plugin marketplace

Supported

Supported, 6 events

Not included

Cursor

Configure the MCP server manually, or install the plugin

Supported

Supported only when you install the plugin, 5 events

Included only when you install the plugin

Codex

Configure the MCP server directly in option A, or sideload the plugin in option B

Supported

Supported only in option B, and requires you to run an extra installation script, 3 events

Included only in option B

QoderWork

Import the Kit package

Supported, requires you to replace the environment variables manually

Supported, requires you to merge the hook configuration manually

Included

Hermes

hermes plugins install

Supported, requires additional MCP client configuration

Not applicable

Not applicable

Claude Code and Claude Cowork share the same plugin system. Install the plugin once to use it in both clients.

Access workflow

The integration has three steps. Step 2 provides two installation methods. Choose one of them.

Step

Description

Required

Step 1: Get an API key and the access domain

Get an API key and the access domain in the AI Search Open Platform console, and write them to environment variables. The plugin configuration of each client reads the credentials from environment variables.

Required. Both installation methods rely on these credentials. For Hermes, you only need to get the credentials. You do not need to configure environment variables.

Step 2: Install the plugin

In method 1, an agent reads the documentation of the plugin repository and installs the plugin automatically. In method 2, you run commands or edit configuration files based on your client.

Required. Choose one of the two methods.

Step 3: Verify the installation

Verify server connectivity, and confirm that the client has loaded the MCP tools.

Recommended. Use this step to confirm that the credentials and the plugin configuration take effect.

Step 1: Get an API key and the access domain

Obtain credentials in the console

  • Log on to the AI Search Open Platform console.

  • In the left-side navigation pane, click API keys.

  • In the Access Domain section in the upper part of the page, record the API domain that you need. Use the Public API Domain in an Internet environment and the Private API Domain in a VPC environment. Both domains support HTTPS. This domain is the base URL in the configurations that follow.

  • Click Create API Key, complete account security authentication as prompted, and then copy the API key, which starts with OS-.

    Creating an API key triggers security authentication for your Alibaba Cloud account. You must pass either MFA verification, with a dynamic code from the Alibaba Cloud app or Google Authenticator, or facial verification. If you already have an API key that you can use, click View in the Actions column of the list to get its plaintext value. This operation does not trigger security authentication. Each account can have at most 10 API keys enabled at the same time.

Configure environment variables

Claude Code, Claude Cowork, Cursor, Codex, and QoderWork all read the credentials from environment variables. Write the API key and the access domain to your shell configuration file first. Hermes does not use environment variables. If you use Hermes, skip to the Hermes section.

# zsh (default on macOS)
echo 'export AGENTIC_MEMORY_API_KEY="OS-your-api-key"' >> ~/.zshrc
echo 'export AGENTIC_MEMORY_BASE_URL="https://xxx.platform-cn-shanghai.opensearch.aliyuncs.com"' >> ~/.zshrc
source ~/.zshrc

# bash
echo 'export AGENTIC_MEMORY_API_KEY="OS-your-api-key"' >> ~/.bashrc
echo 'export AGENTIC_MEMORY_BASE_URL="https://xxx.platform-cn-shanghai.opensearch.aliyuncs.com"' >> ~/.bashrc
source ~/.bashrc

Confirm that the environment variables take effect.

echo $AGENTIC_MEMORY_API_KEY
echo $AGENTIC_MEMORY_BASE_URL

Step 2: Install the plugin

You can install the plugin in two ways. Choose one of them.

  • Method 1 (Recommended): An agent reads the documentation of the plugin repository and completes the installation. Use this method for a quick integration.

  • Method 2: You run commands or edit configuration files based on your client. Use this method to understand the client-specific configurations, or if Method 1 fails.

    Both methods require you to complete Step 1 first, because the MCP configuration of the plugin reads the credentials from environment variables.

Method 1: Let an agent install the plugin automatically (recommended)

In the dialog box of a compatible agent, enter the following prompt and let the agent install the plugin.

  • Claude Code, Claude Cowork, Cursor, Codex, and QoderWork:

Install the plugin based on the documentation at https://github.com/aliyun/alibabacloud-opensearch-memory/blob/main/README.md
  • Hermes:

Install the plugin based on the documentation at https://github.com/aliyun/alibabacloud-opensearch-memory-for-hermes.git

After the installation, perform Step 3 to verify it. If the agent fails, or if you want to understand the client-specific configurations, use Method 2 to install the plugin manually.

Method 2: Install the plugin manually

Select the section for your client. Except for Hermes, all clients require the environment variables that you configured in Step 1.

Claude Code and Claude Cowork

Claude Code and Claude Cowork share the same plugin system. The installation completes the full configuration, including the MCP server and the lifecycle hooks.

CLI method:

claude plugin marketplace add aliyun/alibabacloud-opensearch-memory
  claude plugin install agentic-memory@agentic-memory-plugins

Cowork desktop app method: Open the Cowork tab, click Customize in the sidebar, click Browse plugins, and then install Agentic Memory.

The following lifecycle hooks are registered automatically after the installation.

Hook event

Trigger

Function

SessionStart

On startup or resume, or after context compaction

Loads historical memories as the startup context

UserPromptSubmit

Each time you submit a prompt

Injects relevant memories into the prompt

PreToolUse

Before the Write or Edit tool is called

Blocks direct writes to memory files

PreCompact

Before context compaction

Generates a summary before the compaction

TaskCompleted

When a task is completed

Saves what the agent learned in the task

Stop

At the end of a turn

Reminds the agent to persist what it learned

Cursor

If you configured agentic-memory in the MCP settings of Cursor before, remove the existing entry first to avoid duplicate tool registration.

  • Manual configuration connects only the MCP server. It does not include the hooks or the Skill. Use this if you need only MCP connectivity.

  • Plugin installation provides the MCP server, lifecycle hooks, and the Skill. Use this for the full experience.

    To use manual configuration, add the following content to .cursor/mcp.json.

{
    "mcpServers": {
      "agentic-memory": {
        "url": "${env:AGENTIC_MEMORY_BASE_URL}/v1/agentic-memory/mcp",
        "headers": {
          "Authorization": "Bearer ${env:AGENTIC_MEMORY_API_KEY}"
        }
      }
    }
  }

To install the plugin instead and get the lifecycle hooks (sessionStart, beforeSubmitPrompt, preToolUse, preCompact, and stop events) and the Skill, use the plugin installation method. The plugin repository already includes the Cursor plugin manifest.

Codex

Warning

Codex provides two integration options. Do not use both options at the same time. The plugin manifest registers agentic-memory as an MCP server automatically through .codex-mcp.json. If you also add [mcp_servers.agentic-memory] manually, the server is registered twice.

Option A: Configure the MCP server directly

This is the fastest option, and it provides only the MCP features. Codex reads the MCP server configuration from ~/.codex/config.toml. Add the following content.

[mcp_servers.agentic-memory]
  url = "${AGENTIC_MEMORY_BASE_URL}/v1/agentic-memory/mcp"
  bearer_token_env_var = "AGENTIC_MEMORY_API_KEY"

Export AGENTIC_MEMORY_API_KEY and AGENTIC_MEMORY_BASE_URL in your shell, and then restart Codex. If your Codex version does not support environment variable interpolation in url, replace ${AGENTIC_MEMORY_BASE_URL} with the actual access domain that you got in Step 1.

Note

codex mcp add supports only stdio servers. Agentic Memory is an HTTP server, so you can configure it only in config.toml directly, or through the Plugins > Connect to a custom MCP > Streamable HTTP interface of the Codex app.

Option B: Sideload the plugin

This option provides the full experience, including the MCP server, the Skill, and optional lifecycle hooks. Register the plugin marketplace.

codex plugin marketplace add https://github.com/aliyun/alibabacloud-opensearch-memory.git

Restart Codex, run /plugins, and install Agentic Memory from the Agentic Memory Plugins marketplace.

The common commands to manage the plugin are as follows.

codex plugin marketplace upgrade                          # Pull the latest plugin version
  codex plugin marketplace remove agentic-memory-plugins    # Unregister the plugin marketplace

Optional step for Option B: Enable the lifecycle hooks

Codex does not load the hooks from the plugin manifest automatically. It reads only ~/.codex/hooks.json or <repo>/.codex/hooks.json. Run the installation script that is built into the plugin to merge the hook configuration of Agentic Memory into that file.

python3 <plugin-installation-directory>/scripts/install_codex_hooks.py

The script merges three entries into ~/.codex/hooks.json, rewrites the script paths to absolute paths, and keeps the other hooks that you already have.

Event

Function

SessionStart

Loads historical memories as the startup context

UserPromptSubmit

Injects relevant memories into the prompt

Stop

Reminds the agent to save what it learned at the end of a turn

Note

You must run the script from the plugin directory that you sideloaded with codex plugin marketplace add. Do not run it from a directory that you cloned with git clone. The script identifies the hook entries that it wrote by the plugin directory name. If you run it from your own clone, repeated runs append duplicate entries, and --uninstall cannot remove them.

To enable the hooks, you must also turn on the codex_hooks feature switch in ~/.codex/config.toml. Otherwise, the installation script prints a reminder. Restart Codex after you make the change.

[features]
  codex_hooks = true

To uninstall the hooks, run python3 <plugin-installation-directory>/scripts/install_codex_hooks.py --uninstall. The hook file stores absolute paths. If you move or delete the plugin directory, run the installation script again from the new location.

QoderWork

Step 1: Clone the repository and package it as a ZIP file

git clone https://github.com/aliyun/alibabacloud-opensearch-memory.git && zip -r alibabacloud-opensearch-memory.zip alibabacloud-opensearch-memory

Step 2: Import the Kit

In QoderWork, choose Expert Kits > Install Kit in the upper-right corner to import alibabacloud-opensearch-memory.zip.

Step 3: Replace the environment variables in the MCP configuration manually

QoderWork does not support environment variables in url. Manually replace ${AGENTIC_MEMORY_BASE_URL} and ${AGENTIC_MEMORY_API_KEY} in ~/.qoderwork/plugins-custom/agentic-memory/.mcp.json with the actual values.

Step 4: Merge the hook configuration manually

QoderWork does not support the hooks subdirectory. Manually add the settings in ~/.qoderwork/plugins-custom/agentic-memory/hooks/hooks.json to ~/.qoderwork/settings.json, and replace ${CLAUDE_PLUGIN_ROOT} in them with the actual path prefix ~/.qoderwork/plugins-custom/agentic-memory.

Step 5: Grant execute permissions to all scripts

chmod +x ~/.qoderwork/plugins-custom/agentic-memory/scripts/*

Step 6: Restart QoderWork

Hermes

Hermes integrates through a memory provider. This mechanism differs from the plugin mechanism of the other clients: it does not rely on environment variables, and the credentials are stored in the configuration file of the plugin.

Step 1: Install the plugin

hermes plugins install https://github.com/aliyun/alibabacloud-opensearch-memory-for-hermes.git
Note

hermes plugins install installs only the plugin files. It does not guarantee that the Python runtime dependencies of the memory provider are installed. After the installation, you must add the dependencies in one of the following two ways.

  • Interactive installation: Run hermes memory setup, use the arrow keys to select agentic_memory, and let Hermes install the pip_dependencies defined in plugin.yaml automatically.

  • Manual installation: Install the dependencies in the Python environment that Hermes actually uses, and then set the provider.

pip install requests
  hermes config set memory.provider agentic-memory

Step 2: Configure the plugin

If you choose interactive installation, the plugin prompts you for all required configuration items. Otherwise, create the configuration file $HERMES_HOME/agentic_memory.json manually.

Configuration item

Default value

Description

api_endpoint

None. Required.

The base API URL, which is the access domain that you got in Step 1

api_token

None. Required.

The bearer token, which is the API key that you got in Step 1

user_id

Empty. Generated automatically on the first run.

The user identifier

agent_id

hermes

The agent identifier

Note

The workspace name is parsed automatically from api_endpoint. You do not need to configure it.

Step 3: Configure the MCP client

Add the following content to ~/.hermes/config.yaml. Replace [YOUR_ENDPOINT] with the access domain and [YOUR_API_TOKEN] with the API key that you obtained in Step 1.

mcp_servers:
    agentic-memory:
      url: [YOUR_ENDPOINT]/v1/agentic-memory/mcp
      headers:
        Accept: application/json, text/event-stream
        Authorization: Bearer [YOUR_API_TOKEN]

Step 4: Restart Hermes

Restart Hermes to load the plugin and the MCP server.

Step 3: Verify the installation

Verify server connectivity

Before you configure a client, run the following command to confirm that the credentials and the access domain work. A returned serverInfo indicates that the connection is normal.

curl -X POST "$AGENTIC_MEMORY_BASE_URL/v1/agentic-memory/mcp" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer $AGENTIC_MEMORY_API_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"verify","version":"1.0"}}}'

If the API key is invalid, HTTP 400 is returned with the following response.

{"code":"CredentialsNotFound","message":"Invalid token","request_id":"..."}

Verify client access

  • Start a new session, or restart the current session.

  • Enter Search my memories for hello.

  • If the tools of agentic-memory appear and respond, the integration is successful.

Verify Hermes access

Check whether Hermes recognizes the provider.

hermes memory status

The expected output is as follows.

Provider:  agentic-memory
Plugin:    installed
Status:    available

Then start a Hermes session, ask Hermes to remember a piece of information, ask Hermes to retrieve it, and delete it by memory ID if needed.

MCP tools

The MCP server that the plugin connects provides 18 tools in four categories: memory, knowledge base, skill, and hybrid search.

Category

Tool

Description

Memory

memory_add

Submits a memory write, which runs asynchronously and returns an event_id

Memory

memory_event_status_get

Queries the status of an asynchronous write by event_id

Memory

memory_search

Runs a semantic search for memories in the current workspace

Memory

memory_get

Gets a single memory by ID

Memory

memory_get_all

Returns memories by page based on exact filter conditions

Memory

memory_update

Overwrites the body of a memory by ID

Memory

memory_delete

Deletes a single memory by ID

Knowledge base

kb_docs_search

Finds candidate documents based on document metadata

Knowledge base

kb_nodes_search

Retrieves document fragments or sections by semantic relevance

Knowledge base

kb_doc_structure_get

Gets the section tree of a specified document

Knowledge base

kb_node_content_get

Gets the complete content of a node in the section tree

Knowledge base

kb_doc_grep

Runs an exact text or regular expression match within a specified document

Knowledge base

kb_doc_read

Reads the original document content by line range

Skill

skill_list

Lists the skills available in the current workspace

Skill

skill_search

Runs a semantic search for reusable skills

Skill

skill_view

Views the complete content of a skill or its associated files

Skill

skill_manage

Creates, updates, and deletes skills

Hybrid search

hybrid_search

Searches memories, skills, and knowledge base documents in a single call

For the complete parameters and response structures of each tool, see Connect to Agentic Memory over MCP.

Key behaviors of memory writes

  • Writes are asynchronous.memory_add immediately returns an event_id and status: PENDING. Call memory_event_status_get and poll until the status is SUCCEEDED to get the ID of the generated memory.

  • One message can be extracted into multiple memories. The server performs fact extraction and deduplication on the input, so the number of memories written does not map one-to-one to the number of input messages. If the input contains no extractable facts, no memory is created.

  • The filters parameter of memory_search must use the {"AND": [...]} structure. If you pass {"user_id": "xxx"} directly, HTTP 422 is returned with the error filters must be exactly {'AND': [<entry>, ...]} with no other top-level keys.

Update the plugin

After the plugin is updated, either by pulling a new version from the plugin marketplace or by reinstalling it locally, the MCP server connection in the current session holds a stale handle and stops responding. Restart the client to reconnect.

  • Claude Code: Run /restart at the prompt, or close and reopen the CLI.

  • Claude Cowork: Use the same restart method as Claude Code. Claude Code and Claude Cowork share the same plugin system.

  • Cursor: Quit and restart it.

  • Codex: Restart the editor session.

  • Hermes: Restart Hermes.

    You do not need to enter AGENTIC_MEMORY_API_KEY again after the restart. The MCP configuration of the plugin interpolates ${AGENTIC_MEMORY_API_KEY} when the session starts, not when the plugin is installed. As long as the environment variable is set persistently, in a shell configuration file or, for Claude Code, in the env block of ~/.claude/settings.json, the connection is restored automatically after the restart.

If the connection still fails after the restart, check whether the new shell can read AGENTIC_MEMORY_API_KEY, and confirm that the value starts with OS-.

echo $AGENTIC_MEMORY_API_KEY

Limits

  • Each account can have at most 10 API keys enabled at the same time.

  • Creating an API key requires account security authentication, either MFA verification or facial verification.

  • The lifecycle hook scripts depend on the local jq command.

  • The hook installation script of Codex identifies the entries that it wrote by the plugin directory name. If you run it from your own git clone directory, both idempotent replacement and --uninstall stop working.