Tomasz Czajka

AI 代理

WebMCP: 这个网站能与 AI 代理对话

WebMCP 是一项新的浏览器标准. 网页把自己能做的事描述为工具, 每个工具都有名称, 说明和 JSON 输入模式. 浏览器中的 AI 代理通过这些工具使用网站, 而不是猜测该点击哪里.

你的浏览器

正在检测…

要连接真正的代理, 请使用较新版本的 Chrome, 并在 chrome://flags 中启用 "WebMCP for testing".

工作原理

  1. 1

    页面声明工具

    每个功能都在 Angular 中注册自己的工具. 扫雷工具只在游戏显示时存在.

  2. 2

    浏览器列出工具

    浏览器向代理展示当前页面的工具: 名称, 说明和输入模式.

  3. 3

    代理调用工具

    工具调用的是与按钮相同的 Angular 服务, 所以页面的变化和真人点击完全一样.

试验场

像代理一样调用工具. 右侧的游戏是实时运行的, 所以它的工具在本页同样可用.

扫雷

难度

剩余地雷 10
已放置旗帜 0
得分 0
进度 0 / 71
左键翻开方块, 右键插旗.

调用日志

本站的每次工具调用, 无论来自 AI 代理还是试验场. 展开一行即可查看 JSON.

  • 还没有调用. 在试验场运行一个工具, 或者让代理来玩.

工具目录

本网站可以提供的全部工具, 以及它们在哪里可用.

所有页面

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

为单个组件注册工具

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