Logo di @mcp-b

@mcp-b

Organizzazione
WebMCP-org

NPM packages for MCP-B: Transport layers, React hooks, and browser tools for the Model Context Protocol

AutoreWebMCP-org
Repositorynpm-packages
LinguaTypeScript
Fork
20
Stelle
98
Strumenti disponibili
0
Tipo di trasportostdio
Categorie
LicenzaMIT
Link
  • Collega gli strumenti ai flussi di lavoro IA

    @mcp-b mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    98 stelle e 20 fork nel repository collegato.

@mcp-b

Polyfill and MCP bridge for the Web Model Context API (document.modelContext)


The Web Standard

The Web Model Context API is a W3C Community Group draft spec. It makes every browser tab a tool source — web pages register tools that AI agents can discover and call:

document.modelContext
├── .registerTool(tool, { signal })  Register a tool for AI agents
└── .getTools()                      Discover registered tools

Chrome preview extension
└── .executeTool(tool, inputJson)    Execute a discovered tool

MCP-b polyfills that API for all browsers today, and bridges it to the full Model Context Protocol — turning that tool source into a complete MCP server with prompts, resources, and browser transports.

Built by MCP-b. Not an official W3C or MCP project.

Getting Started

1. Use the web standard directly

If you're running Chrome with --enable-experimental-web-platform-features, document.modelContext is already there. Just use it:

Add @mcp-b/webmcp-types (pnpm add -D @mcp-b/webmcp-types) for input schema inference:

ts
await document.modelContext.registerTool({
  name: 'add_todo',
  description: 'Add a new todo item',
  inputSchema: {
    type: 'object',
    properties: { title: { type: 'string' }, done: { type: 'boolean' } },
    required: ['title'],
  } as const, // ← args inferred: { title: string; done?: boolean }
  execute: async (args) => ({ id: Date.now(), title: args.title }),
});

2. Polyfill it

Want it to work in any browser without the Chrome flag? Add the polyfill — same API, same code:

ts
import { initializeWebMCPPolyfill } from '@mcp-b/webmcp-polyfill'; // pnpm add @mcp-b/webmcp-polyfill

initializeWebMCPPolyfill(); // no-op if native support exists

await document.modelContext.registerTool({
  name: 'get_page_title',
  description: 'Returns the current page title',
  inputSchema: { type: 'object', properties: {} },
  execute: async () => ({
    content: [{ type: 'text', text: document.title }],
  }),
});

Or with React: pnpm add usewebmcp

tsx
import { useWebMCP } from 'usewebmcp';

function PageTitle() {
  useWebMCP({
    name: 'get_page_title',
    description: 'Returns the current page title',
    execute: async () => ({ title: document.title }),
  });
  // ...
}

3. Full MCP server

Need the full Model Context Protocol — prompts, resources, transports, and interop with Claude Desktop, Cursor, or another MCP client? Use @mcp-b/global:

ts
import '@mcp-b/global'; // pnpm add @mcp-b/global

// Same registerTool API — now backed by a full MCP server
await document.modelContext.registerTool({
  name: 'add_todo',
  description: 'Add a new todo item',
  inputSchema: {
    type: 'object',
    properties: {
      title: { type: 'string', description: 'Todo title' },
    },
    required: ['title'],
  },
  execute: async (args) => {
    const todo = { id: Date.now(), ...args };
    return { content: [{ type: 'text', text: JSON.stringify(todo) }] };
  },
});

Or as a script tag (zero build step):

html
<script src="https://unpkg.com/@mcp-b/global/dist/index.iife.js"></script>
<script type="module">
  await document.modelContext.registerTool({
    /* ... */
  });
</script>

Or with React: pnpm add @mcp-b/global @mcp-b/react-webmcp

tsx
import '@mcp-b/global';
import { useWebMCP } from '@mcp-b/react-webmcp';

function TodoApp({ todos, addTodo }) {
  useWebMCP({
    name: 'add_todo',
    description: 'Add a new todo item',
    inputSchema: {
      type: 'object',
      properties: {
        title: { type: 'string', description: 'Todo title' },
      },
      required: ['title'],
    } as const,
    execute: async ({ title }) => {
      addTodo(title);
      return { success: true };
    },
  });

  return (
    <ul>
      {todos.map((t) => (
        <li key={t.id}>{t.title}</li>
      ))}
    </ul>
  );
}

Call Those Tools

Three ways for AI agents to discover and call your tools:

┌─────────────────────────────────────────────────────────┐
│  Your website                                           │
│  document.modelContext.registerTool({ ... })             │
└────────┬────────────────────┬───────────────────┬───────┘
         │                    │                   │
    ┌────▼─────┐    ┌────────▼────────┐   ┌─────▼──────┐
    │  MCP-B   │    │  Chrome Native  │   │   Local    │
    │Extension │    │  (experimental) │   │   Relay    │
    └────┬─────┘    └────────┬────────┘   └─────┬──────┘
         │                   │                   │
         ▼                   ▼                   ▼
    AI agent in         Browser's            Claude Desktop
    browser             built-in agent       Cursor, VS Code

MCP-B Extension — Install it from the Chrome Web Store. It discovers tools exposed by pages and connects them to extension-side agent experiences.

Chrome Native — Enable at chrome://flags → Experimental Web Platform features, or:

bash
google-chrome --enable-experimental-web-platform-features

See Chromium flags reference for macOS / Windows / Linux commands.

Local Relay — Add to your MCP client config (Claude Desktop, Cursor, etc.):

json
{
  "mcpServers": {
    "webmcp-local-relay": {
      "command": "npx",
      "args": ["-y", "@mcp-b/webmcp-local-relay@latest"]
    }
  }
}

Any website running @mcp-b/global becomes callable from your desktop AI agent. See the relay README for details.

Which Package?

I want to…Package
Add tools to my site (simplest)@mcp-b/global
Just the polyfill, no MCP bridge@mcp-b/webmcp-polyfill
Register tools from React@mcp-b/react-webmcp
Add WebMCP from an extension@mcp-b/webmcp-extension
Forward tools to local AI agents@mcp-b/webmcp-local-relay
Control Chrome from an AI agentchrome-devtools-mcp
Just the TypeScript types@mcp-b/webmcp-types

Chrome DevTools integration now lives entirely upstream; its WebMCP changes have all landed there.


Installation

bash
# Full runtime: polyfill + MCP bridge (most users start here)
pnpm add @mcp-b/global

# Strict WebMCP core polyfill only (no MCP extensions)
pnpm add @mcp-b/webmcp-polyfill

# TypeScript definitions (dev dependency)
pnpm add -D @mcp-b/webmcp-types

# React hooks for full runtime
pnpm add @mcp-b/react-webmcp

# React hooks for strict WebMCP core only
pnpm add usewebmcp

# Transport layer (custom integrations)
pnpm add @mcp-b/transports

# Chromium extension template and content-script client
pnpm add @mcp-b/global @mcp-b/webmcp-extension

# DOM extraction for AI
pnpm add @mcp-b/smart-dom-reader

All Packages

Core

PackageVersionDescription
@mcp-b/webmcp-polyfillnpmdocument.modelContext polyfill, with a deprecated navigator alias
@mcp-b/webmcp-typesnpmTypeScript definitions for the WebMCP core API
@mcp-b/globalnpmFull runtime — polyfill + MCP bridge (prompts, resources, transport)
@mcp-b/webmcp-ts-sdknpmBrowser-adapted MCP TypeScript SDK with dynamic tool registration

Transports & Composition

PackageVersionDescription
@mcp-b/transportsnpmpostMessage, iframe, and Chrome extension transports
@mcp-b/webmcp-extensionnpmMV3 template and isolated content-script client for page tools
@mcp-b/mcp-iframenpmWeb component for exposing iframe tools, resources, and prompts
@mcp-b/webmcp-local-relaynpmLocalhost relay — forwards website tools to Claude Desktop, Cursor, etc.

React

PackageVersionDescription
@mcp-b/react-webmcpnpmReact hooks for full runtime (register tools + consume MCP servers)
usewebmcpnpmReact hooks for strict WebMCP core only

Browser Tooling

PackageVersionDescription
@mcp-b/smart-dom-readernpmToken-efficient DOM extraction for AI agents
PackageStatusMigration
@mcp-b/mcp-react-hooksDeprecatedUse @mcp-b/react-webmcp instead
@mcp-b/mcp-react-hook-formRemovedUse custom useWebMCP wrappers
@mcp-b/codemodeRemovedUse Cloudflare Code Mode; browser APIs are exported from @cloudflare/codemode/browser

Architecture

┌──────────────────────────────────────────────────────────┐
│  Your web app                                            │
│  document.modelContext.registerTool({ ... })              │
├────────────── @mcp-b/global ─────────────────────────────┤
│  MCP bridge: prompts, resources, browser transports      │
├────────────── @mcp-b/webmcp-ts-sdk ──────────────────────┤
│  BrowserMcpServer — wraps native/polyfill context        │
├────────────── @mcp-b/webmcp-polyfill ────────────────────┤
│  WebMCP core + optional Chrome executeTool extension    │
├──────────────────────────────────────────────────────────┤
│  Native browser API (when available)                     │
└──────────────────────────────────────────────────────────┘
         ▲                              ▲
         │ postMessage / extension      │ WebSocket
         ▼                              ▼
   AI agent in browser            Local AI agent
   (extension, tab)          (Claude Desktop, Cursor)

Dependency Graph

webmcp-types          (canonical type definitions)
└── webmcp-polyfill   (canonical runtime polyfill)
    ├── webmcp-ts-sdk (TypeScript SDK adapter)
    │   ├── global    (full runtime; also uses transports)
    │   ├── mcp-iframe (iframe element; also uses transports)
    │   └── react-webmcp (also uses usewebmcp; pair with global at app level)
    └── usewebmcp     (React hooks for strict core)

transports            (browser transports shared by integrations)
└── webmcp-extension  (MV3 template and isolated content-script client)

Standalone packages: smart-dom-reader, webmcp-local-relay.

Development

bash
git clone https://github.com/WebMCP-org/npm-packages.git
cd npm-packages
pnpm install
pnpm build
CommandWhat it does
pnpm buildBuild all packages
pnpm typecheckType-check all packages
pnpm checkLint + format (Oxlint + Oxfmt)
pnpm test:unitUnit tests
pnpm test:e2eE2E tests (Playwright)
pnpm testAll tests
pnpm --filter <pkg> buildBuild a single package
pnpm --filter <pkg> testTest a single package
pnpm changesetCreate a changeset for versioning

Prerequisites: Node.js >= 22.12 (see .nvmrc), pnpm >= 10

Documentation

DocumentPurpose
CONTRIBUTING.mdHow to contribute: setup, PR process, commit format
AGENTS.mdQuick reference for AI agents working in this repo
Package PhilosophyPackage boundaries and layering model
Testing PhilosophyTest layers, mocking policy, coverage expectations
E2E TestingPlaywright setup, test apps, debugging
@mcp-b/global guideAdvanced usage for the full runtime
AI Contribution ManifestoSafety rules and code quality bar
Relevant LinksCurated external best practices for contributors

Contributing

Contributions welcome — see CONTRIBUTING.md for guidelines.

License

MIT

Links

Installazione

TypingMind
Prerequisiti:

Node.js 18+

{
  "mcpServers": {
    "webmcp-org-npm-packages": {
      "command": "npx",
      "args": [
        "-y",
        "@mcp-b/npm-packages"
      ]
    }
  }
}

Usa MCP @mcp-b con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso @mcp-b, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi @mcp-b come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di @mcp-b.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "webmcp-org-npm-packages": {
      "command": "npx",
      "args": [
        "-y",
        "@mcp-b/npm-packages"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di @mcp-b, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di @mcp-b.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare @mcp-b per aiutarmi con questa attività?
@mcp-b
Certo. Ho letto.
Ecco cosa ho trovato con @mcp-b.

Domande frequenti

A cosa serve il server MCP @mcp-b?

@mcp-b è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare @mcp-b MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare @mcp-b con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP @mcp-b con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando @mcp-b, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego @mcp-b MCP a TypingMind?

@mcp-b funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre @mcp-b MCP in TypingMind?

@mcp-b mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare @mcp-b MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se @mcp-b richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇