1515class 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}
0 commit comments