Repository navigation
Sync upstream updates: MCP request errors and origin checks, Gemini classification and AI streaming fixes #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
eb903a7
Declare the never return type on a throwing MCP test closure
binaryfire f180f97
Return protocol errors for malformed MCP requests and headers
binaryfire 238749b
Add MCP conformance fixtures and pin the conformance suite
binaryfire b0aaf42
Refuse MCP client redirects and validate request origins
binaryfire 2aeae53
Run OpenAI-compatible tool calls sent without an index
binaryfire 8cf1563
Hint at a missing or invalid API key when a provider rejects it
binaryfire dc5ae43
Add Gemini classification and port AI provider and broadcasting fixes
binaryfire e43537f
Forward attachment provider options to Anthropic requests
binaryfire fe8df37
Decode structured output from a code fence with unpaired backticks
binaryfire e0fe0b9
Keep the text of every step in a stored prompted response
binaryfire 1944d2d
Keep every tool call of a streamed Ollama reply
binaryfire ea7dc97
Classify provider errors when default JSON decoding throws
binaryfire fd3af4a
Decode a fence closed with a lone or longer backtick run
binaryfire c38b5b8
Keep streamed Anthropic citations on their text blocks
binaryfire a747a7e
Report rejected MCP notifications and keep the session
binaryfire 5562433
Trim the legacy MCP protocol version header
binaryfire 869a3e9
Only match configured MCP origins without a path
binaryfire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Dogfood\Mcp\Conformance\Tools; | ||
|
|
||
| use Hypervel\Contracts\JsonSchema\JsonSchema; | ||
| use Hypervel\Mcp\Request; | ||
| use Hypervel\Mcp\Response; | ||
| use Hypervel\Mcp\Server\Tool; | ||
|
|
||
| class CustomHeaderTool extends Tool | ||
| { | ||
| protected string $name = 'test_custom_header'; | ||
|
|
||
| protected string $description = 'Tests custom Mcp-Param header mirroring'; | ||
|
|
||
| /** | ||
| * Return the mirrored region. | ||
| */ | ||
| public function handle(Request $request): Response | ||
| { | ||
| return Response::text("Region: {$request->get('region')}"); | ||
| } | ||
|
|
||
| /** | ||
| * Get the tool's input schema. | ||
| */ | ||
| public function schema(JsonSchema $schema): array | ||
| { | ||
| return [ | ||
| 'region' => $schema->string()->description('Deployment region')->required(), | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Mark the region parameter for header mirroring. | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| $tool = parent::toArray(); | ||
|
|
||
| $tool['inputSchema']['properties']['region']['x-mcp-header'] = 'Region'; | ||
|
|
||
| return $tool; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Dogfood\Mcp\Conformance\Tools; | ||
|
|
||
| use Hypervel\Mcp\Request; | ||
| use Hypervel\Mcp\Response; | ||
| use Hypervel\Mcp\Server\Tool; | ||
|
|
||
| class JsonSchema202012Tool extends Tool | ||
| { | ||
| protected string $name = 'json_schema_2020_12_tool'; | ||
|
|
||
| protected string $description = 'Tool with JSON Schema 2020-12 features'; | ||
|
|
||
| /** | ||
| * Acknowledge the call. | ||
| */ | ||
| public function handle(Request $request): Response | ||
| { | ||
| return Response::text('ok'); | ||
| } | ||
|
|
||
| /** | ||
| * Advertise an input schema using JSON Schema 2020-12 keywords. | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| ...parent::toArray(), | ||
| 'inputSchema' => [ | ||
| '$schema' => 'https://json-schema.org/draft/2020-12/schema', | ||
| 'type' => 'object', | ||
| '$defs' => [ | ||
| 'address' => [ | ||
| '$anchor' => 'addressDef', | ||
| 'type' => 'object', | ||
| 'properties' => [ | ||
| 'street' => ['type' => 'string'], | ||
| 'city' => ['type' => 'string'], | ||
| ], | ||
| ], | ||
| ], | ||
| 'properties' => [ | ||
| 'name' => ['type' => 'string'], | ||
| 'address' => ['$ref' => '#/$defs/address'], | ||
| 'contactMethod' => ['type' => 'string', 'enum' => ['phone', 'email']], | ||
| 'phone' => ['type' => 'string'], | ||
| 'email' => ['type' => 'string'], | ||
| ], | ||
| 'allOf' => [ | ||
| ['anyOf' => [['required' => ['phone']], ['required' => ['email']]]], | ||
| ], | ||
| 'if' => [ | ||
| 'properties' => ['contactMethod' => ['const' => 'phone']], | ||
| 'required' => ['contactMethod'], | ||
| ], | ||
| 'then' => ['required' => ['phone']], | ||
| 'else' => ['required' => ['email']], | ||
| 'additionalProperties' => false, | ||
| ], | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Dogfood\Mcp\Conformance\Tools; | ||
|
|
||
| use Hypervel\Mcp\Request; | ||
| use Hypervel\Mcp\Response; | ||
| use Hypervel\Mcp\Server\Tool; | ||
|
|
||
| class LoggingTool extends Tool | ||
| { | ||
| protected string $name = 'test_logging_tool'; | ||
|
|
||
| protected string $description = 'Tests that no log notifications are sent without a requested log level'; | ||
|
|
||
| /** | ||
| * Complete without sending log notifications. | ||
| */ | ||
| public function handle(Request $request): Response | ||
| { | ||
| return Response::text('Logging tool completed.'); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
dogfood/mcp/conformance/Tools/StreamingElicitationTool.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Dogfood\Mcp\Conformance\Tools; | ||
|
|
||
| use Hypervel\Mcp\Request; | ||
| use Hypervel\Mcp\Response; | ||
| use Hypervel\Mcp\Server\Tool; | ||
|
|
||
| class StreamingElicitationTool extends Tool | ||
| { | ||
| protected string $name = 'test_streaming_elicitation'; | ||
|
|
||
| protected string $description = 'Tests that the response stream never carries independent requests'; | ||
|
|
||
| /** | ||
| * Complete without sending requests on the response stream. | ||
| */ | ||
| public function handle(Request $request): Response | ||
| { | ||
| return Response::text('Streaming elicitation tool completed.'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Ai\Exceptions; | ||
|
|
||
| use Hypervel\Http\Client\RequestException; | ||
| use Hypervel\Http\Client\Response; | ||
|
|
||
| class InvalidApiKeyException extends RequestException | ||
| { | ||
| /** | ||
| * Create a new invalid API key exception. | ||
| */ | ||
| public function __construct(public string $provider, Response $response, false|int|null $truncateExceptionsAt = null) | ||
| { | ||
| parent::__construct($response, $truncateExceptionsAt); | ||
| } | ||
|
|
||
| /** | ||
| * Prepare the exception message. | ||
| */ | ||
| protected function prepareMessage(Response $response): string | ||
| { | ||
| return "Missing or invalid API key for AI provider [{$this->provider}]. " . parent::prepareMessage($response); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.