| 1 |
<?php |
| 2 |
declare( strict_types=1 ); |
| 3 |
|
| 4 |
namespace WPMedia\MCP\OAuth\Transport; |
| 5 |
|
| 6 |
use WP\MCP\Core\McpAdapter; |
| 7 |
use WP\MCP\Infrastructure\ErrorHandling\ErrorLogMcpErrorHandler; |
| 8 |
|
| 9 |
class Server { |
| 10 |
/** |
| 11 |
* Register the MCP server with the adapter. |
| 12 |
* |
| 13 |
* Creates an isolated server at /wp-json/mcp/mcp-oauth-server using the custom |
| 14 |
* OAuthHttpTransport for JWT Bearer authentication. |
| 15 |
* |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
public function register_server(): void { |
| 19 |
if ( ! class_exists( McpAdapter::class ) ) { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
$adapter = McpAdapter::instance(); |
| 24 |
|
| 25 |
$adapter->create_server( |
| 26 |
'mcp-oauth-server', |
| 27 |
'mcp', |
| 28 |
'mcp-oauth-server', |
| 29 |
'MCP OAuth Server', |
| 30 |
'MCP Server with OAuth 2.1 authentication', |
| 31 |
'v1.0.0', |
| 32 |
[ OAuthHttpTransport::class ], |
| 33 |
ErrorLogMcpErrorHandler::class, |
| 34 |
McpObservabilityHandler::class, |
| 35 |
[ |
| 36 |
'mcp-adapter/discover-abilities', |
| 37 |
'mcp-adapter/get-ability-info', |
| 38 |
'mcp-adapter/execute-ability', |
| 39 |
] |
| 40 |
); |
| 41 |
} |
| 42 |
} |
| 43 |
|