Tomasz Czajka

AI-agenter

WebMCP: den här webbplatsen pratar med AI-agenter

WebMCP är en ny webbläsarstandard. En webbsida beskriver vad den kan göra som verktyg, vart och ett med namn, beskrivning och ett JSON-indataschema. En AI-agent i webbläsaren använder sidan genom verktygen i stället för att gissa var den ska klicka.

Din webbläsare

Kontrollerar…

För att ansluta en riktig agent, använd en aktuell Chrome och aktivera flaggan ”WebMCP for testing” i chrome://flags.

Så fungerar det

  1. 1

    Sidan deklarerar verktyg

    Varje funktion registrerar sina verktyg i Angular. Minröjar-verktygen finns bara medan spelet visas.

  2. 2

    Webbläsaren listar dem

    Webbläsaren visar agenten den öppna sidans verktyg: namn, beskrivningar och indatascheman.

  3. 3

    Agenten anropar ett verktyg

    Verktyget anropar samma Angular-tjänst som knapparna, så sidan uppdateras som om en person hade klickat.

Lekplats

Anropa ett verktyg som en agent skulle göra. Spelet till höger körs live, så dess verktyg är aktiva även på den här sidan.

Minsökare

Svårighetsgrad

Bomber kvar 10
Placerade flaggor 0
Poäng 0
Framsteg 0 / 71
Vänsterklicka för att avslöja en ruta. Högerklicka för att placera en flagga.

Aktivitetslogg

Varje verktygsanrop på webbplatsen, från en AI-agent eller från lekplatsen. Fäll ut en rad för att se JSON.

  • Inga anrop än. Kör ett verktyg på lekplatsen eller låt en agent spela.

Verktygskatalog

Alla verktyg som den här webbplatsen kan erbjuda, och var de finns.

Alla sidor

list_pages Aktiv nu Endast läsning

Lists the pages of this website, the article ids, the supported languages and the page that is open now.

Ingen indata

navigate_to_page Aktiv nu

Opens a page of this website in the current language. For a specific article pass page "articles" and its article id.

Indataschema
{
  "type": "object",
  "properties": {
    "page": {
      "type": "string",
      "enum": [
        "home",
        "games",
        "minesweeper",
        "chess",
        "mill",
        "abalone",
        "articles",
        "joker",
        "webmcp",
        "contact",
        "links"
      ],
      "description": "Page to open."
    },
    "article": {
      "type": "string",
      "enum": [
        "resource-sandbox",
        "birds",
        "r2r-vs-ros2"
      ],
      "description": "Optional article id, only with page \"articles\"."
    }
  },
  "required": [
    "page"
  ]
}
set_language Aktiv nu

Switches the website language and keeps the current page open.

Indataschema
{
  "type": "object",
  "properties": {
    "language": {
      "type": "string",
      "enum": [
        "pl",
        "en",
        "de",
        "fr",
        "es",
        "it",
        "pt",
        "uk",
        "no",
        "sv",
        "zh",
        "ja",
        "hi"
      ],
      "description": "pl=Polish, en=English, de=German, fr=French, es=Spanish, it=Italian, pt=Portuguese (Brazil), uk=Ukrainian, no=Norwegian, sv=Swedish, zh=Chinese, ja=Japanese, hi=Hindi."
    }
  },
  "required": [
    "language"
  ]
}
set_color_scheme Aktiv nu

Switches the website between the light and the dark color scheme.

Indataschema
{
  "type": "object",
  "properties": {
    "scheme": {
      "type": "string",
      "enum": [
        "light",
        "dark"
      ]
    }
  },
  "required": [
    "scheme"
  ]
}
set_seasonal_effect Aktiv nu

Sets the decorative animated overlay. "auto" picks one by date: snow in winter, butterflies in spring, halloween in October.

Indataschema
{
  "type": "object",
  "properties": {
    "effect": {
      "type": "string",
      "enum": [
        "auto",
        "off",
        "snow",
        "butterflies",
        "halloween"
      ]
    }
  },
  "required": [
    "effect"
  ]
}

Minröjarsidan

Öppna sidan
minesweeper_get_board Aktiv nu Endast läsning

Returns the visible board, the game status and the counters. Hidden cells never reveal whether they hold a mine.

Ingen indata

minesweeper_reveal_cell Aktiv nu

Reveals a hidden cell, like a left click. Revealing a mine loses the game. Returns the updated board.

Indataschema
{
  "type": "object",
  "properties": {
    "row": {
      "type": "integer",
      "minimum": 0,
      "maximum": 23,
      "description": "0-based row, top to bottom."
    },
    "col": {
      "type": "integer",
      "minimum": 0,
      "maximum": 29,
      "description": "0-based column, left to right."
    }
  },
  "required": [
    "row",
    "col"
  ]
}
minesweeper_toggle_flag Aktiv nu

Toggles a flag on a hidden cell, like a right click. Returns the updated board.

Indataschema
{
  "type": "object",
  "properties": {
    "row": {
      "type": "integer",
      "minimum": 0,
      "maximum": 23,
      "description": "0-based row, top to bottom."
    },
    "col": {
      "type": "integer",
      "minimum": 0,
      "maximum": 29,
      "description": "0-based column, left to right."
    }
  },
  "required": [
    "row",
    "col"
  ]
}
minesweeper_new_game Aktiv nu Får följder

Discards the current game and starts a new one. Optionally switches the difficulty: beginner (9×9, 10 mines), intermediate (16×16, 40 mines), expert (16 rows × 30 columns, 99 mines) or custom (the last custom size).

Indataschema
{
  "type": "object",
  "properties": {
    "difficulty": {
      "type": "string",
      "enum": [
        "beginner",
        "intermediate",
        "expert",
        "custom"
      ]
    }
  }
}

Skämt-bot-sidan

Öppna sidan
ask_joke_botOpålitlig utdata

Sends a message to the AI joke bot on this page. The message and the answer appear in the chat. Returns the joke.

Indataschema
{
  "type": "object",
  "properties": {
    "topic": {
      "type": "string",
      "description": "Topic or message for the joke bot."
    }
  },
  "required": [
    "topic"
  ]
}

För utvecklare

Verktyg är vanliga konstanter som anropar Angular-tjänster. Registreringen knyter dem till appens eller en komponents livstid.

Definiera ett verktyg

export const SET_COLOR_SCHEME = defineWebMcpTool({
  name: 'set_color_scheme',
  description: 'Switches the website between the light and the dark color scheme.',
  inputSchema: {
    type: 'object',
    properties: { scheme: { type: 'string', enum: ['light', 'dark'] } },
    required: ['scheme'],
  },
  execute: (input) => {
    inject(ColorSchemeService).setScheme(input.scheme);
    return `Color scheme set to ${input.scheme}.`;
  },
});

Registrera verktyg för alla sidor

export const appConfig: ApplicationConfig = {
  providers: [
    provideWebMcpTools('site', SITE_WEBMCP_TOOLS),
  ],
};

Registrera verktyg för en komponent

export class MinesweeperComponent {
  constructor() {
    declareWebMcpTools('minesweeper', MINESWEEPER_WEBMCP_TOOLS);
  }
}

Prova i DevTools-konsolen

const tools = await document.modelContext.getTools();
tools.map((tool) => tool.name);

const reveal = tools.find((tool) => tool.name === 'minesweeper_reveal_cell');
await document.modelContext.executeTool(reveal, { row: 4, col: 4 });