Get the FREE Ultimate OpenClaw Setup Guide →

mcp_autogen_sse_stdio

This repository demonstrates how to use AutoGen to integrate local and remote MCP (Model Context Protocol) servers. It showcases a local math tool (math_server.py) using Stdio and a remote Apify tool (RAG Web Browser Actor) via SSE for tasks like arithmetic and web browsing.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio sam-92-mcp_autogen_sse_stdio uvx run mcp_autogen_sse_stdio/main.py \
  --env APIFY_API_KEY="your_apify_api_key_here" \
  --env OPENAI_API_KEY="your_openai_api_key_here"

How to use

This MCP server demonstrates how an AutoGen agent can access both local and remote tools through different MCP transports within a single workflow. It wires a local calculator service (math_server.py) using Stdio transport for fast, in-process interactions, and connects to a remote web browsing tool via a Server-Sent Events (SSE) transport through Apify's MCP server. When you run the server, an AssistantAgent is created with access to both tool sets. The agent can perform arithmetic locally and fetch or summarize internet content remotely, allowing you to test multi-source tool integration and tool orchestration within one agent session.

To use it, run the server (as shown in the installation instructions). Then interact with the AutoGen agent by sending prompts that require math computation (e.g., "Calculate (3 + 5) x 12.") or requests for up-to-date information (e.g., "Summarise the latest news on Iran-US negotiations"). The agent will decide which tool set to invoke: local tools for deterministic math tasks, or remote browsing tools for dynamic information, and then return a unified answer to you.

How to install

Prerequisites

  • Python 3.12 installed
  • Node.js/npm or uv (Python package manager) available; this config uses uvx (uv) to run Python scripts
  • Access to OpenAI API key and Apify API key

Step-by-step installation

  1. Clone the repository: git clone <repository-url> cd mcp_autogen_sse_stdio

  2. Set up Python environment using uv

    • Ensure uv is installed: pip install uv
    • Create and activate a virtual environment (example using uv): uv venv --python 3.12 source .venv/bin/activate # macOS/Linux ..venv\Scripts\activate # Windows
  3. Install project dependencies in editable mode uv pip install -e .

  4. Install MCP CLI if needed (troubleshooting): uv add "mcp[cli]"

  5. Configure environment variables

    • Create a .env file in the mcp_autogen_sse_stdio directory
    • Add your API keys: OPENAI_API_KEY=your_openai_api_key_here APIFY_API_KEY=your_apify_api_key_here
  6. Run the MCP server

    • From the project root, start the server with uv: uv run mcp_autogen_sse_stdio/main.py

Notes

  • The server uses two tool transports: a local Stdio-based math server and a remote SSE-based browser tool via Apify.
  • Make sure your API keys are valid and available in the environment where you run the server.

Additional notes

Tips and common issues:

  • If you encounter MCP CLI installation issues, the provided troubleshooting step (uv add "mcp[cli]") usually resolves missing CLI tooling.
  • Ensure the local math tool (math_server.py) is accessible and compatible with Stdio transport expectations.
  • For remote browsing, verify that your Apify API key has the required permissions to access the RAG web browser actor.
  • If you change working directories, ensure the relative import paths in main.py remain valid.
  • Environment variables can be managed via a .env file; consider using a dotenv loader if your runtime environment requires it.

Related MCP Servers

Sponsor this space

Reach thousands of developers