Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Microsoft Autogen StaticWorkbench McpWorkbench

From Leeroopedia
Knowledge Sources
Domains Tool Management, Tool Discovery, MCP, Agent Infrastructure
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete tools for managing tool lifecycle and discovery provided by Microsoft AutoGen: StaticWorkbench for fixed in-memory tool sets and McpWorkbench for dynamic tool discovery via MCP servers.

Description

StaticWorkbench holds a fixed list of BaseTool instances provided at construction time. It implements the Workbench interface by listing the schemas of its tools (with any overrides applied) and dispatching tool calls by name. Its lifecycle methods (start/stop) are no-ops since all tools are already loaded in memory.

McpWorkbench connects to an external MCP (Model Context Protocol) server to discover and invoke tools dynamically. During start(), it establishes a connection to the server using the provided transport parameters (stdio, HTTP/SSE, or streamable HTTP). It queries the server for available tools via the MCP protocol and presents them as tool schemas. Tool calls are dispatched to the server over the connection. During stop(), it tears down the connection. The MCP server can be a separate process, a remote service, or any MCP-compatible tool provider.

Both workbench types support tool overrides via the tool_overrides parameter. An override can rename a tool, change its description, or modify its parameter schema. Overrides are validated at construction time to prevent name conflicts. A reverse mapping is maintained so that when a tool is called by its overridden name, the workbench resolves back to the original name for dispatch.

Usage

Use StaticWorkbench when you have a known set of tools and want to manage them as a group with optional overrides. Use McpWorkbench when you need to connect to external MCP tool servers for dynamic tool discovery. Pass either workbench type to an AssistantAgent's workbench parameter.

Code Reference

Source Location

  • Repository: Microsoft AutoGen
  • File (StaticWorkbench): python/packages/autogen-core/src/autogen_core/tools/_static_workbench.py (lines 41-66)
  • File (McpWorkbench): python/packages/autogen-ext/src/autogen_ext/tools/mcp/_workbench.py (lines 239-269)

Signature

# StaticWorkbench
class StaticWorkbench:
    def __init__(
        self,
        tools: List[BaseTool[Any, Any]],
        tool_overrides: Optional[Dict[str, ToolOverride]] = None,
    ) -> None:
        ...

# McpWorkbench
class McpWorkbench:
    def __init__(
        self,
        server_params: McpServerParams,
        tool_overrides: Optional[Dict[str, ToolOverride]] = None,
        host: McpSessionHost | None = None,
    ) -> None:
        ...

Import

from autogen_core.tools import StaticWorkbench
from autogen_ext.tools.mcp import McpWorkbench

I/O Contract

Inputs (StaticWorkbench)

Name Type Required Description
tools List[BaseTool[Any, Any]] Yes A fixed list of tool instances to manage. Each tool must have a unique name.
tool_overrides Dict[str, ToolOverride] or None No A dictionary mapping original tool names to override configurations. Each ToolOverride can specify a new name, description, or parameter schema. Override names must not conflict with existing tool names or other overrides.

Inputs (McpWorkbench)

Name Type Required Description
server_params McpServerParams Yes Connection parameters for the MCP server. This is a union type supporting StdioServerParams (for subprocess-based servers), SseServerParams (for HTTP/SSE servers), or StreamableHttpServerParams (for streamable HTTP servers).
tool_overrides Dict[str, ToolOverride] or None No Per-tool overrides, same as StaticWorkbench. Applied to tools discovered from the MCP server.
host McpSessionHost or None No An optional host for the MCP session, allowing customization of session management behavior.

Outputs

Name Type Description
instance StaticWorkbench or McpWorkbench A workbench instance implementing the Workbench interface with start(), list_tools(), call_tool(), and stop() methods.

Usage Examples

StaticWorkbench Basic Example

from autogen_core.tools import FunctionTool, StaticWorkbench


async def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Sunny in {city}"


async def get_time(timezone: str) -> str:
    """Get current time in a timezone."""
    return f"12:00 PM in {timezone}"


weather_tool = FunctionTool(func=get_weather, description="Get weather")
time_tool = FunctionTool(func=get_time, description="Get time")

workbench = StaticWorkbench(tools=[weather_tool, time_tool])

StaticWorkbench with Overrides

from autogen_core.tools import FunctionTool, StaticWorkbench, ToolOverride


async def fetch_data(url: str) -> str:
    """Fetch data from a URL."""
    return f"Data from {url}"


tool = FunctionTool(func=fetch_data, description="Fetch data from URL")

workbench = StaticWorkbench(
    tools=[tool],
    tool_overrides={
        "fetch_data": ToolOverride(
            name="web_fetch",
            description="Retrieve content from a web page by URL.",
        )
    },
)

McpWorkbench Example

from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient


server_params = StdioServerParams(
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
)

workbench = McpWorkbench(server_params=server_params)

model_client = OpenAIChatCompletionClient(model="gpt-4o")

agent = AssistantAgent(
    name="file_agent",
    model_client=model_client,
    workbench=workbench,
)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment