diff --git a/client-sdks/stainless/openapi.yml b/client-sdks/stainless/openapi.yml index a1085c9eb..27fe184e6 100644 --- a/client-sdks/stainless/openapi.yml +++ b/client-sdks/stainless/openapi.yml @@ -7656,6 +7656,41 @@ components: title: ResponseGuardrailSpec description: >- Specification for a guardrail to apply during response generation. + MCPAuthentication: + type: object + properties: + type: + type: string + enum: + - bearer + - basic + - api_key + description: >- + Authentication type ("bearer", "basic", or "api_key") + token: + type: string + description: Bearer token for bearer authentication + username: + type: string + description: Username for basic authentication + password: + type: string + description: Password for basic authentication + api_key: + type: string + description: API key for api_key authentication + header_name: + type: string + default: X-API-Key + description: >- + Custom header name for API key (default: "X-API-Key") + additionalProperties: false + required: + - type + - header_name + title: MCPAuthentication + description: >- + Authentication configuration for MCP servers. OpenAIResponseInputTool: oneOf: - $ref: '#/components/schemas/OpenAIResponseInputToolWebSearch' @@ -7695,6 +7730,10 @@ components: - type: object description: >- (Optional) HTTP headers to include when connecting to the server + authentication: + $ref: '#/components/schemas/MCPAuthentication' + description: >- + (Optional) Authentication configuration for the MCP server require_approval: oneOf: - type: string diff --git a/tests/integration/responses/test_mcp_authentication.py b/tests/integration/responses/test_mcp_authentication.py index c6df3f1e9..a2e61b8a2 100644 --- a/tests/integration/responses/test_mcp_authentication.py +++ b/tests/integration/responses/test_mcp_authentication.py @@ -4,6 +4,8 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +import os + import pytest from llama_stack import LlamaStackAsLibraryClient @@ -12,6 +14,13 @@ from tests.common.mcp import make_mcp_server from .helpers import setup_mcp_tools +# Skip these tests in replay mode until recordings are generated +pytestmark = pytest.mark.skipif( + os.environ.get("LLAMA_STACK_TEST_INFERENCE_MODE") == "replay", + reason="No recordings yet for authentication tests. Run with --inference-mode=record-if-missing to generate.", +) + + def test_mcp_authentication_bearer(compat_client, text_model_id): """Test that bearer authentication is correctly applied to MCP requests.""" if not isinstance(compat_client, LlamaStackAsLibraryClient): @@ -52,23 +61,22 @@ def test_mcp_authentication_bearer(compat_client, text_model_id): assert response.output[1].error is None -def test_mcp_authentication_api_key(compat_client, text_model_id): - """Test that API key authentication is correctly applied to MCP requests.""" +def test_mcp_authentication_different_token(compat_client, text_model_id): + """Test authentication with a different bearer token.""" if not isinstance(compat_client, LlamaStackAsLibraryClient): pytest.skip("in-process MCP server is only supported in library client") - test_api_key = "test-api-key-456" - with make_mcp_server(required_auth_token=test_api_key, auth_header="X-API-Key") as mcp_server_info: + test_token = "different-token-456" + with make_mcp_server(required_auth_token=test_token) as mcp_server_info: tools = setup_mcp_tools( [ { "type": "mcp", - "server_label": "apikey-mcp", + "server_label": "auth2-mcp", "server_url": "", "authentication": { - "type": "api_key", - "api_key": test_api_key, - "header_name": "X-API-Key", + "type": "bearer", + "token": test_token, }, } ],