Skip to content

Commit 0faf1d5

Browse files
committed
Add more details
1 parent 77553aa commit 0faf1d5

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

declarative-api-explainer.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,42 @@ When forms with these attributes are inserted, removed, or these attributes are
5656
creates a new declarative WebMCP tool whose input schema is generated according to
5757
[Input schema synthesis](#input-schema-synthesis).
5858

59-
TODO(domfarolino): Describe the `toolparamname` and `toolparamdescription` attributes, and how they
60-
are processed on form-associated elements.
59+
We also introduce the new `toolparamname` and `toolparamdescription` attributes, which apply to form
60+
control elements. They contribute to a declarative form tool's input schema, by specifying the name
61+
and description of individual parameters inside that schema. In this sense, the following imperative
62+
structure:
63+
64+
```js
65+
window.navigator.modelContext.provideContext({
66+
tools: [
67+
{
68+
name: "search-cars",
69+
description: "Perform a car make/model search",
70+
inputSchema: {
71+
type: "object",
72+
properties: {
73+
make: { type: "string", description: "The vehicle's make (e.g., BMW, Ford)" },
74+
model: { type: "string", description: "The vehicle's model (e.g., 330i, F-150)" },
75+
},
76+
required: ["make", "model"]
77+
},
78+
execute({make, model}, agent) {
79+
...
80+
}
81+
}
82+
]
83+
});
84+
```
85+
86+
... is equivalent to the following declarative form:
87+
88+
```html
89+
<form toolname="search-cars" tooldescription="Perform a car make/model search" [...]>
90+
<input type=text toolparamname="make" toolparamdescription="The vehicle's make (i.e., BMW, Ford)" required>
91+
<input type=text toolparamname="model" toolparamdescription="The vehicle's model (i.e., 330i, F-150)" required>
92+
<button type=submit>Search</button>
93+
</form>
94+
```
6195

6296
## Processing model
6397

@@ -105,7 +139,15 @@ interface SubmitEvent : Event {
105139

106140
**`toolactivated` and `toolcanceled` events
107141

108-
TODO: Fill this out.
142+
We introduce these new events that get fired against he `Window` object when a WebMCP tool is run,
143+
and when its invocation is canceled. Some open questions:
144+
145+
> [!WARNING]
146+
> Should these events fire for imperative tool call invocations as well?
147+
148+
> [!WARNING]
149+
> For declarative, should they be fired at `Window` or at the `<form>` that registered the tool in
150+
> the first place, and bubble up to the document that way?
109151
110152
## Integration with other imperative API bits
111153

0 commit comments

Comments
 (0)