Download the PHP package yoanbernabeu/webmcp-bundle without Composer
On this page you can find all versions of the php package yoanbernabeu/webmcp-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yoanbernabeu/webmcp-bundle
More information about yoanbernabeu/webmcp-bundle
Files in yoanbernabeu/webmcp-bundle
Package webmcp-bundle
Short Description Expose Symfony routes as Web MCP tools via PHP attributes
License MIT
Informations about the package webmcp-bundle
WebMcpBundle
Experimental — Web MCP is a draft specification currently being developed by the W3C Web Machine Learning Community Group. The protocol, the browser APIs, and this bundle's API may change at any time. See the Chrome for Developers blog post for more context.
A Symfony bundle that exposes your controller routes as Web MCP tools using simple PHP attributes. No JavaScript to write.
That's it. The browser AI can now call your API.
What is Web MCP?
Web MCP (Web Model Context Protocol) is an emerging standard, currently in draft at the W3C (Web Machine Learning Community Group), that provides a browser-level API allowing web pages to expose structured tools to AI.
It builds on top of the Model Context Protocol (MCP) created by Anthropic, but targets the browser: instead of server-side integrations, the page itself registers tools via navigator.modelContext.registerTool().
AI browser extensions (like Claude, ChatGPT, etc.) can then:
- Discover available tools, their names, descriptions, and input schemas
- Call them with structured parameters
- Read the JSON response and use it in the conversation
This turns any web page into an AI-capable endpoint. Instead of the user copy-pasting data between your app and an AI extension, the extension talks directly to your backend.
Example use case: A user browsing your app asks the Claude browser extension "What Italian restaurants are nearby?". The extension sees a search_restaurants tool is available on the page, calls it with {"cuisine": "italian"}, and returns the results in natural language.
You can test and inspect your Web MCP tools with the Model Context Tool Inspector Chrome extension.
Learn more:
Installation
The bundle registers itself automatically via Symfony Flex. The assets:install command copies the bundle's JavaScript runtime to public/bundles/webmcp/.
Usage
Annotate your controllers
Each controller method you want to expose as an MCP tool gets two attributes: #[Route] (with an explicit name:, required) and #[AsWebMcpTool].
Simple GET endpoint
GET with query parameters
Inputs without mapTo are sent as query string parameters for GET requests.
GET with path parameter
mapTo: 'id' maps the input restaurant_id to the route parameter {id}.
POST with JSON body
For non-GET methods, inputs (except path params) are sent as a JSON body with Content-Type: application/json.
Render the JavaScript
Add the Twig function to your template, typically before </body>:
This outputs a <script> tag that registers all tools via navigator.modelContext. If the browser does not support Web MCP, the script does nothing.
Attribute reference
#[AsWebMcpTool]
Placed on a controller method. The method must also have a #[Route] with an explicit name:.
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Unique tool name (duplicates throw at compile time) |
description |
string |
Yes | Tool description visible to the AI |
inputs |
WebMcpInput[] |
No | Input parameters |
WebMcpInput
Value object describing a tool input parameter.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name |
string |
Yes | Parameter name | |
type |
string |
No | 'string' |
JSON Schema type (string, number, boolean, array) |
description |
string |
No | '' |
Parameter description visible to the AI |
required |
bool |
No | false |
Whether the parameter is required |
mapTo |
?string |
No | null |
Route parameter name if different from input name (mapTo: 'id' for {id}) |
Security
The bundle does not handle security. Your existing Symfony security applies as-is:
- Firewalls — the generated
fetch()calls carry the browser's session cookies #[IsGranted]— works normally, the AI will receive a 403 error- Voters — same, the controller is called through a standard HTTP request
Rules
- Each
#[Route]paired with#[AsWebMcpTool]must have an explicitname:(otherwise:LogicExceptionat compile time) - Tool names must be unique across the application (otherwise:
LogicExceptionindicating both locations) - Controllers should return JSON (the generated JS calls
response.json())
Requirements
- PHP >= 8.2
- Symfony 6.4 / 7.x / 8.x
- Twig 3.x / 4.x
- A browser supporting the Web MCP API (
navigator.modelContext)
Contributing
License
MIT
All versions of webmcp-bundle with dependencies
symfony/http-kernel Version ^6.4|^7.0|^8.0
symfony/dependency-injection Version ^6.4|^7.0|^8.0
symfony/config Version ^6.4|^7.0|^8.0
symfony/routing Version ^6.4|^7.0|^8.0
twig/twig Version ^3.0|^4.0