@mcp-bのロゴ

@mcp-b

組織
WebMCP-org

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

公開者WebMCP-org
リポジトリnpm-packages
言語TypeScript
フォーク
20
スター
98
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    @mcp-bは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには98件のスターと20件のフォークがあります。

@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

インストール

TypingMind
前提条件:

Node.js 18+

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

@mcp-bのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度@mcp-bに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

@mcp-bをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. @mcp-bのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "webmcp-org-npm-packages": {
      "command": "npx",
      "args": [
        "-y",
        "@mcp-b/npm-packages"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いて@mcp-bのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. @mcp-bのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
@mcp-bを使ってこのタスクを手伝ってもらえますか?
@mcp-b
はい、読みました。
@mcp-bで調べた結果をお伝えします。

よくある質問

@mcp-b MCPサーバーは何に使いますか?

@mcp-bは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindで@mcp-b MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルで@mcp-bを利用できます。

TypingMindで@mcp-b MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。@mcp-bを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

@mcp-b MCPをTypingMindに接続するにはどうすればよいですか?

@mcp-bはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindで@mcp-b MCPのどのようなツールを利用できますか?

@mcp-bはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

@mcp-b MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。@mcp-bで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇