Skip to content

Commit 0b552c6

Browse files
fix: MCP authorization parameter implementation
1 parent 32cb959 commit 0b552c6

File tree

6 files changed

+47
-2
lines changed

6 files changed

+47
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 96
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-ec32c74fc91569d09bb78aa3cdd8ebc65ed6c83bbd845fb79676e37c1711eda2.yml
3-
openapi_spec_hash: 88f8449f767bd696985306c5dda5d026
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-602ce64aa309cc15fa09388d99c9f298795686fc37605237cbc03c39d29aabf6.yml
3+
openapi_spec_hash: fc6995247b2555e8660bc9291eb10415
44
config_hash: e8a35d9d37cb4774b4b0fe1b167dc156

src/llama_stack_client/resources/tool_runtime/tool_runtime.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def invoke_tool(
5656
*,
5757
kwargs: Dict[str, Union[bool, float, str, Iterable[object], object, None]],
5858
tool_name: str,
59+
authorization: str | Omit = omit,
5960
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6061
# The extra values given here take precedence over values defined on the client or passed to this method.
6162
extra_headers: Headers | None = None,
@@ -71,6 +72,8 @@ def invoke_tool(
7172
7273
tool_name: The name of the tool to invoke.
7374
75+
authorization: (Optional) OAuth access token for authenticating with the MCP server.
76+
7477
extra_headers: Send extra headers
7578
7679
extra_query: Add additional query parameters to the request
@@ -85,6 +88,7 @@ def invoke_tool(
8588
{
8689
"kwargs": kwargs,
8790
"tool_name": tool_name,
91+
"authorization": authorization,
8892
},
8993
tool_runtime_invoke_tool_params.ToolRuntimeInvokeToolParams,
9094
),
@@ -97,6 +101,7 @@ def invoke_tool(
97101
def list_tools(
98102
self,
99103
*,
104+
authorization: str | Omit = omit,
100105
mcp_endpoint: tool_runtime_list_tools_params.McpEndpoint | Omit = omit,
101106
tool_group_id: str | Omit = omit,
102107
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -110,6 +115,8 @@ def list_tools(
110115
List all tools in the runtime.
111116
112117
Args:
118+
authorization: (Optional) OAuth access token for authenticating with the MCP server.
119+
113120
mcp_endpoint: The MCP endpoint to use for the tool group.
114121
115122
tool_group_id: The ID of the tool group to list tools for.
@@ -131,6 +138,7 @@ def list_tools(
131138
timeout=timeout,
132139
query=maybe_transform(
133140
{
141+
"authorization": authorization,
134142
"mcp_endpoint": mcp_endpoint,
135143
"tool_group_id": tool_group_id,
136144
},
@@ -167,6 +175,7 @@ async def invoke_tool(
167175
*,
168176
kwargs: Dict[str, Union[bool, float, str, Iterable[object], object, None]],
169177
tool_name: str,
178+
authorization: str | Omit = omit,
170179
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
171180
# The extra values given here take precedence over values defined on the client or passed to this method.
172181
extra_headers: Headers | None = None,
@@ -182,6 +191,8 @@ async def invoke_tool(
182191
183192
tool_name: The name of the tool to invoke.
184193
194+
authorization: (Optional) OAuth access token for authenticating with the MCP server.
195+
185196
extra_headers: Send extra headers
186197
187198
extra_query: Add additional query parameters to the request
@@ -196,6 +207,7 @@ async def invoke_tool(
196207
{
197208
"kwargs": kwargs,
198209
"tool_name": tool_name,
210+
"authorization": authorization,
199211
},
200212
tool_runtime_invoke_tool_params.ToolRuntimeInvokeToolParams,
201213
),
@@ -208,6 +220,7 @@ async def invoke_tool(
208220
async def list_tools(
209221
self,
210222
*,
223+
authorization: str | Omit = omit,
211224
mcp_endpoint: tool_runtime_list_tools_params.McpEndpoint | Omit = omit,
212225
tool_group_id: str | Omit = omit,
213226
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -221,6 +234,8 @@ async def list_tools(
221234
List all tools in the runtime.
222235
223236
Args:
237+
authorization: (Optional) OAuth access token for authenticating with the MCP server.
238+
224239
mcp_endpoint: The MCP endpoint to use for the tool group.
225240
226241
tool_group_id: The ID of the tool group to list tools for.
@@ -242,6 +257,7 @@ async def list_tools(
242257
timeout=timeout,
243258
query=await async_maybe_transform(
244259
{
260+
"authorization": authorization,
245261
"mcp_endpoint": mcp_endpoint,
246262
"tool_group_id": tool_group_id,
247263
},

src/llama_stack_client/types/response_create_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,9 @@ class ToolOpenAIResponseInputToolMcp(TypedDict, total=False):
618618
allowed_tools: ToolOpenAIResponseInputToolMcpAllowedTools
619619
"""(Optional) Restriction on which tools can be used from this server"""
620620

621+
authorization: str
622+
"""(Optional) OAuth access token for authenticating with the MCP server"""
623+
621624
headers: Dict[str, Union[bool, float, str, Iterable[object], object, None]]
622625
"""(Optional) HTTP headers to include when connecting to the server"""
623626

src/llama_stack_client/types/tool_runtime_invoke_tool_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ class ToolRuntimeInvokeToolParams(TypedDict, total=False):
2020

2121
tool_name: Required[str]
2222
"""The name of the tool to invoke."""
23+
24+
authorization: str
25+
"""(Optional) OAuth access token for authenticating with the MCP server."""

src/llama_stack_client/types/tool_runtime_list_tools_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515

1616
class ToolRuntimeListToolsParams(TypedDict, total=False):
17+
authorization: str
18+
"""(Optional) OAuth access token for authenticating with the MCP server."""
19+
1720
mcp_endpoint: McpEndpoint
1821
"""The MCP endpoint to use for the tool group."""
1922

tests/api_resources/test_tool_runtime.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def test_method_invoke_tool(self, client: LlamaStackClient) -> None:
3434
)
3535
assert_matches_type(ToolInvocationResult, tool_runtime, path=["response"])
3636

37+
@parametrize
38+
def test_method_invoke_tool_with_all_params(self, client: LlamaStackClient) -> None:
39+
tool_runtime = client.tool_runtime.invoke_tool(
40+
kwargs={"foo": True},
41+
tool_name="tool_name",
42+
authorization="authorization",
43+
)
44+
assert_matches_type(ToolInvocationResult, tool_runtime, path=["response"])
45+
3746
@parametrize
3847
def test_raw_response_invoke_tool(self, client: LlamaStackClient) -> None:
3948
response = client.tool_runtime.with_raw_response.invoke_tool(
@@ -68,6 +77,7 @@ def test_method_list_tools(self, client: LlamaStackClient) -> None:
6877
@parametrize
6978
def test_method_list_tools_with_all_params(self, client: LlamaStackClient) -> None:
7079
tool_runtime = client.tool_runtime.list_tools(
80+
authorization="authorization",
7181
mcp_endpoint={"uri": "uri"},
7282
tool_group_id="tool_group_id",
7383
)
@@ -107,6 +117,15 @@ async def test_method_invoke_tool(self, async_client: AsyncLlamaStackClient) ->
107117
)
108118
assert_matches_type(ToolInvocationResult, tool_runtime, path=["response"])
109119

120+
@parametrize
121+
async def test_method_invoke_tool_with_all_params(self, async_client: AsyncLlamaStackClient) -> None:
122+
tool_runtime = await async_client.tool_runtime.invoke_tool(
123+
kwargs={"foo": True},
124+
tool_name="tool_name",
125+
authorization="authorization",
126+
)
127+
assert_matches_type(ToolInvocationResult, tool_runtime, path=["response"])
128+
110129
@parametrize
111130
async def test_raw_response_invoke_tool(self, async_client: AsyncLlamaStackClient) -> None:
112131
response = await async_client.tool_runtime.with_raw_response.invoke_tool(
@@ -141,6 +160,7 @@ async def test_method_list_tools(self, async_client: AsyncLlamaStackClient) -> N
141160
@parametrize
142161
async def test_method_list_tools_with_all_params(self, async_client: AsyncLlamaStackClient) -> None:
143162
tool_runtime = await async_client.tool_runtime.list_tools(
163+
authorization="authorization",
144164
mcp_endpoint={"uri": "uri"},
145165
tool_group_id="tool_group_id",
146166
)

0 commit comments

Comments
 (0)