feat: add WebMCP tool definitions for AI agent browser interaction

This commit is contained in:
Graham McIntire 2026-04-17 14:17:28 -05:00
parent ca041fe5aa
commit 12aa724a86

View file

@ -2524,3 +2524,51 @@ if (process.env.NODE_ENV === "development") {
window.liveReloader = reloader
})
}
// WebMCP: expose site tools to AI agents
// https://webmachinelearning.github.io/webmcp/
if (typeof navigator !== "undefined" && (navigator as any).modelContext) {
(navigator as any).modelContext.provideContext({
tools: [
{
name: "navigate",
description: "Navigate to a page on TowerOps",
inputSchema: {
type: "object",
properties: {
path: {
type: "string",
description: "The path to navigate to, e.g. /dashboard or /users/register"
}
},
required: ["path"]
},
execute({ path }: { path: string }) {
window.location.href = path;
}
},
{
name: "view_api_docs",
description: "Open the TowerOps API documentation",
inputSchema: {
type: "object",
properties: {}
},
execute() {
window.location.href = "/docs/api";
}
},
{
name: "register",
description: "Start the registration flow for a new TowerOps account",
inputSchema: {
type: "object",
properties: {}
},
execute() {
window.location.href = "/users/register";
}
}
]
});
}