Tomasz Czajka

Agenti IA

WebMCP: questo sito parla con gli agenti IA

WebMCP è un nuovo standard del browser. Una pagina web descrive ciò che sa fare sotto forma di strumenti, ciascuno con un nome, una descrizione e uno schema JSON di input. Un agente IA nel browser usa poi il sito tramite questi strumenti, invece di indovinare dove cliccare.

Il tuo browser

Verifica in corso…

Per collegare un agente vero, usa una versione recente di Chrome e attiva il flag "WebMCP for testing" in chrome://flags.

Come funziona

  1. 1

    La pagina dichiara gli strumenti

    Ogni funzionalità registra i propri strumenti in Angular. Gli strumenti del Campo minato esistono solo mentre il gioco è sullo schermo.

  2. 2

    Il browser li elenca

    Il browser mostra all'agente gli strumenti della pagina aperta: nomi, descrizioni e schemi di input.

  3. 3

    L'agente chiama uno strumento

    Lo strumento chiama lo stesso servizio Angular dei pulsanti, quindi la pagina si aggiorna come se avesse cliccato una persona.

Playground

Chiama uno strumento come farebbe un agente. Il gioco a destra è attivo, quindi anche i suoi strumenti sono disponibili in questa pagina.

Campo minato

Difficoltà

Bombe rimaste 10
Bandierine piazzate 0
Punteggio 0
Avanzamento 0 / 71
Clic sinistro per scoprire una casella. Clic destro per piazzare una bandierina.

Registro attività

Ogni chiamata a uno strumento su questo sito, da un agente IA o dal playground. Espandi una riga per vedere il JSON.

  • Ancora nessuna chiamata. Esegui uno strumento nel playground o lascia giocare un agente.

Catalogo degli strumenti

Tutti gli strumenti che questo sito può esporre e dove sono disponibili.

Ogni pagina

list_pages Attivo ora Sola lettura

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

Nessun input

navigate_to_page Attivo ora

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

Schema di input
{
  "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 Attivo ora

Switches the website language and keeps the current page open.

Schema di input
{
  "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 Attivo ora

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

Schema di input
{
  "type": "object",
  "properties": {
    "scheme": {
      "type": "string",
      "enum": [
        "light",
        "dark"
      ]
    }
  },
  "required": [
    "scheme"
  ]
}
set_seasonal_effect Attivo ora

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

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

Pagina Campo minato

Apri pagina
minesweeper_get_board Attivo ora Sola lettura

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

Nessun input

minesweeper_reveal_cell Attivo ora

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

Schema di input
{
  "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 Attivo ora

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

Schema di input
{
  "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 Attivo ora Con effetti

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).

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

Pagina Bot delle battute

Apri pagina
ask_joke_botOutput non attendibile

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

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

Per sviluppatori

Gli strumenti sono semplici costanti che chiamano servizi Angular. La registrazione li lega al ciclo di vita dell'app o di un componente.

Definire uno strumento

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}.`;
  },
});

Registrare strumenti per ogni pagina

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

Registrare strumenti per un componente

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

Provalo nella console dei DevTools

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 });