← All Event Families
Ansvar

foundation.protocols.ai.ansvar.*

Ansvar Legal MCP Recording: complete MCP interaction recording for Ansvar legal and regulatory MCP servers. Tool calls, resource access, citation extraction, error handling, session lifecycle. Verified against 6 Ansvar MCP servers (Swedish data protection, cybersecurity, financial regulation, competition, energy regulation, security program).

11
Events
9
Timeline
2
State

Contents

Design Notes

All 11 events use the foundation.protocols.ai.ansvar namespace prefix — nested under ai to make clear that Ansvar is one specific legal/regulatory MCP integration within the broader foundation.protocols.ai.* governance framework.

1. Session

2 state events tracking the MCP bridge session lifecycle — from proxy start to teardown.

State Event

foundation.protocols.ai.ansvar.session.start

Emitted when the bridge starts proxying MCP traffic. Lists all configured MCP servers. This event serves as the thread root for all subsequent events in the session.

FieldTypeDescription
session_idstringUnique session identifier (e.g., ansvar_sess_20260411T120000Z)
serversobject[]Configured MCP servers: name, command, cwd
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.session.start",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "servers": [
      {"name": "swedish-data-protection", "command": "npx", "cwd": "../ansvarsystems/swedish-data-protection-mcp"},
      {"name": "swedish-cybersecurity", "command": "npx", "cwd": "../ansvarsystems/swedish-cybersecurity-mcp"}
    ],
    "timestamp": 1744365600000,
    "actor": "@raazesh:matrix.openearth.network"
  }
}
State Event

foundation.protocols.ai.ansvar.session.end

Emitted when the bridge session terminates. Includes operation counts and total duration.

FieldTypeDescription
session_idstringSession identifier
duration_msintegerTotal session duration in milliseconds
operationsobjectOperation counts: tool_calls, tool_results, resource_reads, citations, errors, server_connect
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.session.end",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "duration_ms": 45230,
    "operations": {
      "tool_calls": 3,
      "tool_results": 3,
      "resource_reads": 1,
      "citations": 5,
      "errors": 0,
      "server_connect": 2
    },
    "timestamp": 1744365645230,
    "actor": "@raazesh:matrix.openearth.network"
  }
}

2. Server

1 event recording MCP server initialization — the initialize handshake.

Timeline Event

foundation.protocols.ai.ansvar.server.connect

Emitted when the MCP initialize handshake completes. Records server identity, protocol version, and capabilities.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name (e.g., swedish-data-protection)
protocol_versionstringMCP protocol version (e.g., 2024-11-05)
server_infoobjectServer identity: name, version
capabilitiesobjectMCP capabilities (tools, resources, prompts)
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.server.connect",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "protocol_version": "2024-11-05",
    "server_info": {
      "name": "swedish-data-protection-mcp",
      "version": "1.0.0"
    },
    "capabilities": {"tools": {}, "resources": {}},
    "timestamp": 1744365601000,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

3. Tools

3 events for MCP tool lifecycle — discovery, invocation, and result capture.

Timeline Event

foundation.protocols.ai.ansvar.tool.list

Emitted when a tools/list response is received from the MCP server. Records available tools and their schemas.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
toolsobject[]Available tools: name, description, input_schema
tool_countintegerNumber of tools available
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.tool.list",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "tools": [
      {
        "name": "search_decisions",
        "description": "Search IMY decisions on data protection",
        "input_schema": {"type": "object", "properties": {"query": {"type": "string"}}}
      },
      {
        "name": "get_decision",
        "description": "Get a specific IMY decision by ID",
        "input_schema": {"type": "object", "properties": {"id": {"type": "string"}}}
      }
    ],
    "tool_count": 2,
    "timestamp": 1744365602000,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.ansvar.tool.call

Emitted when a tools/call request is sent to the MCP server. Records the tool name and arguments.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
request_idinteger|stringJSON-RPC request ID
tool_namestringName of the tool being called
argumentsobjectTool call arguments
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.tool.call",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "request_id": 1,
    "tool_name": "search_decisions",
    "arguments": {"query": "GDPR consent requirements"},
    "timestamp": 1744365603000,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.ansvar.tool.result

Emitted when a tools/call response is received. Records content metadata (length, NOT raw text — data stays home), latency, and the number of legal citations extracted.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
request_idinteger|stringJSON-RPC request ID (matches tool.call)
tool_namestringTool that produced the result
contentobject[]Result metadata: type, text_length (raw text NOT included)
is_errorbooleanWhether the MCP server flagged this as an error result
latency_msintegerTime between tool.call and tool.result
citation_countintegerNumber of legal citations extracted from result text
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.tool.result",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "request_id": 1,
    "tool_name": "search_decisions",
    "content": [{"type": "text", "text_length": 2847}],
    "is_error": false,
    "latency_ms": 234,
    "citation_count": 3,
    "timestamp": 1744365603234,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

4. Resources

3 events for MCP resource access — discovery, read requests, and content delivery.

Timeline Event

foundation.protocols.ai.ansvar.resource.list

Emitted when a resources/list response is received. Records available legal resources and their URIs.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
resourcesobject[]Available resources: uri, name, description, mime_type
resource_countintegerNumber of resources available
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.resource.list",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "resources": [
      {
        "uri": "imy://decisions/2024-001",
        "name": "IMY Decision 2024-001",
        "description": "GDPR enforcement decision — consent basis",
        "mime_type": "text/plain"
      }
    ],
    "resource_count": 1,
    "timestamp": 1744365604000,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.ansvar.resource.read

Emitted when a resources/read request is sent. Records the resource URI being accessed.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
request_idinteger|stringJSON-RPC request ID
uristringResource URI being read
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.resource.read",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "request_id": 2,
    "uri": "imy://decisions/2024-001",
    "timestamp": 1744365605000,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}
Timeline Event

foundation.protocols.ai.ansvar.resource.content

Emitted when a resources/read response is received. Records content metadata (length, MIME type) but NOT the raw content — data stays home.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
request_idinteger|stringJSON-RPC request ID (matches resource.read)
uristringResource URI
contentsobject[]Content metadata: uri, mime_type, text_length
latency_msintegerTime between resource.read and resource.content
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.resource.content",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "request_id": 2,
    "uri": "imy://decisions/2024-001",
    "contents": [
      {"uri": "imy://decisions/2024-001", "mime_type": "text/plain", "text_length": 14523}
    ],
    "latency_ms": 89,
    "timestamp": 1744365605089,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

5. Citation

1 derived event — legal references extracted from tool results via regex-based citation parsing.

Timeline Event

foundation.protocols.ai.ansvar.citation

Derived event — extracted from tool.result text using regex-based citation parsing. Jurisdiction is inferred from the MCP server name (e.g., swedish-*SE). One citation event per legal reference found.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server that produced the source result
source_event_idstringEvent ID of the tool.result this citation was extracted from
jurisdictionstringISO country code (e.g., SE, EU)
referencestringFull citation text
titlestringLaw or regulation name
sectionstringSection, Article, or Chapter number
urlstringURL to source document (if available)
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.citation",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "source_event_id": "$tool_result_event_id",
    "jurisdiction": "SE",
    "reference": "Section 7 of the Swedish Data Protection Act",
    "title": "the Swedish Data Protection Act",
    "section": "7",
    "timestamp": 1744365603300,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

6. Error

1 event for MCP JSON-RPC errors.

Timeline Event

foundation.protocols.ai.ansvar.error

Emitted when a JSON-RPC error response is received from the MCP server. Records the standard JSON-RPC error code and message.

FieldTypeDescription
session_idstringSession identifier
server_namestringMCP server name
request_idinteger|stringJSON-RPC request ID
error_codeintegerJSON-RPC error code (e.g., -32601 for Method Not Found)
error_messagestringError description
methodstringThe MCP method that failed
timestampintegerUnix millisecond timestamp
actorstringMatrix user ID
{
  "type": "foundation.protocols.ai.ansvar.error",
  "content": {
    "session_id": "ansvar_sess_20260411T120000Z",
    "server_name": "swedish-data-protection",
    "request_id": 99,
    "error_code": -32601,
    "error_message": "Method not found",
    "method": "unknown/method",
    "timestamp": 1744365610000,
    "actor": "@raazesh:matrix.openearth.network",
    "m.relates_to": {
      "rel_type": "m.thread",
      "event_id": "$session_start_event_id"
    }
  }
}

Implementation Status

ComponentStatusDetails
Bridge daemonDonetools/ansvar_bridge.py — Python, MCP stdio proxy, matrix-nio
Test suiteDonetools/test_ansvar_bridge.py — 27 unit tests, all passing
MCP servers6 configuredAnsvar-Systems repos (Apache-2.0): data protection, cybersecurity, financial, competition, energy, security
Citation extractorDoneRegex-based: Section/Article/SFS/EU Regulation patterns, jurisdiction inference
Messenger viewsPlannedReuse Claude/Hopsworks view patterns (ToolCallCard, CitationBadge)
Live homeserverPlannedWire to a matrix.<your-homeserver> endpoint for demo

License: bridge daemon is AGPL-3.0 (Layer 2 — strategic choice). MCP servers are Apache-2.0. The bridge communicates via MCP stdio protocol (JSON-RPC) and Matrix wire protocol (JSON/HTTPS) — both are license boundaries.