Skip to main content

A config-driven, plug-and-play worker agent template built on LangGraph + FastMCP.

Project description

๐Ÿค– Universal Worker Agent Template

A config-driven, plug-and-play worker agent template.
Clone the folder, edit config.yaml, and you have a brand new specialized agent โ€” no code changes needed.


Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               Main Agent                    โ”‚
โ”‚   (calls workers via MCP tool calls)        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚ MCP (stdio / SSE)
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚      main.py       โ”‚  โ—„โ”€โ”€โ”€ FastMCP bridge
          โ”‚  execute_task(...)  โ”‚       exposes 1 tool
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚ asyncio
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚   core/agent.py    โ”‚  โ—„โ”€โ”€โ”€ LangGraph ReAct loop
          โ”‚  LangGraph + Ollama โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚ MCP clients (stdio)
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚FS Serverโ”‚  โ”‚  Web   โ”‚  โ”‚ Custom  โ”‚
   โ”‚  (npx)  โ”‚  โ”‚ Search โ”‚  โ”‚ Server  โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Component File Responsibility
Config config.yaml Defines everything โ€” identity, model, tools, server port
Config loader core/config_loader.py Parses YAML into typed dataclasses
ReAct Agent core/agent.py Loads MCP tools, runs LangGraph loop
MCP Bridge main.py Exposes execute_task() as an MCP server

Quick Start

1. Install uv (if not already installed)

# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

2. Install dependencies

uv sync

This creates a .venv and installs all dependencies from pyproject.toml automatically.

For development extras (ruff, mypy, pytest):

uv sync --all-extras

3. Configure your agent

Edit config.yaml โ€” the only file you need to touch:

agent:
  name: "FileMaster"
  description: "A specialized worker that organizes files and manages directory structures."
  system_prompt: "You are an expert at organizing and refactoring local files."

model:
  provider: "ollama" # Supported: "ollama", "openai", "gemini"
  model_name: "llama3.2" # any model loaded in Ollama
  # api_key: "your-api-key-here" # Uncomment if using openai or gemini (or set API_KEY env var)

mcp_clients:
  - name: "filesystem-server"
    command: "npx"
    args:
      ["-y", "@modelcontextprotocol/server-filesystem", "C:/Users/Dev/Project"]

server:
  transport: "stdio" # or "sse"
  port: 8001

4. Run as a subprocess (stdio) โ€” standard MCP

uv run worker-agent

5. Run as an HTTP server (SSE) โ€” call it from a browser or remote agent

uv run worker-agent --transport sse --port 8001

Cloning a New Worker

  1. Copy the whole folder:
    cp -r Agent_a Agent_researcher
    
  2. Edit only config.yaml in the copy:
    • Change agent.name, agent.description, agent.system_prompt
    • Swap out mcp_clients for the tools this worker needs
    • Change server.port so it doesn't conflict
  3. Install & run:
    cd Agent_researcher
    uv sync
    uv run worker-agent
    

Example Worker Configs

File Specialist

agent:
  name: "FileMaster"
  description: "A specialized worker that organizes files and manages directory structures."
  system_prompt: "You are an expert at organizing and refactoring local files."
mcp_clients:
  - name: "filesystem-server"
    command: "npx"
    args:
      ["-y", "@modelcontextprotocol/server-filesystem", "C:/Users/Dev/Project"]

Web Researcher

agent:
  name: "SearchPro"
  description: "A research agent to summarize technical documentation found on the web."
  system_prompt: "You specialize in deep web research and summarizing technical docs."
model:
  provider: "openai"
  model_name: "gpt-4o-mini"
  api_key: "sk-..."
mcp_clients:
  - name: "brave-search"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-brave-search"]

Local Python MCP Server

mcp_clients:
  - name: "my-server"
    command: "python"
    args: ["D:/DEV/mcp/server.py"]

How the Main Agent Calls This Worker

In your Main Agent's MCP config:

{
  "mcpServers": {
    "file-worker": {
      "command": "uv",
      "args": ["--directory", "D:/DEV/mcp/Agent_a", "run", "worker-agent"]
    }
  }
}

Dynamic Configuration (Multiple Workers)

If your Main Agent needs multiple specialized workers, you do not need to clone the entire repository multiple times. You can create several configuration YAML files (e.g., web_worker.yaml, file_worker.yaml) and pass them dynamically using the WORKER_AGENT_CONFIG environment variable.

{
  "mcpServers": {
    "web-worker": {
      "command": "uv",
      "args": ["--directory", "D:/DEV/mcp/Agent_a", "run", "worker-agent"],
      "env": {
        "WORKER_AGENT_CONFIG": "D:/DEV/mcp/Agent_a/web_worker.yaml"
      }
    },
    "file-worker": {
      "command": "uv",
      "args": ["--directory", "D:/DEV/mcp/Agent_a", "run", "worker-agent"],
      "env": {
        "WORKER_AGENT_CONFIG": "D:/DEV/mcp/Agent_a/file_worker.yaml"
      }
    }
  }
}

Or run it directly with uvx and an environment variable if the package is published:

# Linux/macOS
WORKER_AGENT_CONFIG="./custom_config.yaml" uvx worker-agent

# Windows (PowerShell)
$env:WORKER_AGENT_CONFIG="./custom_config.yaml"; uvx worker-agent

The worker exposes one dynamically named tool based on the agent's configured name (e.g., if the name is "SearchPro", the tool will be execute_searchpro_task):

  • execute_<agent_name>_task(instruction: str) โ†’ str

This dynamic naming prevents tool collisions when the Main Agent orchestrates multiple specialized workers simultaneously. The Main Agent calls it like any other MCP tool. The worker handles reasoning, tool use, and error recovery internally, returning only the final result.


Project Structure

Agent_a/
โ”œโ”€โ”€ config.yaml           โ† The only file you edit per clone
โ”œโ”€โ”€ main.py               โ† MCP bridge (FastMCP)
โ”œโ”€โ”€ pyproject.toml         โ† All deps & build config (hatchling)
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ core/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ agent.py          โ† LangGraph ReAct loop
    โ””โ”€โ”€ config_loader.py  โ† YAML โ†’ typed dataclasses

Development Commands

# Install in dev mode with all extras
uv sync --all-extras

# Run from the project directory
uv run worker-agent
uv run worker-agent --transport sse --port 8001

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

worker_agent-1.0.8.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

worker_agent-1.0.8-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file worker_agent-1.0.8.tar.gz.

File metadata

  • Download URL: worker_agent-1.0.8.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for worker_agent-1.0.8.tar.gz
Algorithm Hash digest
SHA256 7a97a4db597465830ecee6daa06c507b1e3a89e5fdf2cb0a82389c8879de0532
MD5 ecb4094c294ccfd74dcc82ee7d966f88
BLAKE2b-256 3bfb92f898f5c4b53a7e8b4d50147218bddcee4d41cf87a1ad9c4779fe4edade

See more details on using hashes here.

File details

Details for the file worker_agent-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: worker_agent-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for worker_agent-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 754c61787c6d86f31330b3ebffb1dd256152b1e71185dbb6a2ecbb3c576fedea
MD5 508ee4917887f14fe9f73683a9ca432a
BLAKE2b-256 69d581cd77c8efcb9fbf49237ba08cdd183d91548cdfa251433106758b5e94fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page