Skip to content

Conversation

@SongChiYoung
Copy link
Contributor

@SongChiYoung SongChiYoung commented Apr 22, 2025

Why are these changes needed?

@ekzhu McpActor for WorkBench is ready! 🚀
I believe we should add more test coverage for this.

If this looks good to you,
would it be possible to trigger Codecov for this PR?
It’d help to easily review which areas need more coverage based on the current changes.

Unless you’re planning to add tests yourself — in that case, no worries at all.

Here’s one of my local test cases — everything runs fine on my end:

def test24():
    import asyncio
    from autogen_ext.tools.mcp import StdioServerParams, McpWorkBench
    from pprint import pprint

    async def main() -> None:
        server_params = StdioServerParams(
            command="npx",
            args=["@playwright/mcp@latest", "--headless", "--executable-path", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"],
        )
        server_params.read_timeout_seconds = 120
        # tools = await mcp_server_tools(server_params)
        workbench = McpWorkBench(server_params)

        await workbench.start()
        pprint(await workbench.list_tools())
        """
        {
            'description': 'Navigate to a URL',
            'name': 'browser_navigate',
            'parameters': {'additionalProperties': False,
                            'properties': {'url': {'description': 'The URL to navigate to',
                                                    'type': 'string'}},
                            'required': ['url'],
                            'type': 'object'}
        },
        {
            'description': 'Wait for a specified time in seconds',
            'name': 'browser_wait',
            'parameters': {'additionalProperties': False,
                            'properties': {'time': {'description': 'The time to wait in '
                                                                    'seconds',
                                                    'type': 'number'}},
                            'required': ['time'],
                            'type': 'object'}
        },
        {
            'description': 'Save page as PDF',
            'name': 'browser_pdf_save',
            'parameters': {'additionalProperties': False,
                            'properties': {},
                            'required': [],
                            'type': 'object'}
        },
        """
        # navigate to a URL
        result = await workbench.call_tool("browser_navigate", {"url": "https://www.bing.com"})
        pprint(result)
        # wait for a specified time in seconds
        result = await workbench.call_tool("browser_wait", {"time": 5})
        # save page as PDF
        result = await workbench.call_tool("browser_pdf_save", {})
        pprint(result)

        await workbench.stop()


        serial = workbench.dump_component()
        workbench = McpWorkBench.load_component(serial)

        # navigate to a URL
        result = await workbench.call_tool("browser_navigate", {"url": "https://www.google.com"})
        pprint(result)
        # wait for a specified time in seconds
        result = await workbench.call_tool("browser_wait", {"time": 5})
        # save page as PDF
        result = await workbench.call_tool("browser_pdf_save", {})
        

    asyncio.run(main())


if __name__ == "__main__":

    test24()

If this looks good so far, I’ve added initial tests, including a basic fetch using list_tools() to validate the setup.

Related issue number

Related #6340

Checks

@ekzhu ekzhu merged commit 8f5c8a7 into microsoft:ekzhu-workbench Apr 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants