Expose in-page tools via WebMCP on answerloops.com
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 15/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, next.js, typescript
- 領域
- api, documentation, frontend, security
研究方向
Start in auth.ts (PUBLIC_PATHS) and /api/widget/chat, then read lib/agent/core to see how searchKbCore and generateAnswerCore are reached. The issue first needs a decision on the server-side org token and the public routes, so do not begin with the client code. Done means document.modelContext.registerTool registers at least two read-only tools backed by real endpoints, with no credential sent to the client and the routes IP-rate-limited via rateLimitShared.
由索引模型根據 Issue 內容生成。
描述
Copied from DeadantCo/answerLoops#31 · originally opened by sethr07 on 2026-11-20
Copied from https://github.com/answerLoops/answerLoops/issues/133 — originally opened by
@NathanTarberton 2026-09-08
Summary
Expose in-page tools on answerloops.com through WebMCP so a browser agent (ChatGPT desktop's built-in browser, Chrome's agent) can call our knowledge base directly from the marketing site without an API key. This is the last unaddressed Usability gap from the agent-readiness scan (PR #132 closed OpenAPI discoverability + scoped permissions; MCP Apps and Wikipedia/Wikidata are tracked separately).
Background
WebMCP is a Web Machine Learning Community Group draft (11 June 2026 report — not yet a W3C Standard). It ships as a Chrome origin trial across Chrome 149–156, ending 2026-11-16, with chrome://flags/#enable-webmcp-testing for local testing. Shipping is currently targeted for Chrome 157. ChatGPT's desktop app can already discover and call WebMCP site tools in its built-in browser where the feature is available.
The scan flagged: "No WebMCP support detected — no tool-attribute forms and no document.modelContext / navigator.modelContext usage found."
The blocker to resolve first
The marketing site has no keyless, AnswerLoops-scoped query surface today. The widget chat endpoint (/api/widget/chat) is keyed by a per-customer widget token, and the Agent API needs an al_live_ key. A WebMCP tool on a public page has neither.
Proposed: add a server env var (name TBD, e.g. ANSWERLOOPS_PUBLIC_WIDGET_TOKEN) pointing at AnswerLoops' own org, and a thin public route (/api/public/ask, /api/public/search) that resolves that token server-side (never exposed to the client), runs the existing lib/agent/core pipeline against our own published KB, and is IP-rate-limited like /api/widget/chat. This is a new integration surface + new env var, so it needs a Production Setup Guide entry and the infra-test skill.
Implementation sketch
- Public keyless endpoints —
/api/public/search(KB search) and/api/public/ask(grounded answer), scoped to the AnswerLoops org via the server-side token, reusingsearchKbCore/generateAnswerCore. Add both toauth.tsPUBLIC_PATHS. ReuserateLimitSharedper-IP. - Client registration component — a
'use client'island mounted inapp/layout.tsx:
Feature-detectif (document.modelContext) { const c = new AbortController() await document.modelContext.registerTool({ name: 'search_answerloops_docs', description: "Search AnswerLoops' own knowledge base and docs.", inputSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] }, annotations: { readOnlyHint: true, consequentialHint: false }, execute: async ({ query }) => { const r = await fetch('/api/public/search?query=' + encodeURIComponent(query)) return await r.text() }, }, { signal: c.signal }) // + ask_answerloops → /api/public/ask }document.modelContext; usenavigator.modelContextonly as a trailing fallback. Unregister via theAbortControllersignal on unmount. - Declarative fallback — add
toolname/tooldescriptionattributes to an existing form (e.g. the waitlist form) as server-rendered evidence, per the scan note that declarative forms are "preview" and shouldn't be the only surface. - Origin-trial token — register
answerloops.comfor the Chrome origin trial and add the<meta http-equiv="origin-trial">token (orOrigin-Trialheader) so it works before Chrome 157 ships. - Docs — new
content/docs/integrations/webmcp.mdx; updatecontent/docs/introduction.mdxcapability table andpublic/llms.txt(triggers the update-llms-txt skill).
Acceptance criteria
-
document.modelContext.registerToolis called onanswerloops.comfor at least two read-only tools, backed by real endpoints (not mocked). - Tools work in Chrome with the origin-trial token, and after Chrome 157 without it.
- No credential is exposed to the client — the AnswerLoops org token stays server-side.
- Public endpoints are IP-rate-limited and KB-scoped to our own org only.
- Re-run the agent-readiness scan and confirm the WebMCP check passes.
- infra-test + update-llms-txt skills run; Production Setup Guide gets the new env var.
References
- https://developer.chrome.com/docs/ai/webmcp/imperative-api
- https://developer.chrome.com/docs/ai/webmcp/secure-tools
- https://github.com/webmachinelearning/webmcp
- https://www.infoq.com/news/2026/06/webmcp-web-agent-standard-chrome/
Start here: new to the project? Read CONTRIBUTING.md first. It covers the ground rules, running answerLoops locally, and how to open a pull request.
- 主要語言
- TypeScript
- 星號
- 0
- 分支
- 0
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
DeadantCo/answerLoopsdev 的其他 Issue
-
Widget: match the chat bubble color to the rest of the widget可能已有人在做 @sethr07 今天認領。 未關閉enhancement frontend help wanted
難度 2/5 半天 新手友好度 75/100
DeadantCo/answerLoopsdev#68 · 3 則留言 ·
-
Widget: make the chat window fit on small phones可能已有人在做 @sethr07 今天認領。 未關閉enhancement frontend good first issue help wanted
難度 2/5 1-3 小時 新手友好度 70/100
DeadantCo/answerLoopsdev#67 · 9 則留言 ·
-
Add 'select all' option to Slack channel picker in Settings可能已有人在做 @sethr07 今天認領。 未關閉frontend good first issue
難度 2/5 1-3 小時 新手友好度 68/100
DeadantCo/answerLoopsdev#22 · 5 則留言 ·
-
enhancement frontend help wanted
難度 4/5 3-5 天 新手友好度 45/100
DeadantCo/answerLoopsdev#141 ·
-
backend enhancement frontend help wanted
難度 4/5 3-5 天 新手友好度 45/100
DeadantCo/answerLoopsdev#140 ·
查看 DeadantCo/answerLoopsdev 的全部 Issue
相似的 Issue
-
chore
難度 2/5 1-3 小時 新手友好度 82/100
drydocs/meridian#1503 · 1 則留言 ·
維護者通常 2 天內回覆
-
refactor review: high
難度 2/5 1-3 小時 新手友好度 72/100
1lck/Lithe-IDEA#2376 ·
維護者通常 1 天內回覆
-
bug extension mcp
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
primer/primitives#1426 ·
-
難度 1/5 1 小時以內 新手友好度 88/100
danielmiessler/LifeOS#2941 ·
維護者通常 4 天內回覆