Skip to content

MCP call context

Every request a Lunen session makes to your MCP server says which session it comes from, and which agent that session runs for when there is one. The same values arrive on two channels — HTTP headers on every request, and _meta keys on every tool call — so your server can read whichever is easier to reach from where it handles the call.

Updated 16 October 2026 · 3 min read

The two values

ValueHTTP header_meta keyWhat it identifies
Sessionx-lunen-session-idai.lunen/session-idOne conversation or one Task Agent run. The unit the audit log and the run’s execution log are keyed by. Always sent.
Agentx-lunen-agent-idai.lunen/agent-idThe Lunen agent the session runs for: a Task Agent’s id, or a Convo Agent’s id. Absent when no agent is involved — an ad-hoc chat, or a planning session, even one editing an existing Task Agent.

Both are opaque identifiers, stable for the life of the connection. A Task Agent’s id is the one in its dashboard URL, so the agent value maps directly to the Task Agent page an administrator can open, and every run of that agent carries the same agent id with a fresh session id.

Lunen sends no identifier for the calling member or the organization. The credential the server was connected with — a member’s own, or the organization’s — is the only signal of who is behind a call.

Where each channel appears

Headers ride every HTTP request a session’s connection makes — the handshake (server/discover, or initialize with servers on earlier protocol versions), tools/list, tools/call, and the standalone SSE GET when your server uses one. They sit beside Lunen’s user-agent and whatever authentication the server was registered with; a registered header with the same name takes precedence over Lunen’s.

_meta keys ride tools/call only, in params._meta — beside the io.modelcontextprotocol/… keys the MCP SDK adds on current-protocol connections. A call that pauses for input and resumes carries them on both rounds. Listing and discovery requests do not carry them, so a server that only wants to attribute tool executions can ignore headers entirely.

{
  "jsonrpc": "2.0",
  "id": 7,
  "method": "tools/call",
  "params": {
    "name": "create_ticket",
    "arguments": { "title": "Rotate the staging certificate" },
    "_meta": {
      "ai.lunen/session-id": "0d4f2a0e-6b1c-4b8e-9c0e-2f0a7f1c9d3b",
      "ai.lunen/agent-id": "8a1d3e5f-2c4b-4a6d-9e8f-1b3c5d7e9f0a"
    }
  }
}

Requests Lunen makes outside a session carry neither value: an administrator’s Refresh of the server’s tool list, and the OAuth discovery requests sent when the server is added or its discovery re-runs. Expect those unattributed.

What to do with them

  • Correlate. Log the session id with your own request id, and a question about a tool call in Lunen’s audit log becomes a lookup in your logs instead of a timestamp search.
  • Attribute. Group usage, quotas, or rate limits by agent id — the identity that stays put across runs — rather than by connection.
  • Scope. A server fronting several backends can pick the right one per agent without a separate registry entry for each.
Warning

These values describe the caller; they do not authenticate it. Keep authorizing requests through the server’s registered mechanism — OAuth or custom credential headers — and treat the session and agent ids as claims to log and route on, not as proof of who is calling.