-
-
Notifications
You must be signed in to change notification settings - Fork 0
Missing: Tests for MCP API Controller tool execution #8
Copy link
Copy link
Closed
Labels
Description
Description
The McpApiController has significant functionality but lacks dedicated test coverage for critical paths including tool execution, version resolution, and error handling.
Location
src/Api/Controllers/McpApiController.php- No corresponding test file found in
src/Api/Tests/Feature/
Missing Test Coverage
-
Tool execution flow (
callToolmethod):- Valid tool execution
- Invalid server/tool combinations
- Version resolution and deprecation warnings
- Input validation against JSON schema
- Error handling for failed executions
-
Version management:
- Version resolution (latest, specific, deprecated)
- Sunset version blocking (410 responses)
- Deprecation header injection
-
Security boundaries:
- API key scope enforcement on POST /tools/call
- Server scope restrictions
- Rate limiting behaviour
-
Error conditions:
- Invalid server ID
- Invalid tool name
- Schema validation failures
- Process execution failures
Impact
Without tests, regressions in the MCP API could go undetected, potentially breaking integrations for API consumers.
Recommended Tests
// src/Api/Tests/Feature/McpApiControllerTest.php
it('returns 404 for unknown server', function () {
$response = $this->withApiKey()->postJson('/api/v1/mcp/tools/call', [
'server' => 'nonexistent',
'tool' => 'some-tool',
]);
$response->assertNotFound();
});
it('returns 404 for unknown tool', function () {
// Mock registry to return a valid server
$response = $this->withApiKey()->postJson('/api/v1/mcp/tools/call', [
'server' => 'hosthub-agent',
'tool' => 'nonexistent-tool',
]);
$response->assertNotFound();
});
it('returns 422 for schema validation failures', function () {
// Test with missing required arguments
});
it('returns 410 for sunset versions', function () {
// Test version that has been sunset
});
it('includes deprecation headers for deprecated versions', function () {
// Test deprecation warning headers
});Priority
Medium - Test coverage is essential for maintainability and catching regressions.
Reactions are currently unavailable