worker-agent 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- worker_agent-1.0.3/.gitignore +207 -0
- worker_agent-1.0.3/LICENSE +21 -0
- worker_agent-1.0.3/PKG-INFO +307 -0
- worker_agent-1.0.3/README.md +256 -0
- worker_agent-1.0.3/config.yaml +54 -0
- worker_agent-1.0.3/core/__init__.py +3 -0
- worker_agent-1.0.3/core/agent.py +344 -0
- worker_agent-1.0.3/core/config_loader.py +159 -0
- worker_agent-1.0.3/core/job_logger.py +198 -0
- worker_agent-1.0.3/main.py +134 -0
- worker_agent-1.0.3/py.typed +0 -0
- worker_agent-1.0.3/pyproject.toml +182 -0
- worker_agent-1.0.3/sample_main_agent.py +311 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tharindumendis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: worker-agent
|
|
3
|
+
Version: 1.0.3
|
|
4
|
+
Summary: A config-driven, plug-and-play worker agent template built on LangGraph + FastMCP.
|
|
5
|
+
Project-URL: Source, https://github.com/tharindumendis/worker_agent_template
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/tharindumendis/worker_agent_template/issues
|
|
7
|
+
Project-URL: Documentation, https://github.com/tharindumendis/worker_agent_template#readme
|
|
8
|
+
Author: Tharindumendis
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent,autonomous-agent,fastmcp,langchain,langgraph,llm,mcp,ollama,react-agent,worker-agent
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: fastmcp>=0.4.0
|
|
27
|
+
Requires-Dist: langchain-community>=0.3.0
|
|
28
|
+
Requires-Dist: langchain-core>=0.3.0
|
|
29
|
+
Requires-Dist: langchain-google-genai>=1.0.0
|
|
30
|
+
Requires-Dist: langchain-mcp-adapters>=0.1.0
|
|
31
|
+
Requires-Dist: langchain-ollama>=0.2.0
|
|
32
|
+
Requires-Dist: langchain-openai>=0.1.0
|
|
33
|
+
Requires-Dist: langchain>=0.3.0
|
|
34
|
+
Requires-Dist: langgraph>=0.2.0
|
|
35
|
+
Requires-Dist: mcp-server-shell>=0.1.0
|
|
36
|
+
Requires-Dist: mcp>=1.0.0
|
|
37
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
38
|
+
Requires-Dist: pyyaml>=6.0
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
41
|
+
Requires-Dist: pre-commit>=3.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
45
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
46
|
+
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
47
|
+
Provides-Extra: release
|
|
48
|
+
Requires-Dist: build>=1.0; extra == 'release'
|
|
49
|
+
Requires-Dist: twine>=5.0; extra == 'release'
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
# 🤖 Universal Worker Agent Template
|
|
53
|
+
|
|
54
|
+
A **config-driven, plug-and-play worker agent** template.
|
|
55
|
+
Clone the folder, edit `config.yaml`, and you have a brand new specialized agent — no code changes needed.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Architecture
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
┌─────────────────────────────────────────────┐
|
|
63
|
+
│ Main Agent │
|
|
64
|
+
│ (calls workers via MCP tool calls) │
|
|
65
|
+
└───────────────────┬─────────────────────────┘
|
|
66
|
+
│ MCP (stdio / SSE)
|
|
67
|
+
┌─────────▼──────────┐
|
|
68
|
+
│ main.py │ ◄─── FastMCP bridge
|
|
69
|
+
│ execute_task(...) │ exposes 1 tool
|
|
70
|
+
└─────────┬──────────┘
|
|
71
|
+
│ asyncio
|
|
72
|
+
┌─────────▼──────────┐
|
|
73
|
+
│ core/agent.py │ ◄─── LangGraph ReAct loop
|
|
74
|
+
│ LangGraph + Ollama │
|
|
75
|
+
└─────────┬──────────┘
|
|
76
|
+
│ MCP clients (stdio)
|
|
77
|
+
┌───────────┼───────────┐
|
|
78
|
+
┌────▼────┐ ┌───▼────┐ ┌──▼──────┐
|
|
79
|
+
│FS Server│ │ Web │ │ Custom │
|
|
80
|
+
│ (npx) │ │ Search │ │ Server │
|
|
81
|
+
└─────────┘ └────────┘ └─────────┘
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
| Component | File | Responsibility |
|
|
85
|
+
| ------------- | ----------------------- | -------------------------------------------------------- |
|
|
86
|
+
| Config | `config.yaml` | Defines everything — identity, model, tools, server port |
|
|
87
|
+
| Config loader | `core/config_loader.py` | Parses YAML into typed dataclasses |
|
|
88
|
+
| ReAct Agent | `core/agent.py` | Loads MCP tools, runs LangGraph loop |
|
|
89
|
+
| MCP Bridge | `main.py` | Exposes `execute_task()` as an MCP server |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Quick Start
|
|
94
|
+
|
|
95
|
+
### 1. Install `uv` (if not already installed)
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Windows (PowerShell)
|
|
99
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
100
|
+
|
|
101
|
+
# macOS / Linux
|
|
102
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. Install dependencies
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
uv sync
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This creates a `.venv` and installs all dependencies from `pyproject.toml` automatically.
|
|
112
|
+
|
|
113
|
+
For development extras (ruff, mypy, pytest):
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
uv sync --all-extras
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 3. Configure your agent
|
|
120
|
+
|
|
121
|
+
Edit **`config.yaml`** — the only file you need to touch:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
agent:
|
|
125
|
+
name: "FileMaster"
|
|
126
|
+
description: "A specialized worker that organizes files and manages directory structures."
|
|
127
|
+
system_prompt: "You are an expert at organizing and refactoring local files."
|
|
128
|
+
|
|
129
|
+
model:
|
|
130
|
+
model_name: "llama3.2" # any model loaded in Ollama
|
|
131
|
+
|
|
132
|
+
mcp_clients:
|
|
133
|
+
- name: "filesystem-server"
|
|
134
|
+
command: "npx"
|
|
135
|
+
args:
|
|
136
|
+
["-y", "@modelcontextprotocol/server-filesystem", "C:/Users/Dev/Project"]
|
|
137
|
+
|
|
138
|
+
server:
|
|
139
|
+
transport: "stdio" # or "sse"
|
|
140
|
+
port: 8001
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 4. Run as a subprocess (stdio) — standard MCP
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
uv run worker-agent
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 5. Run as an HTTP server (SSE) — call it from a browser or remote agent
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
uv run worker-agent --transport sse --port 8001
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Cloning a New Worker
|
|
158
|
+
|
|
159
|
+
1. Copy the whole folder:
|
|
160
|
+
```bash
|
|
161
|
+
cp -r Agent_a Agent_researcher
|
|
162
|
+
```
|
|
163
|
+
2. Edit only `config.yaml` in the copy:
|
|
164
|
+
- Change `agent.name`, `agent.description`, `agent.system_prompt`
|
|
165
|
+
- Swap out `mcp_clients` for the tools this worker needs
|
|
166
|
+
- Change `server.port` so it doesn't conflict
|
|
167
|
+
3. Install & run:
|
|
168
|
+
```bash
|
|
169
|
+
cd Agent_researcher
|
|
170
|
+
uv sync
|
|
171
|
+
uv run worker-agent
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Example Worker Configs
|
|
177
|
+
|
|
178
|
+
### File Specialist
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
agent:
|
|
182
|
+
name: "FileMaster"
|
|
183
|
+
description: "A specialized worker that organizes files and manages directory structures."
|
|
184
|
+
system_prompt: "You are an expert at organizing and refactoring local files."
|
|
185
|
+
mcp_clients:
|
|
186
|
+
- name: "filesystem-server"
|
|
187
|
+
command: "npx"
|
|
188
|
+
args:
|
|
189
|
+
["-y", "@modelcontextprotocol/server-filesystem", "C:/Users/Dev/Project"]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Web Researcher
|
|
193
|
+
|
|
194
|
+
```yaml
|
|
195
|
+
agent:
|
|
196
|
+
name: "SearchPro"
|
|
197
|
+
description: "A research agent to summarize technical documentation found on the web."
|
|
198
|
+
system_prompt: "You specialize in deep web research and summarizing technical docs."
|
|
199
|
+
model:
|
|
200
|
+
model_name: "mistral"
|
|
201
|
+
mcp_clients:
|
|
202
|
+
- name: "brave-search"
|
|
203
|
+
command: "npx"
|
|
204
|
+
args: ["-y", "@modelcontextprotocol/server-brave-search"]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Local Python MCP Server
|
|
208
|
+
|
|
209
|
+
```yaml
|
|
210
|
+
mcp_clients:
|
|
211
|
+
- name: "my-server"
|
|
212
|
+
command: "python"
|
|
213
|
+
args: ["D:/DEV/mcp/server.py"]
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## How the Main Agent Calls This Worker
|
|
219
|
+
|
|
220
|
+
In your Main Agent's MCP config:
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"mcpServers": {
|
|
225
|
+
"file-worker": {
|
|
226
|
+
"command": "uv",
|
|
227
|
+
"args": ["--directory", "D:/DEV/mcp/Agent_a", "run", "worker-agent"]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Dynamic Configuration (Multiple Workers)
|
|
234
|
+
|
|
235
|
+
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.
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"mcpServers": {
|
|
240
|
+
"web-worker": {
|
|
241
|
+
"command": "uv",
|
|
242
|
+
"args": ["--directory", "D:/DEV/mcp/Agent_a", "run", "worker-agent"],
|
|
243
|
+
"env": {
|
|
244
|
+
"WORKER_AGENT_CONFIG": "D:/DEV/mcp/Agent_a/web_worker.yaml"
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
"file-worker": {
|
|
248
|
+
"command": "uv",
|
|
249
|
+
"args": ["--directory", "D:/DEV/mcp/Agent_a", "run", "worker-agent"],
|
|
250
|
+
"env": {
|
|
251
|
+
"WORKER_AGENT_CONFIG": "D:/DEV/mcp/Agent_a/file_worker.yaml"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Or run it directly with `uvx` and an environment variable if the package is published:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Linux/macOS
|
|
262
|
+
WORKER_AGENT_CONFIG="./custom_config.yaml" uvx worker-agent
|
|
263
|
+
|
|
264
|
+
# Windows (PowerShell)
|
|
265
|
+
$env:WORKER_AGENT_CONFIG="./custom_config.yaml"; uvx worker-agent
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The worker exposes one tool:
|
|
269
|
+
|
|
270
|
+
- **`execute_task(instruction: str) → str`**
|
|
271
|
+
|
|
272
|
+
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.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Project Structure
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
Agent_a/
|
|
280
|
+
├── config.yaml ← The only file you edit per clone
|
|
281
|
+
├── main.py ← MCP bridge (FastMCP)
|
|
282
|
+
├── pyproject.toml ← All deps & build config (hatchling)
|
|
283
|
+
├── README.md
|
|
284
|
+
└── core/
|
|
285
|
+
├── __init__.py
|
|
286
|
+
├── agent.py ← LangGraph ReAct loop
|
|
287
|
+
└── config_loader.py ← YAML → typed dataclasses
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Development Commands
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Install in dev mode with all extras
|
|
296
|
+
uv sync --all-extras
|
|
297
|
+
|
|
298
|
+
# Run from the project directory
|
|
299
|
+
uv run worker-agent
|
|
300
|
+
uv run worker-agent --transport sse --port 8001
|
|
301
|
+
|
|
302
|
+
# Build a distributable wheel + sdist
|
|
303
|
+
uv build
|
|
304
|
+
|
|
305
|
+
# Publish to PyPI
|
|
306
|
+
uv publish
|
|
307
|
+
```
|