Skip to content

Commit 709529f

Browse files
committed
fix(OpenAI): augment support for Response API - MCP Connectors
1 parent 03ac006 commit 709529f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/Responses/Responses/Output/OutputMcpCall.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public static function from(array $attributes): self
4848
arguments: $attributes['arguments'],
4949
name: $attributes['name'],
5050
approvalRequestId: $attributes['approval_request_id'],
51-
error: $attributes['error'],
51+
// TODO - Why is this coming back as an array?
52+
error: is_array($attributes['error'])
53+
? json_encode($attributes['error'])
54+
: $attributes['error'],
5255
output: $attributes['output'],
5356
);
5457
}

src/Responses/Responses/Tool/RemoteMcpTool.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @phpstan-import-type McpToolNamesFilterType from McpToolNamesFilter
1313
*
14-
* @phpstan-type RemoteMcpToolType array{type: 'mcp', server_label: string, server_url: string, require_approval: 'never'|'always'|array<'never'|'always', McpToolNamesFilterType>|null, allowed_tools: array<int, string>|McpToolNamesFilterType|null, headers: array<string, string>|null}
14+
* @phpstan-type RemoteMcpToolType array{type: 'mcp', server_label: string, authorization: string|null, connector_id?: string|null, server_url: string|null, require_approval: 'never'|'always'|array<'never'|'always', McpToolNamesFilterType>|null, allowed_tools: array<int, string>|McpToolNamesFilterType|null, headers: array<string, string>|null, server_description?: string|null}
1515
*
1616
* @implements ResponseContract<RemoteMcpToolType>
1717
*/
@@ -33,10 +33,13 @@ final class RemoteMcpTool implements ResponseContract
3333
private function __construct(
3434
public readonly string $type,
3535
public readonly string $serverLabel,
36-
public readonly string $serverUrl,
36+
public readonly ?string $serverUrl = null,
3737
public readonly string|array|null $requireApproval = null,
3838
public readonly array|McpToolNamesFilter|null $allowedTools = null,
3939
public readonly ?array $headers = null,
40+
public readonly ?string $connectorId = null,
41+
public readonly ?string $authorization = null,
42+
public readonly ?string $serverDescription = null,
4043
) {}
4144

4245
/**
@@ -59,10 +62,13 @@ public static function from(array $attributes): self
5962
return new self(
6063
type: $attributes['type'],
6164
serverLabel: $attributes['server_label'],
62-
serverUrl: $attributes['server_url'],
65+
serverUrl: $attributes['server_url'] ?? null,
6366
requireApproval: $requireApproval,
6467
allowedTools: $allowedTools, // @phpstan-ignore-line
6568
headers: $attributes['headers'] ?? null,
69+
connectorId: $attributes['connector_id'] ?? null,
70+
authorization: $attributes['authorization'] ?? null,
71+
serverDescription: $attributes['server_description'] ?? null,
6672
);
6773
}
6874

@@ -90,6 +96,9 @@ public function toArray(): array
9096
'require_approval' => $requireApproval,
9197
'allowed_tools' => $allowedTools,
9298
'headers' => $this->headers,
99+
'connector_id' => $this->connectorId,
100+
'authorization' => $this->authorization,
101+
'server_description' => $this->serverDescription,
93102
];
94103
}
95104
}

0 commit comments

Comments
 (0)