Skip to content

Health Software Common Practices

HSCP-R-003 · recipe · Security

Log an access made by an agent

Written entry, version 0.2, checked on 2026-11-15.

At a glance

ImplementsHSCP-G-002 Log access to health data
CaseInstantiates: applies an existing practice to a context.
Contextan AI agent reads health data on behalf of a person, either built into the product or connected from outside through an MCP server or an API
Verificationopen test · review

Implements HSCP-G-002, Log access to health data. Case: instantiates the practice for the case where the reader is an agent. Comes on top of HSCP-R-002, which it assumes is in place.

When

An agent reads several resources for a single question from a user. If the log records only the user, the review sees a person opening many documents in one second. If the log records only the agent, nobody is accountable for the access any more.

How

  1. Keep two identities per entry: the person on whose behalf the agent reads, and the agent.
  2. Separate what is proven from what is declared. The person and the client application come from the access token, which the server verifies. The agent's name, its version and the model used are declared by the client: they go into separate fields, marked as declared.
  3. Have the client transmit a request identifier, shared by all the reads that answer the same question. The server cannot guess it. Failing that, group by session and record this in the entry.
  4. Refuse in the database an entry whose path is "agent" or "MCP" and which does not name the agent.
  5. Give the agent a read scope specific to its task, narrower than the person's rights, and write this scope into the entry.
  6. Keep the log out of the agent's reach: it has no write or read right on the log.
  7. Add a per-request query to the review: which agent, on whose behalf, how many reads, which resources.

Three cases depending on how the agent arrives:

Case What the server knows unaided What the client transmits
Agent built into the product, server-side the person, the agent, its version, the request nothing
External agent, via MCP or API the person and the client application, through the token the agent, its version, the request identifier
Agent that drives the user's screen the person only nothing: the agent is invisible to the server

Examples

The access context is built where the request comes in, for example in the MCP server (Go, illustrative excerpt, not run):

ctx = AvecAcces(ctx, Acces{
    ActeurID:        jeton.Utilisateur, // proven: the person who authorised the assistant
    Chemin:          "mcp",
    AgentID:         jeton.Client,      // proven: the client application
    RequeteID:       idDeLaDemande,     // transmitted by the client, shared by all its reads
    Titre:           "prise_en_charge",
    PriseEnChargeID: priseEnCharge,
})

The per-request review query (PostgreSQL 16, run on a test dataset: three reads by an agent come out as one row):

SELECT j.requete_id, j.agent_id, u.nom AS au_nom_de, count(*) AS lectures,
       array_agg(DISTINCT j.ressource ORDER BY j.ressource) AS ressources
FROM acces_journal j
JOIN utilisateur u ON u.id = j.acteur_id
WHERE j.chemin IN ('agent', 'mcp')
GROUP BY j.requete_id, j.agent_id, u.nom;

Verification

  • CI test: an entry with path "agent" or "MCP" without an agent identity is refused by the database; three reads made for the same request come out grouped by the review query.
  • Permissions test: the account used by the agent can neither read nor modify the log.
  • Audit agent: identify the entry points (MCP server, API) and check that each builds the access context from the token, not from a free-form header.

Evidence produced

Dated test report, log schema with the proven and declared fields, result of the per-request review query.

Evidence items

Each item attests the recipe at a given date. Frequency given for a product in service.

  • Test report Dated test report: "agent" or "MCP" row without identity refused, reads grouped by requestFrequency: at each release
  • Configuration or schema Schema of the log with proven and declared fieldsFrequency: at each release
  • Export or query result Result of the per-request review queryFrequency: monthly

Own mappings

In addition to those of the practice:

Identifier What the recipe contributes
anssi_ia_agentique_v1.0/7.4 log out of the agent's reach, and reads of a request grouped to reconstruct the sequence
pgssi_s_imputabilite_v1_0/6.2.2-4 reconstruction by user or machine: the entry carries both
ehds_2025_327/annexeII-p13 identifies the natural person who accessed the data, even when an agent reads on their behalf (published text, phased application)

References outside the catalogue

  • MCP specification, authorization, version of 18/06/2025.
  • RFC 8693, OAuth 2.0 Token Exchange.

Versions

Versions of the entry (French reference), most recent first
VersionStatusDate
0.2Draft2026-11-15
0.1Draft2026-11-15

How to cite: “Health Software Common Practices”, HSCP-R-003, version 0.2, https://healthtechpractices.org/en/recettes/hscp-r-003/, under the CC BY-NC-SA 4.0 licence. Licence