Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Server/Registrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function web(string $route, string $serverClass): Route
fn (): HttpTransport => new HttpTransport(
$request = request(),
// @phpstan-ignore-next-line
(string) $request->header('Mcp-Session-Id')
(string) $request->header('MCP-Session-Id')
),
))->middleware([
ReorderJsonAccept::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Server/Transport/HttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function getHeaders(): array
];

if ($this->replySessionId !== null) {
$headers['Mcp-Session-Id'] = $this->replySessionId;
$headers['MCP-Session-Id'] = $this->replySessionId;
}

if ($this->stream instanceof Closure) {
Expand Down
22 changes: 11 additions & 11 deletions tests/Feature/Console/StartCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
/** @var TestResponse $response */
$response = $this->postJson('test-mcp', initializeMessage());

$response->assertHeader('Mcp-Session-Id');
$response->assertHeader('MCP-Session-Id');

// https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#session-management
expect($response->headers->get('Mcp-Session-Id'))->toMatch('/^[\x21-\x7E]+$/');
expect($response->headers->get('MCP-Session-Id'))->toMatch('/^[\x21-\x7E]+$/');
});

it('can list resources over http', function (): void {
Expand All @@ -30,7 +30,7 @@
$response = $this->postJson(
'test-mcp',
listResourcesMessage(),
['Mcp-Session-Id' => $sessionId],
['MCP-Session-Id' => $sessionId],
);

$response->assertStatus(200);
Expand All @@ -44,7 +44,7 @@
$response = $this->postJson(
'test-mcp',
readResourceMessage(),
['Mcp-Session-Id' => $sessionId],
['MCP-Session-Id' => $sessionId],
);

$response->assertStatus(200);
Expand All @@ -58,7 +58,7 @@
$response = $this->postJson(
'test-mcp',
listToolsMessage(),
['Mcp-Session-Id' => $sessionId],
['MCP-Session-Id' => $sessionId],
);

$response->assertStatus(200);
Expand All @@ -72,7 +72,7 @@
$response = $this->postJson(
'test-mcp',
callToolMessage(),
['Mcp-Session-Id' => $sessionId],
['MCP-Session-Id' => $sessionId],
);

$response->assertStatus(200);
Expand All @@ -86,7 +86,7 @@
$response = $this->postJson(
'test-mcp',
pingMessage(),
['Mcp-Session-Id' => $sessionId],
['MCP-Session-Id' => $sessionId],
);

$response->assertStatus(200);
Expand All @@ -100,7 +100,7 @@
$response = $this->postJson(
'test-mcp',
callStreamingToolMessage(),
['Mcp-Session-Id' => $sessionId, 'Accept' => 'text/event-stream'],
['MCP-Session-Id' => $sessionId, 'Accept' => 'text/event-stream'],
);

$response->assertStatus(200);
Expand Down Expand Up @@ -175,7 +175,7 @@
$response = $this->postJson(
'test-mcp-dynamic-tools',
listToolsMessage(),
['Mcp-Session-Id' => $sessionId],
['MCP-Session-Id' => $sessionId],
);

$response->assertStatus(200);
Expand Down Expand Up @@ -233,9 +233,9 @@ function initializeHttpConnection($that, $handle = 'test-mcp')
{
$response = $that->postJson($handle, initializeMessage());

$sessionId = $response->headers->get('Mcp-Session-Id');
$sessionId = $response->headers->get('MCP-Session-Id');

$that->postJson($handle, initializeNotificationMessage(), ['Mcp-Session-Id' => $sessionId]);
$that->postJson($handle, initializeNotificationMessage(), ['MCP-Session-Id' => $sessionId]);

return $sessionId;
}