# Connecting over MCP

> How Memrio exposes a remote MCP server: endpoint, authentication, protocol version, and the JSON-RPC handshake.

## Endpoint

Each workspace has one Streamable HTTP MCP endpoint at `https://memrio.ai/api/mcp/acme`. The same URL serves every agent in the workspace; the API key decides which agent and page set apply.

| Method | Behaviour |
| --- | --- |
| POST | JSON-RPC 2.0 request or batch. Returns JSON. Notifications return 202 with no body. |
| GET | Returns server info for the authenticated key: name, workspace slug, agent name, protocol version. |
| DELETE | Ends a session (no-op; the server is stateless). Returns 204. |
| OPTIONS | CORS preflight. Returns 204. |

## Authentication

Send the agent key as a Bearer token. There is no workspace or page-set header — the key already binds to one agent in one workspace. Requests without a valid key return 401; a paused agent returns 403.

**Header**

```bash
Authorization: Bearer mr_live_8f3a…
```

> **Warning:** Keys are shown once at creation and stored hashed. Treat them like passwords; rotate by creating a new key and revoking the old one from the agent page.

## Protocol

The server speaks MCP protocol version `2025-03-26` over Streamable HTTP and echoes the version the client requests. It advertises the `tools` capability only — no resources or prompts. Server name is `memrio`.

## Handshake by hand

Every client does this for you, but it is useful for debugging with curl.

**initialize**

```bash
curl -s https://memrio.ai/api/mcp/acme \
  -H "Authorization: Bearer mr_live_8f3a…" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
```

**response**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2025-03-26",
    "capabilities": { "tools": { "listChanged": false } },
    "serverInfo": { "name": "memrio", "version": "0.2.0" },
    "instructions": "Browse the Support bot page set in Acme first. …"
  }
}
```

**tools/list and a tools/call**

```bash
curl -s https://memrio.ai/api/mcp/acme \
  -H "Authorization: Bearer mr_live_8f3a…" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

curl -s https://memrio.ai/api/mcp/acme \
  -H "Authorization: Bearer mr_live_8f3a…" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"browse","arguments":{}}}'
```

## Server instructions

The `initialize` result includes an `instructions` string tailored to the agent: browse first, pick pages by their use-when text, never invent facts. Agents with write access also get the registry markdown guide. Most clients pass this straight into the model’s context.

## Request log

Every call — including failed authentication and unknown tools — is recorded with the tool name, query, pages hit, status, and latency. Open the agent to inspect it.

Source: https://memrio.ai/docs/connect-mcp
