mcp_server.handle route should declare _format: json
## Problem/Motivation
The `mcp_server.handle` route does not declare a `_format` requirement. The controller only ever produces a JSON-RPC response, but the route accepts any request format. Without `_format: json`, Drupal's content negotiation does not pin the response to JSON, and error responses in particular can be rendered as HTML instead of JSON.
This also forces consumers to patch the route themselves. To make the endpoint behave correctly we currently add the requirement through a `RouteSubscriber`:
```php
protected function alterRoutes(RouteCollection $collection): void {
$route = $collection->get('mcp_server.handle');
if ($route === NULL) {
return;
}
$route->setRequirement('_format', 'json');
}
```
Since the route is JSON-only by design, this requirement belongs in the module itself rather than in every downstream consumer.
## Proposed resolution
Add `_format: json` to the `mcp_server.handle` route in `mcp_server.routing.yml`:
```yaml
mcp_server.handle:
path: '/_mcp'
defaults:
_controller: '\Drupal\mcp_server\Controller\McpServerController::handle'
_title: 'MCP Server'
requirements:
_permission: 'access mcp server'
_format: 'json'
methods: [GET, POST, DELETE, OPTIONS]
options:
_auth: ['cookie']
no_cache: TRUE
```
## Remaining tasks
- Add the `_format: json` requirement to the route.
- Confirm content negotiation and error responses stay JSON.
issue