---
type: email
from: DKing <notifications@github.com>
subject: [openai/openai-agents-python] Parameter "mcp_servers" for Agent  will

 stuck event async generator while used with gradio (Issue #1716)
received: 2026-03-06 07:28:52
date_header: Thu, 11 Sep 2025 11:48:37 -0700
priority: normal
status: awaiting_approval
uid: 30150
---

## Email Content

**From:** DKing <notifications@github.com>
**Subject:** [openai/openai-agents-python] Parameter "mcp_servers" for Agent  will

 stuck event async generator while used with gradio (Issue #1716)
**Date:** Thu, 11 Sep 2025 11:48:37 -0700

### Body (preview)

DKingAlpha created an issue (openai/openai-agents-python#1716)



### Minimal Code to Reproduce

```python

import asyncio

from openai import OpenAI, AsyncOpenAI

from openai.types.responses import *

import agents

from agents import Agent, ModelSettings

from agents.run import AgentRunner

from api.credentials import Credentials



from agents.mcp import MCPServerStdio, MCPServerStdioParams, MCPServerStreamableHttp, MCPServerStreamableHttpParams



import gradio as gr

from typing import AsyncGenerator



import os

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))



mcp_memory = MCPServerStdio(

    MCPServerStdioParams(

        command="npx",

        args=["-y", "@modelcontextprotocol/server-memory"],

        env={"MEMORY_FILE_PATH": SCRIPT_DIR + "/mcp/memory.json"},

    ),

)



async_client = AsyncOpenAI(

    base_url=OPENAI_BASE_URL,

    api_key=OPENAI_API_KEY,

    timeout=600,

)



agents.set_default_openai_client(async_client)

agents.set_default_openai_api("chat_completions")

agents.set_tracing_disabled(True)



async def main():

    async with mcp_memory:

        runner = AgentRunner()

        agent = Agent(

            name="assistant",

            model_settings=ModelSettings(

                tool_choice='auto',

                temperature=0.6,

                parallel_tool_calls=True,

            ),

            mcp_servers=[mcp_memory],        # comment this out will unblock async generator

        )

        async def async_llm_request(message: str, history: list[dict|gr.Component]) \

            -> AsyncGenerator[str | gr.Component | dict | list[str | gr.Component | dict]]:

            nonlocal runner, agent

            result = runner.run_streamed(agent, input=message)

            print(message)

            async for event in result.stream_events():

                yield str(event)

        

        demo = gr.ChatInterface(

            async_llm_request,

            editable=True,

            examples=[

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
