Expose in-page tools via WebMCP on answerloops.com

Đang mở
#41 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
15/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement frontend question

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 @NathanTarbert on 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

  1. Public keyless endpoints — /api/public/search (KB search) and /api/public/ask (grounded answer), scoped to the AnswerLoops org via the server-side token, reusing searchKbCore / generateAnswerCore. Add both to auth.ts PUBLIC_PATHS. Reuse rateLimitShared per-IP.
  2. Client registration component — a 'use client' island mounted in app/layout.tsx:
    if (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
    }
    
    Feature-detect document.modelContext; use navigator.modelContext only as a trailing fallback. Unregister via the AbortController signal on unmount.
  3. Declarative fallback — add toolname / tooldescription attributes 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.
  4. Origin-trial token — register answerloops.com for the Chrome origin trial and add the <meta http-equiv="origin-trial"> token (or Origin-Trial header) so it works before Chrome 157 ships.
  5. Docs — new content/docs/integrations/webmcp.mdx; update content/docs/introduction.mdx capability table and public/llms.txt (triggers the update-llms-txt skill).

Acceptance criteria

  • document.modelContext.registerTool is called on answerloops.com for 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

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.

Ngôn ngữ chính
TypeScript
Star
0
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DeadantCo/answerLoopsdev

Tất cả issue của DeadantCo/answerLoopsdev

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.