Frontendmcp
БесплатноНе проверенA lightweight WebSocket relay and transport layer to run Model Context Protocol (MCP) servers in the browser and expose them to backend LLMs.
Описание
A lightweight WebSocket relay and transport layer to run Model Context Protocol (MCP) servers in the browser and expose them to backend LLMs.
README
Overview
The Model Context Protocol (MCP) allows applications to provide context and tools to LLMs in a standardized way. FrontendMCP extends this model to browser environments.
This FrontendMCP provides a lightweight relay and transport layer that allows MCP servers to run in client-side applications while remaining accessible to backend LLMs and other MCP clients.
This is particularly useful when the capabilities you want to expose only exist in the client: local state, browser-only APIs, UI logic or frontend code that makes authenticated backend requests on behalf of the current user.
A prehosted relay server is available, so you can get started with FrontendMCP in just a few lines of code. Server implementations in Rust and TypeScript are also provided for those who want to self-host or customize their relay server.
Installation
npm install frontendmcp zod
Usage
import { FrontendMCPServer } from 'frontendmcp';
import { z } from 'zod';
const mcp = new FrontendMCPServer({
name: 'ClientTools',
version: '1.0',
frontendMCP: {
// Optional structured WebSocket lifecycle and JSON-RPC frame tracing.
// Authentication tokens are never included in trace events.
trace: true
}
});
mcp.registerTool(
'get_selection',
{
description: 'Read highlighted text',
inputSchema: z.object({})
},
async () => ({
content: [
{
type: 'text',
text: window.getSelection()?.toString() || ''
}
]
})
);
mcp.connect();
// Pass the server's URL to your backend LLM or MCP client to start using the tool
const url = mcp.url;
connect() resolves only after the relay WebSocket is open and its
authentication packet has been sent. Startup failures reject the returned
promise, so applications should await it:
try {
await mcp.connect();
console.log('FrontendMCP is connected');
} catch (error) {
console.error('FrontendMCP startup failed', error);
}
Debug diagnostics
The FrontendMCP browser library is quiet by default. Enable WebSocket lifecycle
and JSON-RPC frame diagnostics with the opt-in frontendMCP.trace setting shown
above. Use trace: true to write structured events through console.debug, or
pass a callback to route them to your own development logger.
Trace events include the actual parsed JSON-RPC messages. Authorization values
and fields whose names indicate tokens, passwords, cookies, secrets, or API
keys are replaced with [REDACTED] before the event reaches either logger.
Compliance trace
The repository includes a black-box test client built on the official MCP SDK. It records the exact JSON-RPC initialization, tool discovery, and tool-call messages in both directions. Authorization values and secret-shaped fields are redacted.
MCP_URL='https://relay.example/mcp/session-id' \
MCP_AUTHORIZATION='Bearer your-token' \
pnpm test:mcp-compliance -- --trace-file /tmp/frontendmcp-trace.jsonl
For FunctionBridge servers, the runner verifies server instructions, the
search_functions and execute_javascript_code contracts, every discovery
detail level, structured and empty search results, and a harmless execution
containing return 42;. Pass --skip-call to limit the check to initialization
and tools/list metadata.
Check out the examples directory for more complete implementations and use cases.
Architecture
Standard MCP clients typically communicate over Streaming HTTP or STDIO. FrontendMCP uses a relay server to bridge the gap between HTTP-based MCP clients and WebSocket-based communication with the frontend.
- The relay server listens for incoming HTTP requests from an MCP client.
- The frontend establishes a persistent WebSocket connection to the relay server using a unique UUID.
- When the relay server receives an HTTP request for a specific UUID, it forwards the JSON-RPC message over the WebSocket.
- The frontend MCP server processes the request and sends the response back through the WebSocket.
- The relay server completes the HTTP request with the frontend's response.
The full protocol is detailed in PROTOCOL.md and the reference implementations are available in the server directory.
Use Cases
- Local state access without syncing data to a backend first
- UI interactions such as reading highlighted text, clicking buttons, or filling out forms
- Exposing frontend functions that call authenticated backend endpoints using the current user's browser session
- Reducing backend implementation work when generic computation or logic can be handled in the frontend
- Client-side code execution via FunctionBridge
Roadmap
- Additional examples and documentation
- WebRTC based MCPClient for peer-to-peer connections
- Community feedback and contributions to guide future development
Contributing
Issues and pull requests are welcome on GitHub.
Установка Frontendmcp
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/failip/frontendmcpFAQ
Frontendmcp MCP бесплатный?
Да, Frontendmcp MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Frontendmcp?
Нет, Frontendmcp работает без API-ключей и переменных окружения.
Frontendmcp — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Frontendmcp в Claude Desktop, Claude Code или Cursor?
Открой Frontendmcp на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
Playwright
Browser automation, scraping, screenshots
автор: MicrosoftPuppeteer
Browser automation and web scraping.
автор: modelcontextprotocolGarmin Connect
An MCP server for Garmin Connect that provides access to fitness activities, health statistics, and sleep data by routing requests through a headless browser to
автор: etweisbergHiggsfield Unlimited
MCP server for Higgsfield AI that enables unlimited-mode image, video, audio generation, uploads, and job management via multiple parallel accounts, using brows
автор: nukIeeropentabs-dev/opentabs
Plugin-based MCP server + Chrome extension that gives AI agents access to web applications through the user's authenticated browser session. 100+ plugins with a
автор: opentabs-devrobhunter/agentdeals
1,500+ developer infrastructure deals, free tiers, and startup programs across 54 categories. Search deals, compare vendors, plan stacks, and track pricing chan
автор: robhunterhlydecker/ucsc-genome-mcp
MCP server to interact with the UCSC Genome Browser API, letting you find genomes, chromosomes, and more.
автор: hlydecker34892002/bilibili-mcp-js
A MCP server that supports searching for Bilibili content. Provides LangChain integration examples and test scripts.
автор: 34892002achiya-automation/safari-mcp
Native Safari browser automation for AI agents with 80+ tools. No Chrome dependency, optimized for Apple Silicon with 60% less CPU overhead.
автор: achiya-automationagent-infra/mcp-server-browser
Browser automation capabilities using Puppeteer, both support local and remote browser connection.
автор: bytedanceCompare Frontendmcp with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории browse
