Skip to content

Commit 10dedea

Browse files
authored
Correct header name to MCP-Session-Id (#132)
1 parent affd49b commit 10dedea

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/Server/Registrar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function web(string $route, string $serverClass): Route
3737
fn (): HttpTransport => new HttpTransport(
3838
$request = request(),
3939
// @phpstan-ignore-next-line
40-
(string) $request->header('Mcp-Session-Id')
40+
(string) $request->header('MCP-Session-Id')
4141
),
4242
))->middleware([
4343
ReorderJsonAccept::class,

src/Server/Transport/HttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function getHeaders(): array
9191
];
9292

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

9797
if ($this->stream instanceof Closure) {

tests/Feature/Console/StartCommandTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
/** @var TestResponse $response */
1919
$response = $this->postJson('test-mcp', initializeMessage());
2020

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

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

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

3636
$response->assertStatus(200);
@@ -44,7 +44,7 @@
4444
$response = $this->postJson(
4545
'test-mcp',
4646
readResourceMessage(),
47-
['Mcp-Session-Id' => $sessionId],
47+
['MCP-Session-Id' => $sessionId],
4848
);
4949

5050
$response->assertStatus(200);
@@ -58,7 +58,7 @@
5858
$response = $this->postJson(
5959
'test-mcp',
6060
listToolsMessage(),
61-
['Mcp-Session-Id' => $sessionId],
61+
['MCP-Session-Id' => $sessionId],
6262
);
6363

6464
$response->assertStatus(200);
@@ -72,7 +72,7 @@
7272
$response = $this->postJson(
7373
'test-mcp',
7474
callToolMessage(),
75-
['Mcp-Session-Id' => $sessionId],
75+
['MCP-Session-Id' => $sessionId],
7676
);
7777

7878
$response->assertStatus(200);
@@ -86,7 +86,7 @@
8686
$response = $this->postJson(
8787
'test-mcp',
8888
pingMessage(),
89-
['Mcp-Session-Id' => $sessionId],
89+
['MCP-Session-Id' => $sessionId],
9090
);
9191

9292
$response->assertStatus(200);
@@ -100,7 +100,7 @@
100100
$response = $this->postJson(
101101
'test-mcp',
102102
callStreamingToolMessage(),
103-
['Mcp-Session-Id' => $sessionId, 'Accept' => 'text/event-stream'],
103+
['MCP-Session-Id' => $sessionId, 'Accept' => 'text/event-stream'],
104104
);
105105

106106
$response->assertStatus(200);
@@ -175,7 +175,7 @@
175175
$response = $this->postJson(
176176
'test-mcp-dynamic-tools',
177177
listToolsMessage(),
178-
['Mcp-Session-Id' => $sessionId],
178+
['MCP-Session-Id' => $sessionId],
179179
);
180180

181181
$response->assertStatus(200);
@@ -233,9 +233,9 @@ function initializeHttpConnection($that, $handle = 'test-mcp')
233233
{
234234
$response = $that->postJson($handle, initializeMessage());
235235

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

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

240240
return $sessionId;
241241
}

0 commit comments

Comments
 (0)