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 · Advanced
Ngôn ngữ
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.

Evidence for this claim 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. Scope: secure browser context Confidence: high · Verified: 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. Evidence for this claim The imperative API registers named, described, schema-constrained callbacks and supports state-aware cleanup with AbortSignal plus tool-set change notifications. Scope: Current draft and Chrome experiment; API details may change before stable release. Confidence: high · Verified: WebMCP ModelContext API Chrome: WebMCP Imperative API

WebMCP tools should follow the page's real state: register a valid action, execute the same logic as the UI, and remove it when the action is no longer available. Nguồn: Patrick Stox — WebMCP

Five numbered steps run left to right. First, the page registers a name, description, input schema, and callback. Second, an agent already in the page context discovers it. Third, the agent invokes it with validated structured arguments. Fourth, the page reuses its normal application logic and updates the visible interface. Fifth, it returns a bounded result or safe error. A branch from execution shows that state changes or navigation should unregister the tool with AbortSignal and notify observers through 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ủ. Evidence for this claim 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. Scope: Architecture-selection guidance, not a rule that prevents an application from using both technologies. Confidence: high · Verified: Chrome: When to use WebMCP and MCP

WebMCP owns page-context actions; remote MCP owns durable application-to-server integrations. Many products will use both. Nguồn: WebMCP

The left lane shows WebMCP: a browser agent interacts with an open web page, which owns a JavaScript tool and current visible session state. The page must be open for those tools to exist. The right lane shows remote MCP: an AI application connects through an MCP client to a persistent MCP server, which can remain available outside a browser tab. The two lanes are complementary rather than replacements.

© 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 tranghiệ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 trangFallback 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. Evidence for this claim Current Chrome documentation uses document.modelContext and says navigator.modelContext is deprecated beginning in Chrome 150. Scope: Chrome implementation guidance checked July 17, 2026; version and API-name claims expire quickly. Confidence: high · Verified: 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.

Evidence for this claim Current Chrome documentation uses document.modelContext; navigator.modelContext is deprecated in Chrome 150. Scope: browser document Confidence: high · Verified: 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. Evidence for this claim Chrome documents declarative WebMCP form annotations, but the July 10, 2026 Community Group draft says its Declarative WebMCP section is entirely TODO. Scope: A direct comparison between Chrome implementation documentation and the current draft; it does not imply Chrome's experimental implementation is unavailable. Confidence: high · Verified: 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.

Evidence for this claim Chrome documents declarative WebMCP form annotations, but the July 10, 2026 Community Group draft says its Declarative WebMCP section is entirely TODO. Scope: A direct comparison between Chrome implementation documentation and the current draft; it does not imply Chrome's experimental implementation is unavailable. Confidence: high · Verified: 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.
Evidence for this claim WebMCP tool exposure is origin-isolated and controlled by the tools Permissions Policy; cross-origin iframes require explicit delegation. Scope: browser document Confidence: high · Verified: 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. Evidence for this claim 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. Scope: Threat-model and defensive guidance; application authorization and confirmation remain implementation responsibilities. Confidence: high · Verified: 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. readOnlyHintuntrustedContentHint 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ử. Evidence for this claim WebMCP testing should combine deterministic contract and UI-state tests with probabilistic evaluation of agent tool selection and use. Scope: Chrome's evaluation guidance; teams must define product-specific tasks, models, risks, and thresholds. Confidence: high · Verified: 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. Evidence for this claim 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. Scope: 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. Confidence: high · Verified: 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

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.