Skip to content

[Server] McpResourceTemplate throws 500 error when uriTemplate variable is undefined #469

Description

@ferromariano

Describe the bug

When defining an McpResourceTemplate with a uriTemplate that does not define the variable used by the resource template, the application throws a 500 Internal Server Error.

The error appears to be related to Symfony's response handling:

Warning: Cannot modify header information - headers already sent by (output started at /vendor/symfony/http-foundation/Response.php:393) (500 Internal Server Error)

To Reproduce

Steps to reproduce the behavior:

  1. Define an McpResourceTemplate.
  2. Use a variable in the resource template that is not defined in the uriTemplate.
  3. Execute/request the resource.
  4. The application returns a 500 Internal Server Error.

Example

  #[McpResourceTemplate(
        uriTemplate: 'data://tags',
        name: 'all_tags',
        title: 'All Tags ',
        description: 'All Tags',
        mimeType: 'application/json'
    )]
    public function tag_all( ?int $paged = 1 ) : array|Error {

        //.....

    }

Expected behavior

The application should handle an undefined or missing uriTemplate variable gracefully, ideally by returning a clear validation or configuration error rather than triggering a 500 Internal Server Error caused by headers being sent prematurely.

Logs

Warning: Cannot modify header information - headers already sent by (output started at /vendor/symfony/http-foundation/Response.php:393) (500 Internal Server Error)

Additional context

I encountered this while working with McpResourceTemplate.

I was unable to report the issue through GitHub's usual bug-reporting flow, so I am reporting it here directly.

Activity

  1. added
    ServerIssues & PRs related to the Server component
    on Aug 22, 2026
  2. chr-hertel commented on Aug 22, 2026

    @chr-hertel
    Member

    Can you please test if this still happens with the current main branch?
    (composer with dev-main and minimum-stability: dev)

  3. added
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Aug 22, 2026
  4. wachterjohannes commented on Aug 24, 2026

    @wachterjohannes
    Contributor

    @ferromariano ismt this a fix for your issue? #477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featureServerIssues & PRs related to the Server componentbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions