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:
  model_name: "llama3.2" # any model loaded in Ollama

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:
  model_name: "mistral"
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 tool:

  • execute_task(instruction: str) โ†’ str

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

# Build a distributable wheel + sdist
uv build

# Publish to PyPI
uv publish

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.3.tar.gz (19.2 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.3-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: worker_agent-1.0.3.tar.gz
  • Upload date:
  • Size: 19.2 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.3.tar.gz
Algorithm Hash digest
SHA256 cb81e962f2c95278995acdd5bb6b4c655b4a5dbcc88288c0d1b818c86f4dd48f
MD5 4a25429b0b825030fb1d0143b276f221
BLAKE2b-256 7594410378829e7aec1bc66bdabbb165d37f8cf2f4a515d9692904b06de6586d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: worker_agent-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 19.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8e521bab41c72fc9fc233a315ae6b33d899effba56601b0fd009539ee9da9449
MD5 79cf88ce2a87df74e741efa85f114dba
BLAKE2b-256 571d1f7f49e3a3771b1a6fa7a339535b2e7f357e9a06f76bab905ff44dbab1c4

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