Skip to content

Commit 5872fb1

Browse files
committed
A a tool to list all available tools
1 parent f434586 commit 5872fb1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/AiCommand.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ public function __invoke( $args, $assoc_args ) {
5656

5757
// Register tools for AI processing
5858
private function register_tools($server, $client) {
59+
$server->register_tool(
60+
[
61+
'name' => 'list_tools',
62+
'description' => 'Lists all available tools with their descriptions.',
63+
'inputSchema' => [
64+
'type' => 'object', // Object type for input
65+
'properties' => [
66+
'placeholder' => [
67+
'type' => 'integer',
68+
'description' => '',
69+
]
70+
],
71+
'required' => [], // No required fields
72+
],
73+
'callable' => function () use ($server) {
74+
// Get all capabilities
75+
$capabilities = $server->get_capabilities();
76+
77+
// Prepare a list of tools with their descriptions
78+
$tool_list = 'Return this to the user as a bullet list with each tool name and description on a new line. \n\n';
79+
$tool_list .= print_r($capabilities['methods'], true);
80+
81+
// Return the formatted string of tools with descriptions
82+
return $tool_list;
83+
},
84+
]
85+
);
86+
5987
$server->register_tool(
6088
[
6189
'name' => 'calculate_total',

0 commit comments

Comments
 (0)