Skip to content

Commit 5f17049

Browse files
klapaudiusgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 75c9066 commit 5f17049

File tree

13 files changed

+100
-114
lines changed

13 files changed

+100
-114
lines changed

src/Console/Commands/MakeMcpToolCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public function handle()
7272
if ($this->confirm('Would you like to automatically register this tool in config/package/klp-mcp-server.yaml?', true)) {
7373
$this->registerToolInConfig($fullClassName);
7474
} else {
75-
$this->info("Don't forget to register your tool in config/package/klp-mcp-server.yaml:");;
75+
$this->info("Don't forget to register your tool in config/package/klp-mcp-server.yaml:");
7676
$this->comment(' // config/package/klp-mcp-server.yaml');
77-
$this->comment(" tools;");
77+
$this->comment(' tools;');
7878
$this->comment(' // other tools...');
7979
$this->comment(" {$fullClassName}::class,");
8080
}

src/Controllers/MessageController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
namespace KLP\KlpMcpServer\Controllers;
44

55
use KLP\KlpMcpServer\Server\MCPServer;
6-
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
76
use Symfony\Component\HttpFoundation\JsonResponse;
87
use Symfony\Component\HttpFoundation\Request;
98

109
class MessageController
1110
{
12-
public function __construct(private readonly MCPServer $server)
13-
{
14-
}
11+
public function __construct(private readonly MCPServer $server) {}
1512

1613
public function handle(Request $request)
1714
{

src/Controllers/SseController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
class SseController
1010
{
11-
public function __construct(private readonly MCPServerInterface $server)
12-
{
13-
}
11+
public function __construct(private readonly MCPServerInterface $server) {}
1412

1513
public function handle(Request $request)
1614
{

src/DependencyInjection/Configuration.php

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class Configuration implements ConfigurationInterface
99
{
10-
1110
public function getConfigTreeBuilder(): TreeBuilder
1211
{
1312
$treeBuilder = new TreeBuilder('klp_mcp_server');
@@ -21,95 +20,95 @@ public function getConfigTreeBuilder(): TreeBuilder
2120
->addDefaultsIfNotSet()
2221
->children()
2322
// MCP Server Activation
24-
->booleanNode('enabled')
25-
->defaultTrue()
26-
->end()
23+
->booleanNode('enabled')
24+
->defaultTrue()
25+
->end()
2726

2827
// Server Information
29-
->arrayNode('server')
30-
->children()
31-
->scalarNode('name')
32-
->defaultValue('KLP MCP Server')
33-
->cannotBeEmpty()
34-
->end()
35-
->scalarNode('version')
36-
->defaultValue('0.1.0')
37-
->cannotBeEmpty()
38-
->end()
39-
->end()
40-
->end()
28+
->arrayNode('server')
29+
->children()
30+
->scalarNode('name')
31+
->defaultValue('KLP MCP Server')
32+
->cannotBeEmpty()
33+
->end()
34+
->scalarNode('version')
35+
->defaultValue('0.1.0')
36+
->cannotBeEmpty()
37+
->end()
38+
->end()
39+
->end()
4140

4241
// MCP Default Path
43-
->scalarNode('default_path')
44-
->defaultValue('mcp')
45-
->cannotBeEmpty()
46-
->end()
42+
->scalarNode('default_path')
43+
->defaultValue('mcp')
44+
->cannotBeEmpty()
45+
->end()
4746

4847
// Middleware Configuration
49-
->arrayNode('middlewares')
50-
->prototype('scalar')
51-
->end()
52-
->end()
48+
->arrayNode('middlewares')
49+
->prototype('scalar')
50+
->end()
51+
->end()
5352

5453
// Server Provider
55-
->scalarNode('server_provider')
56-
->defaultValue('sse')
57-
->cannotBeEmpty()
58-
->validate()
59-
->ifNotInArray(['sse'])
60-
->thenInvalid('The server provider "%s" is not supported. Currently only "sse" is supported.')
61-
->end()
62-
->end()
54+
->scalarNode('server_provider')
55+
->defaultValue('sse')
56+
->cannotBeEmpty()
57+
->validate()
58+
->ifNotInArray(['sse'])
59+
->thenInvalid('The server provider "%s" is not supported. Currently only "sse" is supported.')
60+
->end()
61+
->end()
6362

6463
// SSE Adapter
65-
->scalarNode('sse_adapter')
66-
->defaultValue('redis')
67-
->cannotBeEmpty()
64+
->scalarNode('sse_adapter')
65+
->defaultValue('redis')
66+
->cannotBeEmpty()
6867
// ->validate()
6968
// ->ifNotInArray($supportedAdaptersServices)
7069
// ->thenInvalid('The sse adapter "%s" is not supported. Please choose one of '.implode(', ', $supportedAdaptersServices))
7170
// ->end()
72-
->end()
71+
->end()
7372

7473
// Adapters for SSE
75-
->arrayNode('adapters')
76-
->useAttributeAsKey('name') // Allows keys like "in_memory" and "redis"
77-
->arrayPrototype()
78-
->children()
79-
->scalarNode('prefix')
80-
->defaultValue('mcp_sse_')
81-
->end()
82-
->scalarNode('connection')
83-
->defaultValue('default')
84-
->end()
85-
->integerNode('ttl')
86-
->defaultValue(100)
87-
->end()
88-
->end()
89-
->end()
90-
->end()
74+
->arrayNode('adapters')
75+
->useAttributeAsKey('name') // Allows keys like "in_memory" and "redis"
76+
->arrayPrototype()
77+
->children()
78+
->scalarNode('prefix')
79+
->defaultValue('mcp_sse_')
80+
->end()
81+
->scalarNode('connection')
82+
->defaultValue('default')
83+
->end()
84+
->integerNode('ttl')
85+
->defaultValue(100)
86+
->end()
87+
->end()
88+
->end()
89+
->end()
9190

9291
// Tools List
93-
->arrayNode('tools')
94-
->prototype('scalar')
95-
->validate()
96-
->ifTrue(static fn ($v) => !class_exists($v))
97-
->thenInvalid('The tool "%s" must be a valid fully qualified class name.')
98-
->end()
99-
->end()
100-
->end()
92+
->arrayNode('tools')
93+
->prototype('scalar')
94+
->validate()
95+
->ifTrue(static fn ($v) => ! class_exists($v))
96+
->thenInvalid('The tool "%s" must be a valid fully qualified class name.')
97+
->end()
98+
->end()
99+
->end()
101100

102101
// Prompts
103-
->arrayNode('prompts')
104-
->prototype('scalar')
105-
->end()
106-
->end()
102+
->arrayNode('prompts')
103+
->prototype('scalar')
104+
->end()
105+
->end()
107106

108107
// Resources
109-
->arrayNode('resources')
110-
->prototype('scalar')
111-
->end()
112-
->end()
108+
->arrayNode('resources')
109+
->prototype('scalar')
110+
->end()
111+
->end()
113112
->end();
114113

115114
return $treeBuilder;

src/DependencyInjection/KlpMcpServerExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class KlpMcpServerExtension extends Extension
1111
{
1212
public function load(array $configs, ContainerBuilder $container): void
1313
{
14-
$config = $this->processConfiguration(new Configuration(), $configs);
15-
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config'));
14+
$config = $this->processConfiguration(new Configuration, $configs);
15+
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
1616
$loader->load('services.xml');
1717

18-
$container->setParameter('klp_mcp_server.enabled', $config['enabled']);;
18+
$container->setParameter('klp_mcp_server.enabled', $config['enabled']);
1919
$container->setParameter('klp_mcp_server.default_path', $config['default_path']);
2020
$container->setParameter('klp_mcp_server.server.name', $config['server']['name']);
2121
$container->setParameter('klp_mcp_server.server.version', $config['server']['version']);
22-
$container->setParameter('klp_mcp_server.adapter', 'klp_mcp_server.adapter.' . $config['sse_adapter']);
22+
$container->setParameter('klp_mcp_server.adapter', 'klp_mcp_server.adapter.'.$config['sse_adapter']);
2323
}
2424
}

src/KlpMcpServerBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public function boot(): void
1414
{
1515
parent::boot();
1616
$configPath = $this->container->getParameter('kernel.project_dir').'/config/packages/klp_mcp_server.yaml';
17-
$filesystem = new Filesystem();
17+
$filesystem = new Filesystem;
1818

1919
// Check if the file already exists
20-
if (!$filesystem->exists($configPath)) {
20+
if (! $filesystem->exists($configPath)) {
2121
$defaultConfig = __DIR__.'/Resources/config/packages/klp_mcp_server.yaml';
2222
$filesystem->copy($defaultConfig, $configPath);
2323
}

src/Protocol/MCPProtocolInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace KLP\KlpMcpServer\Protocol;
44

5-
65
use Exception;
76
use KLP\KlpMcpServer\Protocol\Handlers\NotificationHandler;
87
use KLP\KlpMcpServer\Protocol\Handlers\RequestHandler;

src/Server/MCPServerInterface.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace KLP\KlpMcpServer\Server;
44

5-
65
use KLP\KlpMcpServer\Data\Requests\InitializeData;
76
use KLP\KlpMcpServer\Data\Resources\InitializeResource;
87
use KLP\KlpMcpServer\Exceptions\JsonRpcErrorException;
@@ -26,16 +25,15 @@ interface MCPServerInterface
2625
* Registers a request handler with the protocol layer.
2726
* Request handlers process incoming method calls from the client.
2827
*
29-
* @param RequestHandler $handler The request handler instance to register.
28+
* @param RequestHandler $handler The request handler instance to register.
3029
*/
3130
public function registerRequestHandler(RequestHandler $handler): void;
3231

3332
/**
3433
* Registers the necessary request handlers for MCP Tools functionality.
3534
* This typically includes handlers for 'tools/list' and 'tools/call'.
3635
*
37-
* @param ToolRepository $toolRepository The repository containing available tools.
38-
* @return \KLP\KlpMcpServer\Server\MCPServer
36+
* @param ToolRepository $toolRepository The repository containing available tools.
3937
*/
4038
public function registerToolRepository(ToolRepository $toolRepository): \KLP\KlpMcpServer\Server\MCPServer;
4139

@@ -54,7 +52,7 @@ public function disconnect(): void;
5452
* Registers a notification handler with the protocol layer.
5553
* Notification handlers process incoming notifications from the client (requests without an ID).
5654
*
57-
* @param NotificationHandler $handler The notification handler instance to register.
55+
* @param NotificationHandler $handler The notification handler instance to register.
5856
*/
5957
public function registerNotificationHandler(NotificationHandler $handler): void;
6058

@@ -63,7 +61,7 @@ public function registerNotificationHandler(NotificationHandler $handler): void;
6361
* Stores client capabilities, checks protocol version, and marks the server as initialized.
6462
* Throws an error if the server is already initialized.
6563
*
66-
* @param InitializeData $data The data object containing initialization parameters from the client.
64+
* @param InitializeData $data The data object containing initialization parameters from the client.
6765
* @return InitializeResource A resource object containing the server's initialization response.
6866
*
6967
* @throws JsonRpcErrorException If the server has already been initialized (JSON-RPC error code -32600).
@@ -74,8 +72,8 @@ public function initialize(InitializeData $data): InitializeResource;
7472
* Forwards a request message to a specific client via the protocol handler.
7573
* Used for server-initiated requests to the client (if supported by the protocol/transport).
7674
*
77-
* @param string $clientId The identifier of the target client.
78-
* @param array<string, mixed> $message The request message payload (following JSON-RPC structure).
75+
* @param string $clientId The identifier of the target client.
76+
* @param array<string, mixed> $message The request message payload (following JSON-RPC structure).
7977
*/
8078
public function requestMessage(string $clientId, array $message): void;
8179
}

src/Server/ServerCapabilitiesInterface.php

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

33
namespace KLP\KlpMcpServer\Server;
44

5-
65
/**
76
* Represents the server's capabilities according to the MCP specification.
87
* This class defines what features the MCP server supports, such as tools.
@@ -15,9 +14,8 @@ interface ServerCapabilitiesInterface
1514
* Enables the tools capability for the server instance.
1615
* Allows specifying optional configuration details for the tools feature.
1716
*
18-
* @param array|null $config Optional configuration data specific to the tools capability.
17+
* @param array|null $config Optional configuration data specific to the tools capability.
1918
* Defaults to an empty array if not provided.
20-
* @return \KLP\KlpMcpServer\Server\ServerCapabilities
2119
*
2220
* @see https://modelcontextprotocol.io/docs/concepts/tools
2321
*/

src/Transports/SseAdapters/RedisAdapter.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ final class RedisAdapter implements SseAdapterInterface
3333

3434
public function __construct(
3535
private readonly ?LoggerInterface $logger
36-
)
37-
{
38-
}
36+
) {}
3937

4038
/**
4139
* Initialize the adapter with any required configuration
@@ -48,8 +46,8 @@ public function initialize(array $config): void
4846
{
4947
try {
5048
$connection = $config['connection'] ?? 'default';
51-
$this->redis = new Redis();
52-
$this->redis->connect( 'localhost', 6379 );
49+
$this->redis = new Redis;
50+
$this->redis->connect('localhost', 6379);
5351

5452
if (isset($config['prefix'])) {
5553
$this->keyPrefix = $config['prefix'];

0 commit comments

Comments
 (0)