Skip to content

Commit a47f962

Browse files
feat(api): Add connectors support for MCP tool
1 parent 7333b28 commit a47f962

File tree

3 files changed

+149
-23
lines changed

3 files changed

+149
-23
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 119
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-4bcdfe525558e67a09b32dec7a573e87b94bab47db3951eb4a86a4dafb60296c.yml
3-
openapi_spec_hash: 49e7e46bfe9f61b7b7a60e36840c0cd7
4-
config_hash: e4514526ae01126a61f9b6c14a351737
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-ddbdf9343316047e8a773c54fb24e4a8d225955e202a1888fde6f9c8898ebf98.yml
3+
openapi_spec_hash: 9802f6dd381558466c897f6e387e06ca
4+
config_hash: fe0ea26680ac2075a6cd66416aefe7db

src/openai/types/responses/tool.py

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"Tool",
1616
"Mcp",
1717
"McpAllowedTools",
18-
"McpAllowedToolsMcpAllowedToolsFilter",
18+
"McpAllowedToolsMcpToolFilter",
1919
"McpRequireApproval",
2020
"McpRequireApprovalMcpToolApprovalFilter",
2121
"McpRequireApprovalMcpToolApprovalFilterAlways",
@@ -29,30 +29,54 @@
2929
]
3030

3131

32-
class McpAllowedToolsMcpAllowedToolsFilter(BaseModel):
32+
class McpAllowedToolsMcpToolFilter(BaseModel):
33+
read_only: Optional[bool] = None
34+
"""Indicates whether or not a tool modifies data or is read-only.
35+
36+
If an MCP server is
37+
[annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
38+
it will match this filter.
39+
"""
40+
3341
tool_names: Optional[List[str]] = None
3442
"""List of allowed tool names."""
3543

3644

37-
McpAllowedTools: TypeAlias = Union[List[str], McpAllowedToolsMcpAllowedToolsFilter, None]
45+
McpAllowedTools: TypeAlias = Union[List[str], McpAllowedToolsMcpToolFilter, None]
3846

3947

4048
class McpRequireApprovalMcpToolApprovalFilterAlways(BaseModel):
49+
read_only: Optional[bool] = None
50+
"""Indicates whether or not a tool modifies data or is read-only.
51+
52+
If an MCP server is
53+
[annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
54+
it will match this filter.
55+
"""
56+
4157
tool_names: Optional[List[str]] = None
42-
"""List of tools that require approval."""
58+
"""List of allowed tool names."""
4359

4460

4561
class McpRequireApprovalMcpToolApprovalFilterNever(BaseModel):
62+
read_only: Optional[bool] = None
63+
"""Indicates whether or not a tool modifies data or is read-only.
64+
65+
If an MCP server is
66+
[annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
67+
it will match this filter.
68+
"""
69+
4670
tool_names: Optional[List[str]] = None
47-
"""List of tools that do not require approval."""
71+
"""List of allowed tool names."""
4872

4973

5074
class McpRequireApprovalMcpToolApprovalFilter(BaseModel):
5175
always: Optional[McpRequireApprovalMcpToolApprovalFilterAlways] = None
52-
"""A list of tools that always require approval."""
76+
"""A filter object to specify which tools are allowed."""
5377

5478
never: Optional[McpRequireApprovalMcpToolApprovalFilterNever] = None
55-
"""A list of tools that never require approval."""
79+
"""A filter object to specify which tools are allowed."""
5680

5781

5882
McpRequireApproval: TypeAlias = Union[McpRequireApprovalMcpToolApprovalFilter, Literal["always", "never"], None]
@@ -62,15 +86,49 @@ class Mcp(BaseModel):
6286
server_label: str
6387
"""A label for this MCP server, used to identify it in tool calls."""
6488

65-
server_url: str
66-
"""The URL for the MCP server."""
67-
6889
type: Literal["mcp"]
6990
"""The type of the MCP tool. Always `mcp`."""
7091

7192
allowed_tools: Optional[McpAllowedTools] = None
7293
"""List of allowed tool names or a filter object."""
7394

95+
authorization: Optional[str] = None
96+
"""
97+
An OAuth access token that can be used with a remote MCP server, either with a
98+
custom MCP server URL or a service connector. Your application must handle the
99+
OAuth authorization flow and provide the token here.
100+
"""
101+
102+
connector_id: Optional[
103+
Literal[
104+
"connector_dropbox",
105+
"connector_gmail",
106+
"connector_googlecalendar",
107+
"connector_googledrive",
108+
"connector_microsoftteams",
109+
"connector_outlookcalendar",
110+
"connector_outlookemail",
111+
"connector_sharepoint",
112+
]
113+
] = None
114+
"""Identifier for service connectors, like those available in ChatGPT.
115+
116+
One of `server_url` or `connector_id` must be provided. Learn more about service
117+
connectors
118+
[here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
119+
120+
Currently supported `connector_id` values are:
121+
122+
- Dropbox: `connector_dropbox`
123+
- Gmail: `connector_gmail`
124+
- Google Calendar: `connector_googlecalendar`
125+
- Google Drive: `connector_googledrive`
126+
- Microsoft Teams: `connector_microsoftteams`
127+
- Outlook Calendar: `connector_outlookcalendar`
128+
- Outlook Email: `connector_outlookemail`
129+
- SharePoint: `connector_sharepoint`
130+
"""
131+
74132
headers: Optional[Dict[str, str]] = None
75133
"""Optional HTTP headers to send to the MCP server.
76134
@@ -83,6 +141,12 @@ class Mcp(BaseModel):
83141
server_description: Optional[str] = None
84142
"""Optional description of the MCP server, used to provide more context."""
85143

144+
server_url: Optional[str] = None
145+
"""The URL for the MCP server.
146+
147+
One of `server_url` or `connector_id` must be provided.
148+
"""
149+
86150

87151
class CodeInterpreterContainerCodeInterpreterToolAuto(BaseModel):
88152
type: Literal["auto"]

src/openai/types/responses/tool_param.py

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ToolParam",
1717
"Mcp",
1818
"McpAllowedTools",
19-
"McpAllowedToolsMcpAllowedToolsFilter",
19+
"McpAllowedToolsMcpToolFilter",
2020
"McpRequireApproval",
2121
"McpRequireApprovalMcpToolApprovalFilter",
2222
"McpRequireApprovalMcpToolApprovalFilterAlways",
@@ -30,30 +30,54 @@
3030
]
3131

3232

33-
class McpAllowedToolsMcpAllowedToolsFilter(TypedDict, total=False):
33+
class McpAllowedToolsMcpToolFilter(TypedDict, total=False):
34+
read_only: bool
35+
"""Indicates whether or not a tool modifies data or is read-only.
36+
37+
If an MCP server is
38+
[annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
39+
it will match this filter.
40+
"""
41+
3442
tool_names: List[str]
3543
"""List of allowed tool names."""
3644

3745

38-
McpAllowedTools: TypeAlias = Union[List[str], McpAllowedToolsMcpAllowedToolsFilter]
46+
McpAllowedTools: TypeAlias = Union[List[str], McpAllowedToolsMcpToolFilter]
3947

4048

4149
class McpRequireApprovalMcpToolApprovalFilterAlways(TypedDict, total=False):
50+
read_only: bool
51+
"""Indicates whether or not a tool modifies data or is read-only.
52+
53+
If an MCP server is
54+
[annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
55+
it will match this filter.
56+
"""
57+
4258
tool_names: List[str]
43-
"""List of tools that require approval."""
59+
"""List of allowed tool names."""
4460

4561

4662
class McpRequireApprovalMcpToolApprovalFilterNever(TypedDict, total=False):
63+
read_only: bool
64+
"""Indicates whether or not a tool modifies data or is read-only.
65+
66+
If an MCP server is
67+
[annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
68+
it will match this filter.
69+
"""
70+
4771
tool_names: List[str]
48-
"""List of tools that do not require approval."""
72+
"""List of allowed tool names."""
4973

5074

5175
class McpRequireApprovalMcpToolApprovalFilter(TypedDict, total=False):
5276
always: McpRequireApprovalMcpToolApprovalFilterAlways
53-
"""A list of tools that always require approval."""
77+
"""A filter object to specify which tools are allowed."""
5478

5579
never: McpRequireApprovalMcpToolApprovalFilterNever
56-
"""A list of tools that never require approval."""
80+
"""A filter object to specify which tools are allowed."""
5781

5882

5983
McpRequireApproval: TypeAlias = Union[McpRequireApprovalMcpToolApprovalFilter, Literal["always", "never"]]
@@ -63,15 +87,47 @@ class Mcp(TypedDict, total=False):
6387
server_label: Required[str]
6488
"""A label for this MCP server, used to identify it in tool calls."""
6589

66-
server_url: Required[str]
67-
"""The URL for the MCP server."""
68-
6990
type: Required[Literal["mcp"]]
7091
"""The type of the MCP tool. Always `mcp`."""
7192

7293
allowed_tools: Optional[McpAllowedTools]
7394
"""List of allowed tool names or a filter object."""
7495

96+
authorization: str
97+
"""
98+
An OAuth access token that can be used with a remote MCP server, either with a
99+
custom MCP server URL or a service connector. Your application must handle the
100+
OAuth authorization flow and provide the token here.
101+
"""
102+
103+
connector_id: Literal[
104+
"connector_dropbox",
105+
"connector_gmail",
106+
"connector_googlecalendar",
107+
"connector_googledrive",
108+
"connector_microsoftteams",
109+
"connector_outlookcalendar",
110+
"connector_outlookemail",
111+
"connector_sharepoint",
112+
]
113+
"""Identifier for service connectors, like those available in ChatGPT.
114+
115+
One of `server_url` or `connector_id` must be provided. Learn more about service
116+
connectors
117+
[here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
118+
119+
Currently supported `connector_id` values are:
120+
121+
- Dropbox: `connector_dropbox`
122+
- Gmail: `connector_gmail`
123+
- Google Calendar: `connector_googlecalendar`
124+
- Google Drive: `connector_googledrive`
125+
- Microsoft Teams: `connector_microsoftteams`
126+
- Outlook Calendar: `connector_outlookcalendar`
127+
- Outlook Email: `connector_outlookemail`
128+
- SharePoint: `connector_sharepoint`
129+
"""
130+
75131
headers: Optional[Dict[str, str]]
76132
"""Optional HTTP headers to send to the MCP server.
77133
@@ -84,6 +140,12 @@ class Mcp(TypedDict, total=False):
84140
server_description: str
85141
"""Optional description of the MCP server, used to provide more context."""
86142

143+
server_url: str
144+
"""The URL for the MCP server.
145+
146+
One of `server_url` or `connector_id` must be provided.
147+
"""
148+
87149

88150
class CodeInterpreterContainerCodeInterpreterToolAuto(TypedDict, total=False):
89151
type: Required[Literal["auto"]]

0 commit comments

Comments
 (0)