Surface callerOrigin on ModelContextClient passed to ToolExecuteCallback
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- html
- Área
- api
Línea de trabajo
Start with the ModelContextClient interface and the tool execution steps in the current WebMCP spec, then trace how the existing exposedTo allowlist check computes the invoking origin. Update the IDL and execute algorithm together, ensuring native-agent invocations produce null. The issue identifies the relevant spec sections and related issues, but implementation may require coordination around the unresolved native-agent exposure question.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Background
PR #179 adds the toolchange event and establishes the cross-origin tool discovery model: a tool registered with exposedTo: ["https://agent.example"] becomes visible to agent.example via toolchange, and that document can subsequently invoke it. This closes the consumer side of the cross-origin relationship the permitted origin learns when tools become available.
The gap
The registrant side has no equivalent signal. When agent.example invokes the tool, the current ToolExecuteCallback fires:
webidlcallback ToolExecuteCallback = Promise (object input, ModelContextClient client);
The client object carries no information about which origin triggered the call. This is consequential when exposedTo lists multiple origins:
jsdocument.modelContext.registerTool({
name: "get-record",
description: "Fetches a record by ID",
inputSchema: { type: "object", properties: { id: { type: "string" } } },
execute(input, client) {
// client.callerOrigin does not exist
// both callers below receive identical behavior
return getFullRecord(input.id);
}
}, {
exposedTo: [
"https://internal-agent.example",
"https://partner-agent.example"
]
});
The browser already enforces that only listed origins may invoke the tool the exposedTo allowlist check happens during IPC routing before execute() fires. But the result of that check which specific listed origin passed is not forwarded to the callback. The registrant cannot observe it from any other available surface.
The exposedTo declaration creates a named, multi-party relationship at registration time. Without caller identity at invocation time, the registrant cannot implement differentiated behavior within that relationship serving different response shapes to different permitted callers, or making dynamic decisions based on which party in an established relationship is acting.
Proposal
Add callerOrigin as a USVString? attribute on ModelContextClient:
webidlinterface ModelContextClient {
// ... existing members ...
readonly attribute USVString? callerOrigin;
};
callerOrigin is the serialization of the invoking document's origin, produced by running the serialize an origin algorithm. It is null when the invoking agent is a browser's agent.
The browser already computes this value during the exposedTo allowlist check it is the target origin in the tool is visible to an origin algorithm. This proposal forwards it to the callback rather than discarding it.
Usage:
jsexecute(input, client) {
if (client.callerOrigin === "https://partner-agent.example") {
return { summary: getSummary(input.id) };
}
return { full: getFullRecord(input.id) };
}
Precedent
MessageEvent.origin (HTML §9.4.3) is the closest parallel. In postMessage, the browser enforces origin-based routing; MessageEvent.origin lets the receiver differentiate among already-permitted senders rather than gate access. The motivation here is identical: exposedTo is the allowlist, the browser enforces it, and callerOrigin lets the registrant distinguish which permitted party acted.
Spec delta
The change touches two places in the current spec:
§4.2.3 ModelContextClient interface add the callerOrigin attribute to the IDL and define its value as the serialized origin of the invoking document, set by the browser when constructing the ModelContextClient instance passed to execute.
§3 tool definition / execute steps the execute steps for imperatively-registered tools (currently "steps that invoke the supplied ToolExecuteCallback") need to specify that the ModelContextClient passed to the callback is constructed with callerOrigin set to the serialized origin of the invoking document at the point the allowlist check passes.
The native-agent case
For tools invoked by a browser's agent (no explicit exposedTo, or invoked natively), callerOrigin should be null.
Rationale: a browser's agent has no document origin in the sense the web platform uses that term. Using null (rather than a sentinel string like "browser") is the correct type-safe choice it avoids introducing an unstructured magic string into an otherwise origin-typed field, it is consistent with how the platform handles absent origins elsewhere (e.g. opaque origins serializing to "null" is already a known footgun, so we should not add another string consumers need to guard against), and it gives registrants a clean boolean branch: if (client.callerOrigin === null) means native agent. This does intersect with the open question in the explainer about native-agent exposure and should be resolved in coordination with that discussion.
Related issues
- #179 adds toolchange and the cross-origin discovery model this proposal's registrant-side signal completes
- #178 ModelContextClient interface definition; callerOrigin is an addition to this interface
- #180 cross-origin invocation mechanics; the IPC routing path that already computes the value being proposed here
- #159 / #160 multi-origin exposedTo use cases that motivated tiered tool access and are the primary driver for needing caller identity at invocation time
- Lenguaje dominante
- Bikeshed
- Estrellas
- 4.7k
- Forks
- 328
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 16
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de webmachinelearning/webmcp
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
webmachinelearning/webmcp#360 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Say how an agent should weigh annotations that the page wrote about itselfPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
webmachinelearning/webmcp#353 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
webmachinelearning/webmcp#343 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Agenda+ i18n-tracker
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
webmachinelearning/webmcp#273 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
a11y-tracker Agenda+
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
webmachinelearning/webmcp#272 · 4 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de webmachinelearning/webmcp
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
CLIMADA-project/climada_python#1337 ·
Los mantenedores suelen responder en 3 días
-
client.HTTPFetcher doesn't close non-200 response bodies, so connections leakPosiblemente ocupada @grempe la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
transparency-dev/tessera#1245 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
mattpolzin/harmony#435 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
kristoff-it/ziggy#87 ·
-
listFeatures/getFeatureExamples never return Kotlin examples for Android or server Kotlin SDKsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
appwrite/mcp-for-docs#23 · 1 comentario ·