-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdminTool.php
More file actions
34 lines (30 loc) · 1.01 KB
/
Copy pathAdminTool.php
File metadata and controls
34 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);
namespace McpServer\Tools;
use McpServer\Attributes\McpFunction;
readonly class AdminTool {
/**
* Demonstrates access control: this tool requires the caller to hold the
* `admin` role. The server hides it from tools/list for other users and
* rejects direct calls with a -32001 access-denied error.
*/
#[McpFunction(
name: 'server_status',
description: 'Returns server runtime information. Admin-only.',
schema: ['type' => 'object', 'properties' => new \stdClass()],
roles: ['admin']
)]
public function serverStatus(array $arguments): array {
return [
[
'type' => 'text',
'text' => json_encode([
'server' => 'php-simple-mcp',
'version' => '1.0.0',
'time' => date('c'),
'php_version' => PHP_VERSION,
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
]
];
}
}