Skip to content

Commit 59dc7a7

Browse files
klapaudiusgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 6eeba0a commit 59dc7a7

File tree

47 files changed

+305
-262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+305
-262
lines changed

src/Command/TestMcpToolCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(private readonly ContainerInterface $container)
3030
public function displayResult(mixed $result, array $sentNotifications = [], ?StreamableToolInterface $tool = null): void
3131
{
3232
// Display progress notifications if any were sent
33-
if (!empty($sentNotifications)) {
33+
if (! empty($sentNotifications)) {
3434
$this->io->newLine();
3535
$this->io->section('Progress Notifications');
3636
$this->io->text(sprintf('Total notifications sent: %d', count($sentNotifications)));

src/Controllers/SseController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function __construct(private MCPServerInterface $server) {}
1313
public function handle(): StreamedResponse
1414
{
1515
$this->server->setProtocolVersion(MCPProtocolInterface::PROTOCOL_VERSION_SSE);
16+
1617
return new StreamedResponse(fn () => $this->server->connect(), headers: [
1718
'Content-Type' => 'text/event-stream',
1819
'Cache-Control' => 'no-cache, private',

src/Controllers/StreamableHttpController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function gethandle(): JsonResponse
3131
return new JsonResponse(
3232
[
3333
'jsonrpc' => 2.0,
34-
'error' => 'This endpoint does not support GET requests yet.'
34+
'error' => 'This endpoint does not support GET requests yet.',
3535
],
3636
Response::HTTP_METHOD_NOT_ALLOWED);
3737
}
@@ -48,7 +48,7 @@ public function postHandle(Request $request): StreamedResponse|JsonResponse
4848
$input = json_decode($request->getContent(), true, flags: JSON_THROW_ON_ERROR);
4949
$this->logger?->debug('Received message from clientId:'.$clientId, ['message' => $input]);
5050

51-
$willStream = !isset($input['jsonrpc']) && isset($input[0]['jsonrpc']);
51+
$willStream = ! isset($input['jsonrpc']) && isset($input[0]['jsonrpc']);
5252
$messages = $willStream ? $input : [$input];
5353

5454
return new StreamedResponse(function () use ($clientId, $messages) {
@@ -62,6 +62,7 @@ public function postHandle(Request $request): StreamedResponse|JsonResponse
6262
]);
6363
} catch (JsonException|StreamableHttpTransportException $e) {
6464
$message = $e instanceof JsonException ? 'Parse error' : $e->getMessage();
65+
6566
return new JsonResponse(['jsonrpc' => 2.0, 'error' => ['code' => -32700, 'message' => $message]], 400);
6667
}
6768
}

src/DependencyInjection/CompilerPass/ConditionalRoutePass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
88
use Symfony\Component\DependencyInjection\ContainerBuilder;
9-
use Symfony\Component\Routing\RouteCollection;
109

1110
/**
1211
* Compiler pass to conditionally register routes based on enabled server providers
@@ -15,7 +14,7 @@ class ConditionalRoutePass implements CompilerPassInterface
1514
{
1615
public function process(ContainerBuilder $container): void
1716
{
18-
if (!$container->hasParameter('klp_mcp_server.providers')) {
17+
if (! $container->hasParameter('klp_mcp_server.providers')) {
1918
return;
2019
}
2120

src/DependencyInjection/KlpMcpServerExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function load(array $configs, ContainerBuilder $container): void
2727
}
2828
if (isset($config['server_provider'])
2929
&& $config['server_provider'] === 'sse'
30-
&& !count($providers)) {
30+
&& ! count($providers)) {
3131
$providers[] = 'klp_mcp_server.provider.sse';
3232
}
3333
$container->setParameter('klp_mcp_server.providers', $providers);
@@ -51,15 +51,15 @@ public function load(array $configs, ContainerBuilder $container): void
5151
private function removeDisabledControllers(ContainerBuilder $container, array $enabledProviders): void
5252
{
5353
// Remove SSE controllers if SSE provider is not enabled
54-
if (!in_array('klp_mcp_server.provider.sse', $enabledProviders, true)) {
54+
if (! in_array('klp_mcp_server.provider.sse', $enabledProviders, true)) {
5555
$container->removeDefinition('KLP\KlpMcpServer\Controllers\SseController');
5656
$container->removeAlias('klp_mcp_server.controller.sse');
5757
$container->removeDefinition('KLP\KlpMcpServer\Controllers\MessageController');
5858
$container->removeAlias('klp_mcp_server.controller.message');
5959
}
6060

6161
// Remove StreamableHTTP controller if StreamableHTTP provider is not enabled
62-
if (!in_array('klp_mcp_server.provider.streamable_http', $enabledProviders, true)) {
62+
if (! in_array('klp_mcp_server.provider.streamable_http', $enabledProviders, true)) {
6363
$container->removeDefinition('KLP\KlpMcpServer\Controllers\StreamableHttpController');
6464
$container->removeAlias('klp_mcp_server.controller.streamable_http');
6565
}

src/KlpMcpServerBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace KLP\KlpMcpServer;
44

5+
use KLP\KlpMcpServer\DependencyInjection\CompilerPass\ConditionalRoutePass;
56
use KLP\KlpMcpServer\DependencyInjection\CompilerPass\ResourcesDefinitionCompilerPass;
67
use KLP\KlpMcpServer\DependencyInjection\CompilerPass\ToolsDefinitionCompilerPass;
7-
use KLP\KlpMcpServer\DependencyInjection\CompilerPass\ConditionalRoutePass;
88
use Symfony\Component\DependencyInjection\ContainerBuilder;
99
use Symfony\Component\HttpKernel\Bundle\Bundle;
1010

src/Protocol/MCPProtocol.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* MCPProtocol
2626
*
2727
* @internal
28+
*
2829
* @see https://modelcontextprotocol.io/docs/concepts/architecture
2930
*/
3031
final class MCPProtocol implements MCPProtocolInterface
@@ -45,9 +46,7 @@ final class MCPProtocol implements MCPProtocolInterface
4546
* @param TransportFactoryInterface $transportFactory The transport factory to use for creating transports.
4647
* @return void
4748
*/
48-
public function __construct(private readonly TransportFactoryInterface $transportFactory)
49-
{
50-
}
49+
public function __construct(private readonly TransportFactoryInterface $transportFactory) {}
5150

5251
/**
5352
* Establishes a connection and processes incoming messages from the transport layer.
@@ -259,6 +258,7 @@ public function getResponseResult(string $clientId): array
259258
$result[] = json_decode($message);
260259
}
261260
}
261+
262262
return $result;
263263
}
264264

src/Protocol/MCPProtocolInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
* MCPProtocol
1111
*
1212
* @internal
13+
*
1314
* @see https://modelcontextprotocol.io/docs/concepts/architecture
1415
*/
1516
interface MCPProtocolInterface
1617
{
1718
public const PROTOCOL_VERSION_SSE = '2024-11-05';
19+
1820
public const PROTOCOL_VERSION_STREAMABE_HTTP = '2025-03-26';
1921

2022
public function setProtocolVersion(string $version): void;

src/Routing/Loader/McpRouteLoader.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
class McpRouteLoader implements LoaderInterface
1616
{
1717
private array $enabledProviders = [];
18+
1819
private string $defaultPath = 'mcp';
20+
1921
private bool $loaded = false;
2022

2123
public function setEnabledProviders(array $providers): void
@@ -28,31 +30,31 @@ public function setDefaultPath(string $defaultPath): void
2830
$this->defaultPath = $defaultPath;
2931
}
3032

31-
public function load($resource, string|null $type = null): RouteCollection
33+
public function load($resource, ?string $type = null): RouteCollection
3234
{
3335
if ($this->loaded) {
3436
throw new \RuntimeException('MCP routes already loaded');
3537
}
3638

37-
$routes = new RouteCollection();
39+
$routes = new RouteCollection;
3840

3941
// StreamableHTTP routes
4042
if ($this->isProviderEnabled('streamable_http')) {
4143
$routes->add('klp_mcp_server_streamable_http', new Route(
42-
'/' . $this->defaultPath,
44+
'/'.$this->defaultPath,
4345
['_controller' => 'klp_mcp_server.controller.streamable_http::handle']
4446
));
4547
}
4648

4749
// SSE routes
4850
if ($this->isProviderEnabled('sse')) {
4951
$routes->add('klp_mcp_server_sse', new Route(
50-
'/' . $this->defaultPath . '/sse',
52+
'/'.$this->defaultPath.'/sse',
5153
['_controller' => 'klp_mcp_server.controller.sse::handle']
5254
));
5355

5456
$routes->add('klp_mcp_server_sse_message', new Route(
55-
'/' . $this->defaultPath . '/messages',
57+
'/'.$this->defaultPath.'/messages',
5658
['_controller' => 'klp_mcp_server.controller.message::handle'],
5759
[],
5860
[],
@@ -63,19 +65,21 @@ public function load($resource, string|null $type = null): RouteCollection
6365
}
6466

6567
$this->loaded = true;
68+
6669
return $routes;
6770
}
6871

69-
public function supports($resource, string|null $type = null): bool
72+
public function supports($resource, ?string $type = null): bool
7073
{
71-
return 'mcp' === $type;
74+
return $type === 'mcp';
7275
}
7376

7477
public function getResolver(): LoaderResolverInterface
7578
{
7679
// Return a dummy resolver as it's required by the interface
77-
return new class implements LoaderResolverInterface {
78-
public function resolve($resource, string|null $type = null): LoaderInterface|false
80+
return new class implements LoaderResolverInterface
81+
{
82+
public function resolve($resource, ?string $type = null): LoaderInterface|false
7983
{
8084
return false;
8185
}
@@ -99,6 +103,6 @@ public function setResolver(LoaderResolverInterface $resolver): void
99103

100104
private function isProviderEnabled(string $provider): bool
101105
{
102-
return in_array('klp_mcp_server.provider.' . $provider, $this->enabledProviders, true);
106+
return in_array('klp_mcp_server.provider.'.$provider, $this->enabledProviders, true);
103107
}
104108
}

src/Server/MCPServer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public static function create(
110110
): self {
111111
return new self($protocol,
112112
$progressNotifierRepository, [
113-
'name' => $name,
114-
'version' => $version,
115-
], $capabilities);
113+
'name' => $name,
114+
'version' => $version,
115+
], $capabilities);
116116
}
117117

118118
/**

0 commit comments

Comments
 (0)