From 1a6cb7041d52e8a96ca302a519f138f17b1af2ec Mon Sep 17 00:00:00 2001 From: Omar Abdelwahab Date: Wed, 12 Nov 2025 19:02:54 -0800 Subject: [PATCH] precommit --- client-sdks/stainless/openapi.yml | 11 +++++++++++ docs/static/llama-stack-spec.yaml | 11 +++++++++++ docs/static/stainless-llama-stack-spec.yaml | 11 +++++++++++ src/llama_stack/core/routing_tables/toolgroups.py | 4 +++- .../tool_runtime/model_context_protocol/config.py | 1 + .../model_context_protocol.py | 12 +++--------- src/llama_stack/testing/api_recorder.py | 4 +++- .../inference/test_tools_with_schemas.py | 2 -- .../tool_runtime/test_mcp_json_schema.py | 13 ------------- 9 files changed, 43 insertions(+), 26 deletions(-) diff --git a/client-sdks/stainless/openapi.yml b/client-sdks/stainless/openapi.yml index 27351c964..f7657bc32 100644 --- a/client-sdks/stainless/openapi.yml +++ b/client-sdks/stainless/openapi.yml @@ -1881,6 +1881,13 @@ paths: required: false schema: $ref: '#/components/schemas/URL' + - name: authorization + in: query + description: >- + (Optional) OAuth access token for authenticating with the MCP server. + required: false + schema: + type: string deprecated: false /v1/toolgroups: get: @@ -9086,6 +9093,10 @@ components: - type: object description: >- A dictionary of arguments to pass to the tool. + authorization: + type: string + description: >- + (Optional) OAuth access token for authenticating with the MCP server. additionalProperties: false required: - tool_name diff --git a/docs/static/llama-stack-spec.yaml b/docs/static/llama-stack-spec.yaml index bab7c355d..759c7501a 100644 --- a/docs/static/llama-stack-spec.yaml +++ b/docs/static/llama-stack-spec.yaml @@ -1878,6 +1878,13 @@ paths: required: false schema: $ref: '#/components/schemas/URL' + - name: authorization + in: query + description: >- + (Optional) OAuth access token for authenticating with the MCP server. + required: false + schema: + type: string deprecated: false /v1/toolgroups: get: @@ -8370,6 +8377,10 @@ components: - type: object description: >- A dictionary of arguments to pass to the tool. + authorization: + type: string + description: >- + (Optional) OAuth access token for authenticating with the MCP server. additionalProperties: false required: - tool_name diff --git a/docs/static/stainless-llama-stack-spec.yaml b/docs/static/stainless-llama-stack-spec.yaml index 27351c964..f7657bc32 100644 --- a/docs/static/stainless-llama-stack-spec.yaml +++ b/docs/static/stainless-llama-stack-spec.yaml @@ -1881,6 +1881,13 @@ paths: required: false schema: $ref: '#/components/schemas/URL' + - name: authorization + in: query + description: >- + (Optional) OAuth access token for authenticating with the MCP server. + required: false + schema: + type: string deprecated: false /v1/toolgroups: get: @@ -9086,6 +9093,10 @@ components: - type: object description: >- A dictionary of arguments to pass to the tool. + authorization: + type: string + description: >- + (Optional) OAuth access token for authenticating with the MCP server. additionalProperties: false required: - tool_name diff --git a/src/llama_stack/core/routing_tables/toolgroups.py b/src/llama_stack/core/routing_tables/toolgroups.py index 0761c5582..7f5ddd2b1 100644 --- a/src/llama_stack/core/routing_tables/toolgroups.py +++ b/src/llama_stack/core/routing_tables/toolgroups.py @@ -43,7 +43,9 @@ class ToolGroupsRoutingTable(CommonRoutingTableImpl, ToolGroups): routing_key = self.tool_to_toolgroup[routing_key] return await super().get_provider_impl(routing_key, provider_id) - async def list_tools(self, toolgroup_id: str | None = None, authorization: str | None = None) -> ListToolDefsResponse: + async def list_tools( + self, toolgroup_id: str | None = None, authorization: str | None = None + ) -> ListToolDefsResponse: if toolgroup_id: if group_id := parse_toolgroup_from_toolgroup_name_pair(toolgroup_id): toolgroup_id = group_id diff --git a/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/config.py b/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/config.py index 290b13c26..f2ae0c00b 100644 --- a/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/config.py +++ b/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/config.py @@ -19,6 +19,7 @@ class MCPProviderDataValidator(BaseModel): This validator is kept for future provider-data extensions if needed. """ + pass diff --git a/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py b/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py index 4ad2d4b3a..337a30415 100644 --- a/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py +++ b/src/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py @@ -25,9 +25,7 @@ from .config import MCPProviderConfig logger = get_logger(__name__, category="tools") -class ModelContextProtocolToolRuntimeImpl( - ToolGroupsProtocolPrivate, ToolRuntime, NeedsRequestProviderData -): +class ModelContextProtocolToolRuntimeImpl(ToolGroupsProtocolPrivate, ToolRuntime, NeedsRequestProviderData): def __init__(self, config: MCPProviderConfig, _deps: dict[Api, Any]): self.config = config @@ -52,9 +50,7 @@ class ModelContextProtocolToolRuntimeImpl( # Use authorization parameter for MCP servers that require auth headers = {} - return await list_mcp_tools( - endpoint=mcp_endpoint.uri, headers=headers, authorization=authorization - ) + return await list_mcp_tools(endpoint=mcp_endpoint.uri, headers=headers, authorization=authorization) async def invoke_tool( self, tool_name: str, kwargs: dict[str, Any], authorization: str | None = None @@ -76,9 +72,7 @@ class ModelContextProtocolToolRuntimeImpl( authorization=authorization, ) - async def get_headers_from_request( - self, mcp_endpoint_uri: str - ) -> tuple[dict[str, str], str | None]: + async def get_headers_from_request(self, mcp_endpoint_uri: str) -> tuple[dict[str, str], str | None]: """ Placeholder method for extracting headers and authorization. diff --git a/src/llama_stack/testing/api_recorder.py b/src/llama_stack/testing/api_recorder.py index 87284eae9..a7ad582f3 100644 --- a/src/llama_stack/testing/api_recorder.py +++ b/src/llama_stack/testing/api_recorder.py @@ -885,7 +885,9 @@ def patch_inference_clients(): OllamaAsyncClient.list = patched_ollama_list # Create patched methods for tool runtimes - async def patched_tavily_invoke_tool(self, tool_name: str, kwargs: dict[str, Any], authorization: str | None = None): + async def patched_tavily_invoke_tool( + self, tool_name: str, kwargs: dict[str, Any], authorization: str | None = None + ): return await _patched_tool_invoke_method( _original_methods["tavily_invoke_tool"], "tavily", self, tool_name, kwargs, authorization=authorization ) diff --git a/tests/integration/inference/test_tools_with_schemas.py b/tests/integration/inference/test_tools_with_schemas.py index 9f5cecbff..53f334527 100644 --- a/tests/integration/inference/test_tools_with_schemas.py +++ b/tests/integration/inference/test_tools_with_schemas.py @@ -9,8 +9,6 @@ Integration tests for inference/chat completion with JSON Schema-based tools. Tests that tools pass through correctly to various LLM providers. """ -import json - import pytest from llama_stack.core.library_client import LlamaStackAsLibraryClient diff --git a/tests/integration/tool_runtime/test_mcp_json_schema.py b/tests/integration/tool_runtime/test_mcp_json_schema.py index cb713adec..567380244 100644 --- a/tests/integration/tool_runtime/test_mcp_json_schema.py +++ b/tests/integration/tool_runtime/test_mcp_json_schema.py @@ -9,8 +9,6 @@ Integration tests for MCP tools with complex JSON Schema support. Tests $ref, $defs, and other JSON Schema features through MCP integration. """ -import json - import pytest from llama_stack.core.library_client import LlamaStackAsLibraryClient @@ -123,8 +121,6 @@ class TestMCPSchemaPreservation: mcp_endpoint=dict(uri=uri), ) - - # List runtime tools response = llama_stack_client.tool_runtime.list_tools( tool_group_id=test_toolgroup_id, @@ -163,7 +159,6 @@ class TestMCPSchemaPreservation: provider_id="model-context-protocol", mcp_endpoint=dict(uri=uri), ) - # List tools response = llama_stack_client.tool_runtime.list_tools( @@ -210,8 +205,6 @@ class TestMCPSchemaPreservation: mcp_endpoint=dict(uri=uri), ) - - response = llama_stack_client.tool_runtime.list_tools( tool_group_id=test_toolgroup_id, authorization=AUTH_TOKEN, @@ -254,8 +247,6 @@ class TestMCPToolInvocation: mcp_endpoint=dict(uri=uri), ) - - # List tools to populate the tool index llama_stack_client.tool_runtime.list_tools( tool_group_id=test_toolgroup_id, @@ -297,8 +288,6 @@ class TestMCPToolInvocation: mcp_endpoint=dict(uri=uri), ) - - # List tools to populate the tool index llama_stack_client.tool_runtime.list_tools( tool_group_id=test_toolgroup_id, @@ -350,8 +339,6 @@ class TestAgentWithMCPTools: mcp_endpoint=dict(uri=uri), ) - - tools_list = llama_stack_client.tools.list( toolgroup_id=test_toolgroup_id, authorization=AUTH_TOKEN,