Home / Function/ test_mcp_builtin() — langchain Function Reference

test_mcp_builtin() — langchain Function Reference

Architecture documentation for the test_mcp_builtin() function in test_responses_api.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  984ed9ee_9cdc_121f_83c5_8ba3ea26d97e["test_mcp_builtin()"]
  992496d5_b7d4_139f_00cf_3e585d851f81["test_responses_api.py"]
  984ed9ee_9cdc_121f_83c5_8ba3ea26d97e -->|defined in| 992496d5_b7d4_139f_00cf_3e585d851f81
  style 984ed9ee_9cdc_121f_83c5_8ba3ea26d97e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py lines 633–669

def test_mcp_builtin() -> None:
    llm = ChatOpenAI(model="o4-mini", use_responses_api=True, output_version="v0")

    llm_with_tools = llm.bind_tools(
        [
            {
                "type": "mcp",
                "server_label": "deepwiki",
                "server_url": "https://mcp.deepwiki.com/mcp",
                "require_approval": {"always": {"tool_names": ["read_wiki_structure"]}},
            }
        ]
    )
    input_message = {
        "role": "user",
        "content": (
            "What transport protocols does the 2025-03-26 version of the MCP spec "
            "support?"
        ),
    }
    response = llm_with_tools.invoke([input_message])
    assert all(isinstance(block, dict) for block in response.content)

    approval_message = HumanMessage(
        [
            {
                "type": "mcp_approval_response",
                "approve": True,
                "approval_request_id": output["id"],
            }
            for output in response.additional_kwargs["tool_outputs"]
            if output["type"] == "mcp_approval_request"
        ]
    )
    _ = llm_with_tools.invoke(
        [approval_message], previous_response_id=response.response_metadata["id"]
    )

Domain

Subdomains

Frequently Asked Questions

What does test_mcp_builtin() do?
test_mcp_builtin() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py.
Where is test_mcp_builtin() defined?
test_mcp_builtin() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py at line 633.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free