fn(mcp_url$0, mcp_token$1, handler$2) =>
#get_parts<@wasi.io>({
ids: $2.part_ids,
then: fn(parts$3) =>
#outgoing_request<@wasi.io>({
request: {
method: "POST",
url: $0,
headers: [
{name: "Content-Type", value: "application/json"},
{name: "Accept", value: "application/json, text/event-stream"}
],
secret_headers: [{name: "Authorization", prefix: "Bearer ", secret: $1}],
body: @core.string-to-bytes(
value: @definy.json-to-string(
value: #object<@definy.json>([
{key: "jsonrpc", value: #string<@definy.json>("2.0")},
{key: "id", value: #number<@definy.json>(1)},
{key: "method", value: #string<@definy.json>("tools/call")},
{
key: "params",
value: #object<@definy.json>([
{key: "name", value: #string<@definy.json>("definy_commit_parts")},
{
key: "arguments",
value: #object<@definy.json>([
{key: "project", value: #string<@definy.json>("host-release")},
{key: "branch", value: #string<@definy.json>("main")},
{key: "message", value: #string<@definy.json>("Build the release (html-ui.build-release)")},
{
key: "changes",
value: #array<@definy.json>([
@html-ui.release-change(part: "host-release.runtime-script", value: @definy.cloudflare-service-runtime-script),
@html-ui.release-change(
part: "host-release.app-wasm-base64",
value: @std.bytes-to-base64(bytes: @core.compile-to-wasm(expr: $2.expression, parts: $3))
),
@html-ui.release-change(part: "host-release.host-script", value: @definy.node-host-script)
])
}
])
}
])
}
])
)
)
},
then: fn(result$4) =>
match $4 {
#error(message$5) =>
#done<@wasi.io>(@core.string-concat(left: "The MCP request failed: ", right: $5)),
#ok(response$6) =>
#done<@wasi.io>(@std.string-join(items: ["HTTP ", @std.number-to-string(value: $6.status), ": ", $6.text], separator: ""))
}
})
})