Skip to content

Commit 3aa36f9

Browse files
committed
tool: search-docs return markdown from API
1 parent 66bb8b2 commit 3aa36f9

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/Mcp/Tools/SearchDocs.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ class SearchDocs extends Tool
1616
{
1717
use MakesHttpRequests;
1818

19-
public function __construct(protected Roster $roster)
20-
{
21-
}
19+
public function __construct(protected Roster $roster) {}
2220

2321
public function description(): string
2422
{
@@ -29,7 +27,7 @@ public function schema(ToolInputSchema $schema): ToolInputSchema
2927
{
3028
return $schema
3129
->string('queries')
32-
->description('### separated list of queries to perform. Useful to pass multiple if you aren\'t sure if it is "toggle" or "switch, or "infinite scroll" or "infinite load", for example.')->required()
30+
->description('### separated list of queries to perform. Useful to pass multiple if you aren\'t sure if it is "toggle" or "switch", or "infinite scroll" or "infinite load", for example.')->required()
3331

3432
->raw('packages', [
3533
'description' => 'Package names to limit searching to from application-info. Useful if you know the package(s) you need. i.e. laravel/framework, inertiajs/inertia-laravel, @inertiajs/react',
@@ -100,18 +98,6 @@ public function handle(array $arguments): ToolResult|Generator
10098
return ToolResult::error('HTTP request failed: '.$e->getMessage());
10199
}
102100

103-
$data = $response->json();
104-
$results = $data['results'] ?? [];
105-
106-
/** @var array<int, array{content?: string}> $results */
107-
$concatenatedKnowledge = collect($results)
108-
->map(fn ($result) => $result['content'] ?? '')
109-
->filter()
110-
->join("\n\n---\n\n");
111-
112-
return ToolResult::json([
113-
'knowledge_count' => count($results),
114-
'knowledge' => $concatenatedKnowledge,
115-
]);
101+
return ToolResult::text($response->body());
116102
}
117103
}

0 commit comments

Comments
 (0)