Skip to main content
Glama
martindzejky

agentmemory-mcp-shim

by martindzejky
README.md
# agentmemory-mcp-shim

Coding agents and other local MCP hosts spawn this process. It forwards `tools/list` and `tools/call` to AgentMemory REST and returns the server payload as-is, including `structuredContent`. There is no local memory database and no silent fallback.

## Why this exists

`npx @agentmemory/mcp` runs upstream `@agentmemory/agentmemory`, which drops `structuredContent` on the stdio path. Cursor then rejects every tool call with `-32600` once the tool advertises `outputSchema`.

This shim is the Cursor-side counterpart of [agentmemory-mcp-gateway](https://github.com/martindzejky/agentmemory-mcp-gateway): same two REST endpoints, fail loud when the server is missing.

## Required env

| Name                 | Purpose                                               |
| -------------------- | ----------------------------------------------------- |
| `AGENTMEMORY_URL`    | AgentMemory origin, e.g. `https://memory.example.com` |
| `AGENTMEMORY_SECRET` | Bearer secret for `/agentmemory/*`                    |

Missing either one exits with status 1. Optional: `AGENTMEMORY_TIMEOUT_MS` (default `10000`).

## Setup

This is a complete `mcp.json`. Paste it into the host config (Cursor uses `~/.cursor/mcp.json`) and replace the env values:

```json
{
  "mcpServers": {
    "agentmemory": {
      "command": "npx",
      "args": ["-y", "@martindzejky/agentmemory-mcp-shim"],
      "env": {
        "AGENTMEMORY_URL": "https://memory.example.com",
        "AGENTMEMORY_SECRET": "replace-me"
      }
    }
  }
}
```

## Wire protocol

- `GET ${AGENTMEMORY_URL}/agentmemory/mcp/tools`
- `POST ${AGENTMEMORY_URL}/agentmemory/mcp/call` with `{ "name", "arguments" }`
- Pass through `content`, `structuredContent`, `isError`, and `_meta`

Upstream errors become MCP tool errors (`isError: true`). This process never opens an InMemoryKV or writes observations locally.