Tomasz Czajka

AIエージェント

WebMCP:このWebサイトはAIエージェントと対話します

WebMCPは新しいブラウザ標準です。Webページは自分にできることを「ツール」として記述し、各ツールには名前、説明、JSONの入力スキーマがあります。ブラウザ内のAIエージェントは、どこをクリックすべきか推測する代わりに、そのツールを通じてサイトを操作します。

お使いのブラウザ

確認中…

実際のエージェントを接続するには、最新のChromeを使い、chrome://flagsで「WebMCP for testing」フラグを有効にしてください。

仕組み

  1. 1

    ページがツールを宣言する

    各機能がAngularにツールを登録します。マインスイーパーのツールは、ゲームが画面に表示されている間だけ存在します。

  2. 2

    ブラウザがツールを一覧にする

    ブラウザは、開いているページのツール(名前、説明、入力スキーマ)をエージェントに示します。

  3. 3

    エージェントがツールを呼び出す

    ツールはボタンと同じAngularサービスを呼び出すので、人がクリックしたときと同じようにページが更新されます。

プレイグラウンド

エージェントと同じ方法でツールを呼び出してみましょう。右側のゲームは実際に動いているので、そのツールもこのページで有効になっています。

マインスイーパー

難易度

残りの地雷 10
立てた旗 0
スコア 0
進捗 0 / 71
左クリックでマスを開き、右クリックで旗を立てます。

アクティビティログ

AIエージェントやプレイグラウンドから、このサイトで行われたすべてのツール呼び出し。行を展開するとJSONを確認できます。

  • まだツール呼び出しはありません。プレイグラウンドでツールを実行するか、エージェントに遊ばせてみましょう。

ツールカタログ

このWebサイトが公開できるすべてのツールと、それぞれが利用できる場所。

全ページ

list_pages 現在有効 読み取り専用

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

入力なし

navigate_to_page 現在有効

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

入力スキーマ
{
  "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 現在有効

Switches the website language and keeps the current page open.

入力スキーマ
{
  "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 現在有効

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

入力スキーマ
{
  "type": "object",
  "properties": {
    "scheme": {
      "type": "string",
      "enum": [
        "light",
        "dark"
      ]
    }
  },
  "required": [
    "scheme"
  ]
}
set_seasonal_effect 現在有効

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

入力スキーマ
{
  "type": "object",
  "properties": {
    "effect": {
      "type": "string",
      "enum": [
        "auto",
        "off",
        "snow",
        "butterflies",
        "halloween"
      ]
    }
  },
  "required": [
    "effect"
  ]
}

マインスイーパーのページ

ページを開く
minesweeper_get_board 現在有効 読み取り専用

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

入力なし

minesweeper_reveal_cell 現在有効

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

入力スキーマ
{
  "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 現在有効

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

入力スキーマ
{
  "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 現在有効 副作用あり

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

入力スキーマ
{
  "type": "object",
  "properties": {
    "difficulty": {
      "type": "string",
      "enum": [
        "beginner",
        "intermediate",
        "expert",
        "custom"
      ]
    }
  }
}

ジョークボットのページ

ページを開く
ask_joke_bot信頼できない出力

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

入力スキーマ
{
  "type": "object",
  "properties": {
    "topic": {
      "type": "string",
      "description": "Topic or message for the joke bot."
    }
  },
  "required": [
    "topic"
  ]
}

開発者向け

ツールはAngularサービスを呼び出すただの定数です。登録によって、アプリまたはコンポーネントのライフタイムに紐づけられます。

ツールを定義する

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

全ページ向けにツールを登録する

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

1つのコンポーネント向けにツールを登録する

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

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