Hướng dẫn về WebMCP

WebMCP lets một web trang expose structured tools để an AI agent trong đó trình duyệt. Learn cách điều này differs từ MCP, điều gì Chrome hỗ trợ, security risks, và khi nào nên chờ.

Xuất bản lần đầu: 17 thg 7, 2026 · Cập nhật lần cuối: 8 thg 8, 2026 · Nâng cao
1 tín hiệu bằng chứng trên trang này

WebMCP là an experimental trình duyệt API đó lets an open web trang offer structured tools để an AI agent. Điều này là hữu ích cho bounded trang actions, không web phát hiện hoặc thứ hạng. As of July 17, 2026, điều này là một Community Group draft và Chrome 149 origin trial; hiện tại Chrome các ví dụ dùng document.modelContext, trong khi navigator.modelContext là deprecated trong Chrome 150.

Tóm tắt — WebMCP exposes trang-owned tools từ document.modelContext để agent trong active browsing context. imperative API registers name, mô tả, JSON Schema input, các chú thích, và async callback; tools có thể là state-phụ thuộc và unregistered với AbortSignal. Chrome documents declarative form layer cũng, nhưng July 10, 2026 Community Group draft vẫn labels của nó declarative section TODO. feature là trong Chrome 149 origin trial, không ổn định cross-trình duyệt baseline. Treat nó as progressive enhancement, không SEO infrastructure, và secure nó as authenticated application surface.

Bằng chứng cho nhận định này Chrome documents declarative form annotations such as toolname and tooldescription, but the declarative section of the July 10, 2026 Community Group draft is still marked TODO. Phạm vi: secure browser context Độ tin cậy: cao · Đã xác minh: WebMCP Draft Community Group Report

Cách WebMCP hoạt động trong trình duyệt

hữu ích WebMCP lifecycle begins và ends với trang. trang registers chỉ actions đó là hợp lệ trong của nó hiện tại state; agent đã operating trong đó browsing context discovers và invokes một; trang executes của nó thông thường application logic, cập nhật human-visible interface, và trả về bounded kết quả. Khi state thay đổi, trang xóa tools đó không lâu hơn apply. Bằng chứng cho nhận định này The imperative API registers named, described, schema-constrained callbacks and supports state-aware cleanup with AbortSignal plus tool-set change notifications. Phạm vi: Current draft and Chrome experiment; API details may change before stable release. Độ tin cậy: cao · Đã xác minh: WebMCP ModelContext API Chrome: WebMCP Imperative API

Công cụ WebMCP phải bám theo trạng thái thực của trang: đăng ký một hành động hợp lệ, thực thi cùng logic như giao diện và xóa công cụ khi hành động không còn khả dụng. Nguồn: Patrick Stox — WebMCP

Năm bước được đánh số chạy từ trái sang phải. Đầu tiên, trang đăng ký tên, mô tả, schema đầu vào và callback. Thứ hai, một tác nhân đang ở trong ngữ cảnh trang phát hiện công cụ. Thứ ba, tác nhân gọi công cụ bằng các đối số có cấu trúc đã được xác thực. Thứ tư, trang tái sử dụng logic ứng dụng thông thường và cập nhật giao diện hiển thị. Thứ năm, công cụ trả về một kết quả có giới hạn hoặc lỗi an toàn. Một nhánh từ bước thực thi cho thấy khi trạng thái thay đổi hoặc có điều hướng, trang nên hủy đăng ký công cụ bằng AbortSignal và thông báo cho bên quan sát qua toolchange.

© Patrick Stox LLC · CC BY 4.0 ·

điều này stateful lifecycle là một reason WebMCP nên không become static dump của mỗi function trong JavaScript bundle. tool Đó là không thể trong visible UI nên thông thường là không khả dụng để agent cũng.

WebMCP so với MCP: hai khác runtime boundaries

names invite confusion, nhưng operational boundary là khác. WebMCP lives trong document event loop và hiện tại trình duyệt session. Remote MCP lives tại AI application integration boundary và commonly reaches persistent backend máy chủ. Bằng chứng cho nhận định này WebMCP is designed for tools owned by an active page and its browser context, while remote MCP commonly connects an AI application to a persistent backend server. Phạm vi: Architecture-selection guidance, not a rule that prevents an application from using both technologies. Độ tin cậy: cao · Đã xác minh: Chrome: When to use WebMCP and MCP

WebMCP phụ trách hành động trong ngữ cảnh trang; MCP từ xa phụ trách các tích hợp bền vững giữa ứng dụng và máy chủ. Nhiều sản phẩm sẽ dùng cả hai. Nguồn: WebMCP

Làn bên trái thể hiện WebMCP: một tác nhân trình duyệt tương tác với trang web đang mở, nơi sở hữu công cụ JavaScript và trạng thái phiên đang hiển thị. Trang phải được mở thì các công cụ đó mới tồn tại. Làn bên phải thể hiện MCP từ xa: một ứng dụng AI kết nối qua MCP client đến MCP server thường trực, có thể tiếp tục khả dụng bên ngoài tab trình duyệt. Hai làn bổ sung cho nhau chứ không thay thế nhau.

© Patrick Stox LLC · CC BY 4.0 ·

Interfacenơi nó livesKhi nó là discoveredtrang phải là open?Best fit
WebMCPActive trình duyệt documentsau khi client visits trangCóhiện tại UI state và trang actions
Remote MCPAI client và MCP máy chủqua client/máy chủ configuration hoặc phát hiệnKhôngPersistent tools, dữ liệu, và backend workflows
Web/điểm cuối APIApplication backendqua application-cụ thể integrationKhôngỔn định programmatic access cho known consumers
Dữ liệu có cấu trúctrang markupDuring trang processingthường fetched as nội dungDescribing entities và trang meaning, không executing actions
llms.txtStatic text fileKhi client chọn để yêu cầu nóKhông active tab bắt buộcProposed nội dung hướng dẫn; không callable tool surface
trình duyệt automationAgent/controller interpreting UIsau khi loading và inspecting trangCóFallback nơi không rõ ràng trang tool tồn tại

không chọn từ acronym. chọn từ owner của hành động. nếu hành động cần hiện tại DOM, selection, cart, hoặc UI state, WebMCP có thể fit. nếu nó phải chạy trong background, trên nhiều các trang, hoặc không có open tab, sử dụng API hoặc remote MCP.

imperative API

imperative API registers tool qua document.modelContext.registerTool(). tool bao gồm unique name, mô tả, JSON Schema input, execute callback, và tùy chọn các chú thích. Chrome cũng documents getTools(), executeTool() cho kiểm thử, và toolchange event. Bằng chứng cho nhận định này Current Chrome documentation uses document.modelContext and says navigator.modelContext is deprecated beginning in Chrome 150. Phạm vi: Chrome implementation guidance checked July 17, 2026; version and API-name claims expire quickly. Độ tin cậy: cao · Đã xác minh: Chrome: WebMCP Imperative API

điều này illustrative candidate hiển thị dự kiến shape cho tương lai Schema Validator pilot. nó không phải đang chạy on điều này trang web, và API có thể thay đổi trước khi ổn định phát hành:

if (document.modelContext) {
  const registration = new AbortController();

  await document.modelContext.registerTool({
    name: 'validate_schema',
    description: 'Validate pasted JSON-LD and return bounded issues.',
    inputSchema: {
      type: 'object',
      properties: {
        markup: {
          type: 'string',
          description: 'JSON-LD markup to validate.',
          maxLength: 50000
        }
      },
      required: ['markup'],
      additionalProperties: false
    },
    annotations: {
      readOnlyHint: true,
      untrustedContentHint: true
    },
    execute: async ({ markup }) => {
      const result = await validateWithTheSameEngineAsTheUI(markup);
      renderResultInTheVisibleUI(result);
      return minimizeValidationResult(result);
    }
  }, { signal: registration.signal });

  // When this page state no longer supports validation:
  // registration.abort();
}

quan trọng architecture không phải wrapper. nó là đó callback calls giống nhau validator as visible UI, máy chủ-side limits và authorization vẫn apply, và phản hồi là có chủ ý minimized. Feature detection preserves đầy đủ human workflow trong unsupported các trình duyệt.

sử dụng document.modelContext, không stale các ví dụ được xây dựng khoảng navigator.modelContext; Chrome marks latter deprecated beginning trong Chrome 150. Date đó advice vì feature vẫn experimental.

Bằng chứng cho nhận định này Current Chrome documentation uses document.modelContext; navigator.modelContext is deprecated in Chrome 150. Phạm vi: browser document Độ tin cậy: cao · Đã xác minh: WebMCP Imperative API

declarative API có các tiêu chuẩn mismatch

Chrome documents declarative approach đó annotates ordinary forms với các thuộc tính chẳng hạn như toolname, tooldescription, và toolparamdescription. nó cũng documents tùy chọn toolautosubmit; nếu không, người dùng clicks Submit. SubmitEvent.agentInvoked identifies agent-triggered submission. Bằng chứng cho nhận định này Chrome documents declarative WebMCP form annotations, but the July 10, 2026 Community Group draft says its Declarative WebMCP section is entirely TODO. Phạm vi: A direct comparison between Chrome implementation documentation and the current draft; it does not imply Chrome's experimental implementation is unavailable. Độ tin cậy: cao · Đã xác minh: Chrome: WebMCP Declarative API WebMCP: Declarative WebMCP

Tuy nhiên, đó July 10 Community Group Báo cáo says của nó Declarative WebMCP section là “entirely a TODO” (bản dịch) «hoàn toàn một TODO» và leaves đó form-để-JSON-Schema algorithm chưa xác định. Đó không có nghĩa là Chrome thử nghiệm là imaginary. Điều này có nghĩa là đó implementation tài liệu là ahead of đó normative draft. Treat declarative markup as an experimental Chrome surface, không settled cross-trình duyệt HTML.

Bằng chứng cho nhận định này Chrome documents declarative WebMCP form annotations, but the July 10, 2026 Community Group draft says its Declarative WebMCP section is entirely TODO. Phạm vi: A direct comparison between Chrome implementation documentation and the current draft; it does not imply Chrome's experimental implementation is unavailable. Độ tin cậy: cao · Đã xác minh: Chrome: WebMCP Declarative API WebMCP: Declarative WebMCP

cho hiện tại, ordinary semantic forms vẫn durable base. experimental chú thích layer nên enhance them, không bao giờ replace labels, validation, accessibility, xác nhận, hoặc máy chủ-side authorization.

Tool phát hiện, lifecycle, và cross-origin boundaries

hiện tại API có several boundaries worth designing explicitly:

  • Browsing context: Chrome thử nghiệm requires trình duyệt context. client visits trang web trước khi nó discovers trang web tools.
  • Dynamic availability: register tools Khi họ là hợp lệ và abort của họ registration Khi state hoặc navigation invalidates them. Observers có thể listen cho toolchange.
  • giống nhau origin theo mặc định: tools Permissions Policy defaults để 'self'. Cross-origin iframes cần rõ ràng delegation chẳng hạn như allow="tools".
  • Hai-sided cross-origin consent: tool có thể sử dụng exposedTo để list được phép secure origins, trong khi caller các yêu cầu tools từ named origins với fromOrigins. Một side opting trong không phải đủ.
  • Progressive enhancement: unsupported hoặc disabled WebMCP phải leave ordinary trang fully usable.
Bằng chứng cho nhận định này WebMCP tool exposure is origin-isolated and controlled by the tools Permissions Policy; cross-origin iframes require explicit delegation. Phạm vi: browser document Độ tin cậy: cao · Đã xác minh: WebMCP Imperative API

những điều này là hữu ích nền tảng controls, nhưng họ không turn risky application hành động vào safe một.

Security: trình duyệt session raises stakes

trình duyệt agent có thể operate bên trong người dùng authenticated session. đó có thể là feature—access để hiện tại cart, account, hoặc workspace—và danger. Chrome và draft discuss prompt injection, misleading tool metadata, contaminated tool output, over-rộng parameters, quyền riêng tư leakage, cross-origin exposure, và misuse của signed-trong authority. Bằng chứng cho nhận định này WebMCP tool hints can communicate read-only and untrusted-output intent, but they do not eliminate prompt injection, misleading metadata, privacy leakage, cross-origin risk, or misuse of authenticated browser authority. Phạm vi: Threat-model and defensive guidance; application authorization and confirmation remain implementation responsibilities. Độ tin cậy: cao · Đã xác minh: WebMCP security and privacy considerations Chrome: WebMCP tool security Chrome: Agent security considerations

Treat mỗi tool as công khai application điểm cuối với unusual caller:

  1. giữ tool hẹp. Một job, rõ ràng inputs, tight enums và lengths, không hidden “làm bất cứ điều gì” parameter.
  2. Enforce authorization trong application logic. agent không gain nhiều hơn authority hơn signed-trong người dùng, và hint không phải permission.
  3. Tách biệt đọc từ ghi. readOnlyHint và untrustedContentHint communicate risk; họ không enforce nó.
  4. Require visible xác nhận cho consequences. Purchases, submissions, deletions, messages, và account thay đổi cần human-understandable checkpoint.
  5. Minimize output. trả về chỉ Điều gì task cần; không bao giờ spill session dữ liệu, thô các header, secrets, hoặc unrelated records.
  6. Treat output as untrusted. string được trả về by một tool có thể become input để sau đó model reasoning. không cho phép nó để smuggle instructions hoặc authority.
  7. Log boundary. Record tool, input class, authorization decision, xác nhận, kết quả class, lỗi, origin, và lifecycle không có logging secrets.

Đó safe câu hỏi không phải “Can an agent call this?” (bản dịch) «Có thể an agent call này?» Điều này là “Would I expose this as a reviewed endpoint to a caller that can misunderstand instructions and relay untrusted text?” (bản dịch) «Sẽ I expose này as một reviewed endpoint để một caller đó có thể misunderstand instructions và relay untrusted text?»

Kiểm thử contracts và agent behavior riêng

Chrome eval hướng dẫn separates deterministic sản phẩm các kiểm thử từ probabilistic agent các kiểm thử. Bằng chứng cho nhận định này WebMCP testing should combine deterministic contract and UI-state tests with probabilistic evaluation of agent tool selection and use. Phạm vi: Chrome's evaluation guidance; teams must define product-specific tasks, models, risks, and thresholds. Độ tin cậy: cao · Đã xác minh: Chrome: Evals for WebMCP Cả hai quan trọng:

Deterministic các kiểm thử nên verify registration, schema rejection, hợp lệ và không hợp lệ inputs, authorization, rate limits, side effects, lỗi shape, output minimization, UI parity, unregister behavior, và unsupported-trình duyệt fallback.

Probabilistic evals nên đo lường liệu representative agents discover right tool, tránh irrelevant tools, chọn đúng parameters, ask cho clarification Khi bắt buộc, respect confirmations, dừng sau khi thành công, và resist adversarial các mô tả hoặc output.

không sử dụng một demo prompt as phát hành gate. thành công callback proves code ran; nó không prove đó models select nó reliably hoặc đó hành động là safe.

Cloudflare trình duyệt Chạy: hữu ích lab, không enablement

Cloudflare documents WebMCP hỗ trợ trong trình duyệt Chạy experimental lab pool và nói lab sessions nên không là được sử dụng cho production workloads. Của nó April 23 trang cũng contains older Chrome-era kiểm thử names, so sử dụng đó trang as evidence của Cloudflare’s hiện tại sản phẩm offering—không as authority cho mới nhất WebMCP API shape. Bằng chứng cho nhận định này Cloudflare Browser Run offers experimental lab sessions that can consume and test page-provided WebMCP tools, but the page still owns tool registration and Cloudflare says lab sessions are not for production workloads. Phạm vi: Cloudflare product documentation last updated April 23, 2026; its example API names lag current Chrome documentation and should not be used as the API authority. Độ tin cậy: cao · Đã xác minh: Cloudflare Browser Run: WebMCP

Cloudflare có thể cung cấp trình duyệt session và agent path đó consumes tools. nó không thể infer safe contract cho của bạn application hoặc register trang-owned tools bạn đã làm không xây dựng.

Proposed patrickstox.com pilot: Schema Validator

Schema Markup Validator là good tương lai pilot candidate, không trực tiếp WebMCP implementation. nó đã có bounded pasted input, deterministic logic, structured các vấn đề, và visible kết quả. tương lai validate_schema tool có thể reuse giống nhau validation engine as UI và existing remote MCP tool suite.

pilot nên chờ cho đến khi trình duyệt API reaches ổn định, non-experimental phát hành và truyền fresh security review. đầu tiên version nên là đọc-chỉ, feature-detected, input-limited, phản hồi-minimized, và không khả dụng on preview, admin, hoặc owner-chỉ surfaces. điều này trang web làm không hiện tại claim WebMCP hỗ trợ.

Decision: xây dựng, thử nghiệm, chờ, hoặc skip

SituationDecision
Ổn định trình duyệt hỗ trợ là bắt buộc cho customer workflowChờ và giữ thông thường UI/API hoàn tất
bạn có bounded đọc-chỉ hành động và có thể chạy riêng tư labThử nghiệm, với feature detection và không production dependency
task cần background hoặc headless executionsử dụng API hoặc remote MCP
trang chỉ publishes nội dungSkip WebMCP; improve semantic, accessible HTML
hành động ghi, purchases, submits, deletes, hoặc exposes riêng tư dữ liệukhông pilot casually; require tách biệt threat model và xác nhận design
ổn định implementation ships và all contract/security/parity các kiểm thử truyềncân nhắc progressive production pilot

Thêm ghi chú chuyên gia

Ghim trích dẫn chuyên gia

Người mới? Hãy tạo hồ sơ chưa có người xác nhận cho họ tại /admin/experts/ → Ghim trích dẫn chuyên gia trước.