Files
Mian Shahzad RazaandClaude Opus 4.8 165b09caf1 perf(mcp): no-store/LiteSpeed cache headers + reliability guidance (Issue 1)
Bug report Issue 1 (intermittent 'connector isn't responding' on shared
LiteSpeed): send Cache-Control: no-store + X-LiteSpeed-Cache-Control: no-cache
+ X-Accel-Buffering: no on the MCP route so LiteSpeed/QUIC never caches or
buffers MCP responses. Adds a readme FAQ (cache-exclusion + PHP limits + MCP
Log) and an opt-in EMCP_TOOLS_PROFILE_REGISTRATION timing seam. The registrar
was confirmed already lazy/cheap, so this targets the transport layer.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-08-01 05:13:37 +05:00

44 lines
1.4 KiB
PHP

<?php
/**
* Host-mismatch guard (Bug report Issue 2).
*
* @package EMCP_Tools
*/
use PHPUnit\Framework\TestCase;
require_once __DIR__ . '/../includes/class-mcp-host-guard.php';
class McpHostGuardTest extends TestCase {
public function test_exact_match(): void {
$this->assertTrue(
EMCP_Tools_MCP_Host_Guard::host_matches( 'devis.debord-toiture.com', 'devis.debord-toiture.com' )
);
}
public function test_www_and_case_and_port_tolerant(): void {
$this->assertTrue(
EMCP_Tools_MCP_Host_Guard::host_matches( 'www.Example.com:443', 'example.com' )
);
}
public function test_different_domain_is_mismatch(): void {
$this->assertFalse(
EMCP_Tools_MCP_Host_Guard::host_matches( 'paleturquoise-sardine-346722.hostingersite.com', 'devis.debord-toiture.com' )
);
}
public function test_empty_request_host_is_not_a_mismatch(): void {
// A missing Host header must never brick the endpoint.
$this->assertTrue( EMCP_Tools_MCP_Host_Guard::host_matches( '', 'example.com' ) );
}
public function test_is_mcp_route(): void {
$this->assertTrue( EMCP_Tools_MCP_Host_Guard::is_mcp_route( '/mcp/emcp-tools-server' ) );
$this->assertTrue( EMCP_Tools_MCP_Host_Guard::is_mcp_route( '/mcp/emcp-tools-server/messages' ) );
$this->assertFalse( EMCP_Tools_MCP_Host_Guard::is_mcp_route( '/wp/v2/posts' ) );
$this->assertFalse( EMCP_Tools_MCP_Host_Guard::is_mcp_route( '/mcp/other-server' ) );
}
}