Skip to content

Commit 2880173

Browse files
committed
feat(server): add dynamics flag to handle method for conditional server creation
1 parent 3749303 commit 2880173

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Server/Framework/Hyperf/HyperfMcpServer.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ public function __construct(ContainerInterface $container)
3636
$this->sessionManager = $container->get(SessionManagerInterface::class);
3737
}
3838

39-
public function handle(string $server, string $version = '1.0.0'): ResponseInterface
39+
public function handle(string $server, string $version = '1.0.0', bool $dynamics = false): ResponseInterface
4040
{
41-
$mcpServer = $this->servers[$server][$version] ?? null;
42-
if (! $mcpServer instanceof McpServer) {
41+
if ($dynamics) {
4342
$mcpServer = $this->createMcpServer($server, $version);
44-
$this->servers[$server][$version] = $mcpServer;
43+
} else {
44+
$mcpServer = $this->servers[$server][$version] ?? null;
45+
if (! $mcpServer instanceof McpServer) {
46+
$mcpServer = $this->createMcpServer($server, $version);
47+
$this->servers[$server][$version] = $mcpServer;
48+
}
4549
}
50+
4651
$request = $this->container->get(RequestInterface::class);
4752
return $mcpServer->http($request, $this->sessionManager, $this->authenticator);
4853
}

0 commit comments

Comments
 (0)