Skip to content

@return / outputSchema missing #76

@vielhuber

Description

@vielhuber

The PHP MCP server appears to ignore PHPDoc @return annotations when building tool metadata and does not expose any outputSchema for tools discovered via attributes (e.g. #[McpTool]).

Input schemas are inferred from type hints and optional #[Schema] attributes, but output schemas are missing even when the return type is documented in PHPDoc. This makes it impossible to communicate structured return shapes to MCP clients without manual registration.

The example in the readme is therefore misleading:

/**
 * Adds two numbers together.
 * 
 * @param int $a The first number
 * @param int $b The second number  
 * @return int The sum of the two numbers
 */
#[McpTool(name: 'add_numbers')]
public function add(int $a, int $b): int
{
    return $a + $b;
}

Expected behavior or feature request:

Either parse PHPDoc @return (or a dedicated PHPDoc tag) to derive an output schema when using attribute discovery, or
This limitation makes it difficult to document tool outputs and metadata consistently in projects that rely on discovery rather than manual withTool(...) registration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions