npm-packages
AGENTS.md104 starsChanged 44 days agoMITView on GitHub
Guidance for AI agents when working with this repository. Both apps are pnpm workspace members. Landing page at mcp-b.ai (also www.mcp-b.ai). Astro 7 (output: 'server') deployed to Cloudflare Workers via @astrojs/cloudflare v14. Dev runs on real workerd (Vite Environment API). WebMCP docs at docs.mcp-b.ai, built with Mintlify (its own CLI runs dev/build; Vite+ only manages its dependencies). Authored following the Diataxis framework.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository4 other files it gives its agents.
- diataxisSkill
- docs-authoringSkill
- mintlifySkill
- releaseSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 1 is common, 2 are distinctive, and 2 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 102
Check the live draft and package source before documenting browser behavior.
- Very specific: line 131
Polyfill: Call installWebMCP() from @mcp-b/webmcp-polyfill.
- Common: line 157
Keep privileged extension APIs and secrets out of the MAIN-world bundle.
- Very specific: line 188
Read the live Community Group draft and compare it with the relevant file in .reference/webmcp/.
- Distinctive: line 215
All code must pass:
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Guidance for AI agents when working with this repository.
Commands
vp install # Install dependencies
pnpm build # Build all packages
pnpm typecheck # Type checking
vp check --fix # Lint, format, and fix (Oxlint + Oxfmt)
vp check # Check without fixing (CI)
pnpm check-all # All checks (typecheck + lint)
pnpm test:unit # Unit tests only
pnpm test:e2e # E2E tests only
pnpm test:wpt # Pinned upstream WebMCP WPT (requires Chrome Canary)
vp test run # Run tests in current package
vp pack # Build current library package
pnpm changeset # Create a changeset for versioningStructure
packages/ # All NPM packages (@mcp-b/*)
apps/ # Deployed apps (landing-page, documentation-website)
e2e/ # E2E tests and test apps
docs/ # Technical documentation
.agents/skills/ # Agent skills and their bundled references/assets
.reference/ # Upstream reference repos (gitignored, shallow clones)Apps (apps/*)
Both apps are pnpm workspace members.
apps/landing-page — @mcp-b/landing-page
Landing page at mcp-b.ai (also www.mcp-b.ai). Astro 7
(output: 'server') deployed to Cloudflare Workers via @astrojs/cloudflare
v14. Dev runs on real workerd (Vite Environment API).
pnpm dev(wrangler types→astro dev),pnpm build(wrangler types→astro check→astro build),pnpm preview.- Cloudflare runtime: env via
import { env } from 'cloudflare:workers';Astro.request.cf; execution context atAstro.locals.cfContext. Do NOT useAstro.locals.runtime(removed from@astrojs/cloudflarein v13, used with Astro 6). - Secrets:
npx wrangler secret put <KEY>; local secrets in.dev.vars. - Config:
astro.config.mjs,wrangler.jsonc. Excluded from rootpnpm build/check-allvia--filter '!@mcp-b/landing-page'.
apps/documentation-website — @mcp-b/documentation-website
WebMCP docs at docs.mcp-b.ai, built with Mintlify (its own CLI runs dev/build; Vite+ only manages its dependencies). Authored following the Diataxis framework.
pnpm dev:docsfrom the root, orpnpm devin the app dir (both runmintlify devat http://localhost:3000).pnpm buildrunsmintlify validate.docs.jsonis the single source of truth for navigation. Do not modify without explicit request.- Authoring rules (Diataxis, writing style, Mintlify components, source-of-truth boundaries) are in .agents/skills/docs-authoring/SKILL.md. Read it before writing or editing docs pages.
Key Files
| File | Purpose |
| CONTRIBUTING.md | Code quality requirements, commit format, PR process |
| .agents/skills/release/SKILL.md | Publishing workflow and troubleshooting |
| docs/TESTING.md | Testing documentation |
| packages/global/WEBMCP-CONFORMANCE-REFERENCES.md | WebMCP spec, WPT, and Chromium source index |
| pnpm-workspace.yaml | Workspace packages and dependency catalog |
| vite.config.ts | Lint, format, staged, and task config (Vite+) |
Quick Reference
- Node: >= 22.18
- Package manager: pnpm (not npm/yarn)
- Toolchain: Vite+ (
vpCLI) — unified dev/build/test/lint/format - Linter: Oxlint (via
vp lint/vp check) - Formatter: Oxfmt (via
vp fmt/vp check) - Bundler: tsdown via
vp pack(config in each package'svite.config.tspackblock) - Test runner: Vitest via
vp test(config in each package'svite.config.tstestblock) - Zod version: MCP SDK v2 requires Zod ^4.2 when used. Zod 3 is unsupported
- Commit format:
<type>(<scope>): <subject>(enforced by hook)
Commit Scopes
Package scopes: global, mcp-iframe, react-webmcp, smart-dom-reader, transports, usewebmcp, webmcp-extension, webmcp-local-relay, webmcp-polyfill, webmcp-ts-sdk, webmcp-types
Repo scopes: root, deps, release, ci, docs, *
WebMCP Architecture
WebMCP Proposal APIs
document.modelContextis the canonical current-draft WebMCP surface.executeTool(tool, inputObject)takes an input object and resolves to a string. Results are JSON, except that native declarative tools can return plain text, so MCP-B treats a result as structured only when it parses to a plain JSON object. String input, string input schemas, and navigator aliases are not supported.- The draft fires
toolactivatedandtoolcancelat the model context. The polyfill fires both for declarative tools;BrowserMcpServerre-dispatches them and addsontoolactivatedandontoolcancel. - Native Chrome lanes require Chrome 155 or later, the first release with object input.
- The vendored core needs Chrome 126, Firefox 126, or Safari 18 (
URL.parse()). On older engines and insecure pages,installWebMCP()installs nothing. - Check the live draft and package source before documenting browser behavior.
- New examples and public documentation use
document.modelContext.
Package Layering
┌─────────────────────────────────────────────────────┐
│ @mcp-b/global │
│ Entry point. Orchestrates polyfill + server setup. │
│ Auto-initializes in browser environments. │
├─────────────────────────────────────────────────────┤
│ @mcp-b/webmcp-ts-sdk (BrowserMcpServer) │
│ Wraps the underlying modelContext. Extends it with │
│ listTools, prompt/resource helpers, and a composed │
│ MCP server. Mirrors core tool ops down to the │
│ native/polyfill context. │
├─────────────────────────────────────────────────────┤
│ @mcp-b/webmcp-polyfill │
│ Bundles upstream webmcp-polyfill (pinned commit). │
│ Exposes installWebMCP() plus temporary MCP-B │
│ declarative tools. │
├─────────────────────────────────────────────────────┤
│ Native browser API (if available) │
│ document.modelContext provided by the browser. │
└─────────────────────────────────────────────────────┘Initialization Flow (@mcp-b/global)
- Polyfill: Call
installWebMCP()from@mcp-b/webmcp-polyfill. It preserves existing native/preinstalled contexts and adds declarative support when missing. That package bundles the upstream source at the commit recorded inpackages/webmcp-polyfill/package.jsonand temporarily retains MCP-B declarative tools. MCPoutputSchemabelongs to@mcp-b/global. - Capture native: A reference to the current document context is saved as
native. - BrowserMcpServer: Uses the page's context by default, installing the upstream polyfill when needed. Global passes its captured
{ native }explicitly. Browser-facing tool registrations mirror down to that context and native tools are reconciled throughgetTools(). In the top frame that includes tools from same-origin descendant frames; in a child frame it mirrors only the frame's own tools. - Replace:
document.modelContextexposes theBrowserMcpServerinstance, which addsregisterPrompt,registerResource,listTools, and other MCP-B extensions. Browser-shaped execution usesgetTools()plusexecuteTool(tool, inputObject). - Cleanup:
cleanupWebModelContext()restores the original native/polyfill context. Closing the server unregisters every tool registered through it; tools registered directly on the underlying context remain. The polyfill and its declarative layer remain installed for the document lifetime.
What Lives Where
| Method / capability | Current draft | @mcp-b/webmcp-polyfill | @mcp-b/global / BrowserMcpServer |
registerTool() | Y | Y | Y (mirrors to core) |
getTools() | Y | Y | Y (delegates to core) |
ontoolchange | Y | Y | Y |
executeTool(tool, input) | Y (object) | Y (object) | Y (object) |
toolactivated / toolcancel | Y | Y (declarative only) | Y (re-dispatched) |
ontoolactivated / ontoolcancel | Y | - | Y |
| MCP-B declarative tools | explainer | Y | Y (via polyfill) |
outputSchema | - | - | Y |
registerPrompt() | - | - | Y |
registerResource() | - | - | Y |
listTools() | - | - | Y |
Extension Integration (@mcp-b/webmcp-extension)
- A MAIN-world content script imports
@mcp-b/global; page code still usesdocument.modelContextnormally. - The isolated content script calls
connectWebMCPClient()and receives the official MCPClient. - Keep privileged extension APIs and secrets out of the MAIN-world bundle.
- The template is top-frame only. Do not add
all_frameswhile@mcp-b/globalselects the iframe-child transport in child frames.
Type ownership
- Upstream
webmcp-typesowns the WebMCP browser contracts anddocument.modelContextdeclaration. Packages pin it exactly to0.1.9; 0.1.10 adds lifecycle members and event classes that the vendored core does not implement. @mcp-b/webmcp-typesforwards upstream exports for existing package consumers; new code importswebmcp-typesdirectly. Both legacy core packages are temporary aliases.@mcp-b/webmcp-ts-sdkowns MCP-B adapter and extension contracts plus schema helpers.@mcp-b/globaldeclares onlywindow.__webModelContextOptions.document.modelContextkeeps the upstream type, so narrow it withisBrowserMcpServer()to reach MCP-B extensions.
Reference Repos (.reference/)
The .reference/ directory (gitignored) holds shallow clones of upstream repos
we track for sync. They are not runtime dependencies. Most are human/AI
references; wpt/ is also the pinned upstream conformance suite used by CI.
| Directory | Upstream | Purpose |
standard-schema/ | standard-schema/standard-schema | @mcp-b/webmcp-ts-sdk/schema reference |
typescript-sdk/ | anthropics/anthropic-sdk-typescript | General SDK reference |
webmcp/ | webmachinelearning/webmcp | WebMCP draft and explainer source |
wpt/ | web-platform-tests/wpt | Executable WebMCP conformance, pinned in CI |
WebMCP Proposal and Conformance
For changes to browser-facing WebMCP behavior:
- Read the live Community Group draft
and compare it with the relevant file in
.reference/webmcp/. The local clone can lag active proposal work. - Inspect
.reference/wpt/webmcp/for executable upstream behavior. WPT is a cross-browser standards suite, not a Chromium-only test repository. - Consult Blink's
third_party/blink/renderer/core/script_tools/only for Chromium-specific implementation details or extensions.
The pinned WPT revision and CI job live in
.github/workflows/e2e.yml. Test selection and
the shared local/CI runner live in
scripts/run-webmcp-wpt.mjs. The WPT lane builds
the standalone polyfill, disables native WebMCP, injects the bundle, and runs an
explicit allowlist. When changing covered behavior, run the shared conformance
suite and replay the WPT lane with
CHROME_BIN=/path/to/chrome-canary pnpm test:wpt. Update the WPT pin
deliberately and review the upstream diff first. See
docs/TESTING.md for the test matrix and why the allowlist
omits the other upstream files.
pnpm test:wpt:idl is a second lane checking API shape rather than behavior.
It needs interfaces in the .reference/wpt sparse checkout and runs
non-blocking in CI; see
docs/TESTING.md.
Before Committing
All code must pass:
pnpm build && pnpm typecheck && vp check && pnpm test:unitDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

