[Server] Use getDescription to get all descriptions. (#188)

* Remove `getSummary` method and update descriptions in snapshots and code

* Add changelog entry

---------

Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
This commit is contained in:
落月 2026-01-12 05:08:05 +08:00 • committed by GitHub
commit 2c16b3e084
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 42 deletions

View file

@ -222,7 +222,7 @@ final class Discoverer implements DiscovererInterface
case McpTool::class:
$docBlock = $this->docBlockParser->parseDocBlock($method->getDocComment() ?? null);
$name = $instance->name ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $instance->description ?? $this->docBlockParser->getSummary($docBlock) ?? null;
$description = $instance->description ?? $this->docBlockParser->getDescription($docBlock) ?? null;
$inputSchema = $this->schemaGenerator->generate($method);
$outputSchema = $this->schemaGenerator->generateOutputSchema($method);
$tool = new Tool(
@ -241,7 +241,7 @@ final class Discoverer implements DiscovererInterface
case McpResource::class:
$docBlock = $this->docBlockParser->parseDocBlock($method->getDocComment() ?? null);
$name = $instance->name ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $instance->description ?? $this->docBlockParser->getSummary($docBlock) ?? null;
$description = $instance->description ?? $this->docBlockParser->getDescription($docBlock) ?? null;
$resource = new Resource(
$instance->uri,
$name,
@ -260,7 +260,7 @@ final class Discoverer implements DiscovererInterface
case McpPrompt::class:
$docBlock = $this->docBlockParser->parseDocBlock($method->getDocComment() ?? null);
$name = $instance->name ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $instance->description ?? $this->docBlockParser->getSummary($docBlock) ?? null;
$description = $instance->description ?? $this->docBlockParser->getDescription($docBlock) ?? null;
$arguments = [];
$paramTags = $this->docBlockParser->getParamTags($docBlock);
foreach ($method->getParameters() as $param) {
@ -280,7 +280,7 @@ final class Discoverer implements DiscovererInterface
case McpResourceTemplate::class:
$docBlock = $this->docBlockParser->parseDocBlock($method->getDocComment() ?? null);
$name = $instance->name ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $instance->description ?? $this->docBlockParser->getSummary($docBlock) ?? null;
$description = $instance->description ?? $this->docBlockParser->getDescription($docBlock) ?? null;
$mimeType = $instance->mimeType;
$annotations = $instance->annotations;
$meta = $instance->meta ?? null;

View file

@ -55,19 +55,6 @@ class DocBlockParser
}
}
/**
* Gets the summary line from a DocBlock.
*/
public function getSummary(?DocBlock $docBlock): ?string
{
if (!$docBlock) {
return null;
}
$summary = trim($docBlock->getSummary());
return $summary ?: null; // Return null if empty after trimming
}
/**
* Gets the description from a DocBlock (summary + description body).
*/

View file

@ -108,7 +108,7 @@ final class ArrayLoader implements LoaderInterface
$docBlock = $docBlockParser->parseDocBlock($reflection->getDocComment() ?? null);
$name = $data['name'] ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $data['description'] ?? $docBlockParser->getSummary($docBlock) ?? null;
$description = $data['description'] ?? $docBlockParser->getDescription($docBlock) ?? null;
}
$inputSchema = $data['inputSchema'] ?? $schemaGenerator->generate($reflection);
@ -149,7 +149,7 @@ final class ArrayLoader implements LoaderInterface
$docBlock = $docBlockParser->parseDocBlock($reflection->getDocComment() ?? null);
$name = $data['name'] ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $data['description'] ?? $docBlockParser->getSummary($docBlock) ?? null;
$description = $data['description'] ?? $docBlockParser->getDescription($docBlock) ?? null;
}
$resource = new Resource(
@ -189,7 +189,7 @@ final class ArrayLoader implements LoaderInterface
$docBlock = $docBlockParser->parseDocBlock($reflection->getDocComment() ?? null);
$name = $data['name'] ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $data['description'] ?? $docBlockParser->getSummary($docBlock) ?? null;
$description = $data['description'] ?? $docBlockParser->getDescription($docBlock) ?? null;
}
$template = new ResourceTemplate(
@ -228,7 +228,7 @@ final class ArrayLoader implements LoaderInterface
$docBlock = $docBlockParser->parseDocBlock($reflection->getDocComment() ?? null);
$name = $data['name'] ?? ('__invoke' === $methodName ? $classShortName : $methodName);
$description = $data['description'] ?? $docBlockParser->getSummary($docBlock) ?? null;
$description = $data['description'] ?? $docBlockParser->getDescription($docBlock) ?? null;
}
$arguments = [];