mcp-ai-workforce
Can be integrated as an MCP client in the Windsurf editor to use the autonomous worker for delegating coding tasks to cost-effective models.
Provides git diff auditing capabilities to review and verify changes made by the autonomous worker in the workspace repository.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-ai-workforce Write unit tests for the auth module using a cost-efficient model."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP AI Workforce
Autonomous Model Context Protocol Server for Cost-Effective AI Coding Delegation
Empower primary AI orchestrators to delegate token-heavy coding tasks to economical models via OpenRouter, reducing token expenditure by up to 95%.
Key Features | Architecture | Quickstart | Client Integrations | Tools Reference | Security
The Problem and The Solution
The Problem
Frontier AI models (Claude 3.7 Sonnet, Claude Opus, Gemini 2.5 Pro, GPT-4o) cost anywhere from $3.00 to $50.00+ per million tokens. Using these elite models for tasks such as writing repetitive test suites, formatting JSON payloads, generating boilerplate, or fixing syntactic linter errors consumes valuable context windows and leads to high operational costs.
The Solution
mcp-ai-workforce is an open-source Model Context Protocol (MCP) server that establishes a two-tier delegation architecture:
The Orchestrator: The primary AI client (Claude Desktop, Google Antigravity, or Cursor) manages high-level architecture, breaks down engineering goals, and audits changes.
The Autonomous Worker: The orchestrator invokes
workforce_delegate.mcp-ai-workforceexecutes a sandboxed ReAct loop powered by cost-effective coding models (such as Qwen 2.5 Coder 32B or DeepSeek V4 via OpenRouter at approximately $0.20 to $0.50 per million tokens).The Audit: When execution completes, the orchestrator inspects the unified Git diff (
workforce_audit_diff), conducts automated or manual code reviews, and approves the changes.
Related MCP server: claude-openrouter-delegate-mcp
Key Features
Cost Optimization: Offload routine code generation to economical models while reserving frontier reasoning models for architectural oversight.
Zero-Trust Security Sandbox:
Path Confinement: Validates canonical paths against the configured root directory to prevent directory traversal (
../../) and unauthorized filesystem access.Credential Shielding (CWE-522): Prohibits the worker from accessing or modifying
.env*files, server source code, and cryptographic private keys.RCE-Immune Git Auditing (CWE-78): Enforces sanitized flags (
--no-ext-diff) to prevent arbitrary command execution via.git/config.
Autonomous ReAct Worker Loop: Provides controlled filesystem operations (
read_file,write_file,list_dir) with built-in infinite-loop detection and configurable step and timeout budgets.Universal Client Support: Compatible with Claude Desktop, Cursor IDE, Google Antigravity, Windsurf, and any standard MCP client across macOS, Linux, and Windows.
Automated Test Coverage: Verified with 32 unit and integration tests executing across Python 3.10, 3.11, and 3.12 in continuous integration.
Architecture
sequenceDiagram
autonumber
actor User as Developer
participant Orchestrator as Primary AI (Claude / Antigravity / Cursor)
participant Server as mcp-ai-workforce (FastMCP)
participant Provider as OpenRouter (Qwen / DeepSeek)
participant Workspace as Local Repository / Workspace
User->>Orchestrator: Implement unit tests for authentication module
Orchestrator->>Server: workforce_delegate(task_prompt, model="qwen/qwen-2.5-coder-32b-instruct")
activate Server
Note over Server: Security Sandbox & Guardrails Active
loop Autonomous ReAct Loop (max 15 steps)
Server->>Provider: Send context and available tools
Provider-->>Server: Tool call (read_file / write_file)
Server->>Workspace: Execute safe filesystem operation
Workspace-->>Server: Operation result
end
Server-->>Orchestrator: Return task summary report
deactivate Server
Orchestrator->>Server: workforce_audit_diff()
Server-->>Orchestrator: Return sanitized git diff
Note over Orchestrator: Code review and verification
Orchestrator-->>User: Implementation complete and verifiedQuickstart
Prerequisites
Python 3.10 or higher.
Git installed and available on system PATH.
An OpenRouter API key.
1. Clone and Set Up Environment
# Clone the repository
git clone https://github.com/DevImperatore/mcp-ai-workforce.git
cd mcp-ai-workforce
# Create and activate a virtual environment
# On macOS / Linux:
python3 -m venv .venv
source .venv/bin/activate
# On Windows:
python -m venv .venv
.\.venv\Scripts\activate
# Install in editable mode (registers the 'mcp-ai-workforce' CLI command)
pip install -e .
# Or install dependencies from requirements.txt
pip install -r requirements.txt2. Configure Environment Variables
Copy the template .env.example to .env:
cp .env.example .envEdit .env:
# OpenRouter API Key
OPENROUTER_API_KEY=sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Default model for worker tasks
DEFAULT_MODEL=qwen/qwen-2.5-coder-32b-instruct
# Canonical workspace path (defaults to current working directory if omitted)
WORKSPACE_ROOT=/path/to/your/project
# Execution limits
MAX_STEPS=15
TIMEOUT_SECONDS=300Client Integrations
The server can be executed directly via its entry point command (mcp-ai-workforce), via uvx / pipx, or by referencing the virtual environment Python interpreter.
Claude Desktop
Add the following entry to claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ai-workforce": {
"command": "mcp-ai-workforce",
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-xxxxxxxxxxxxxxxx"
}
}
}
}Or using an explicit virtual environment:
{
"mcpServers": {
"ai-workforce": {
"command": "/path/to/mcp-ai-workforce/.venv/bin/python",
"args": ["-m", "src.server"],
"cwd": "/path/to/mcp-ai-workforce",
"env": {
"PYTHONUTF8": "1"
}
}
}
}Note: On Windows, use .venv\\Scripts\\python.exe with properly escaped backslashes.
Cursor IDE
Configure through .cursor/mcp.json or through Cursor Settings:
Open Cursor Settings (
Ctrl + Shift + JorCmd + Shift + J).Navigate to Features > MCP.
Select Add New MCP Server:
Name:
ai-workforceType:
commandCommand:
mcp-ai-workforce(or/path/to/mcp-ai-workforce/.venv/bin/python -m src.server)
Or add directly to .cursor/mcp.json:
{
"mcpServers": {
"ai-workforce": {
"command": "mcp-ai-workforce",
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-xxxxxxxxxxxxxxxx"
}
}
}
}Google Antigravity
Add the server configuration to ~/.gemini/config/mcp_config.json:
{
"mcpServers": {
"ai-workforce": {
"command": "mcp-ai-workforce",
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-xxxxxxxxxxxxxxxx"
}
}
}
}Or using virtual environment paths:
{
"mcpServers": {
"ai-workforce": {
"command": "/path/to/mcp-ai-workforce/.venv/bin/python",
"args": ["-m", "src.server"],
"cwd": "/path/to/mcp-ai-workforce",
"env": {
"PYTHONUTF8": "1"
}
}
}
}Windsurf (Codeium)
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"ai-workforce": {
"command": "mcp-ai-workforce",
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-xxxxxxxxxxxxxxxx"
}
}
}
}Or using explicit Python path:
{
"mcpServers": {
"ai-workforce": {
"command": "/path/to/mcp-ai-workforce/.venv/bin/python",
"args": ["-m", "src.server"],
"cwd": "/path/to/mcp-ai-workforce",
"env": {
"PYTHONUTF8": "1"
}
}
}
}Tools Reference
Tool Name | Parameters | Description |
|
| Dispatches an autonomous ReAct worker agent to inspect, modify, and create workspace files under strict security guardrails. |
| None | Reports API key connectivity, canonical workspace root path, execution limits, and recommended models. |
|
| Executes a non-blocking git diff across the repository to inspect all changes generated by the worker. |
Security and Sandboxing
The autonomous worker executes within a zero-trust sandbox:
Path Jail (
validate_safe_path):Canonicalizes and normalizes all target paths against
WORKSPACE_ROOT.Rejects directory traversal attempts (
../,..\\, symlink redirection).Blocks access to system directories (
/etc,C:\Windows, etc.).
Credential and Secrets Protection:
Strictly blocks access to
.env*,.git/,.agents/mcp-ai-workforce/, and private keys (.pem,.key,id_rsa).
Execution Guardrails:
Infinite Loop Detection: Halts execution if identical tool signatures are called 3 consecutive times.
Resource Limits: Enforces step bounds (
MAX_STEPS) and hard timeouts (TIMEOUT_SECONDS) to prevent runaway API consumption.
Example Prompts
Once configured, invoke tasks in natural language via your primary AI interface:
"Please delegate to the workforce the task of writing comprehensive pytest
unit tests for 'src/services/auth.py'. Once the worker finishes, call
workforce_audit_diff to verify the changes.""Use workforce_delegate with model 'deepseek/deepseek-chat' to refactor
all utility functions in 'utils/formatter.py' by adding full type annotations
and Google-style docstrings."Running Tests
The test suite covers OpenRouter API mocks, path traversal defenses, loop traps, and FastMCP tool endpoints.
pytest -v============================= test session starts =============================
platform win32 / linux -- Python 3.10+ -- pytest-9.1.1
collected 32 items
tests/test_agent_loop.py::test_execute_tool_read_and_write PASSED [ 3%]
tests/test_agent_loop.py::test_execute_tool_guardrail_protection PASSED [ 6%]
tests/test_agent_loop.py::test_infinite_loop_detector PASSED [ 9%]
tests/test_agent_loop.py::test_agent_max_steps_limit PASSED [ 12%]
tests/test_agent_loop.py::test_agent_normal_completion PASSED [ 15%]
tests/test_fs_tools.py::test_worker_write_and_read_file PASSED [ 18%]
...
tests/test_server.py::test_workforce_delegate_success PASSED [ 81%]
tests/test_worker_loop.py::test_worker_loop_successful_termination PASSED [100%]
============================= 32 passed in 2.80s ==============================License
This project is licensed under the MIT License. See the LICENSE file for details.
Developed by DevImperatore
Available Tools
3 toolsworkforce_audit_diffA
Execute a git diff inspection across the workspace to audit worker modifications.
Args:
staged: If True, inspect staged changes (git diff --staged);
otherwise inspect unstaged workspace modifications (git diff).
Returns: str: The unified git diff output or an informative message if no changes exist.
Inputs: staged. Returns: result
workforce_delegateA
Delegate a software engineering task to an autonomous ReAct worker agent.
The worker operates with filesystem tools under strict guardrails to inspect, read, modify, and create workspace files safely.
Args: task_prompt: Comprehensive description of the task or feature to implement. target_files: Optional list of relevant workspace-relative file paths. model: OpenRouter model to utilize (defaults to DEFAULT_MODEL). timeout_seconds: Execution timeout limit in seconds (default: 300).
Returns: str: Final completion summary or diagnostic output from the worker agent.
Inputs: task_prompt (required), model, target_files, timeout_seconds. Returns: result
workforce_models_statusA
Inspect current configuration, supported models, and OpenRouter readiness.
Returns: Dict[str, Any]: Configuration status including API key presence, default model, configured workspace root, and suggested coding models.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a distinct function: workforce_delegate executes tasks, workforce_audit_diff reviews changes, and workforce_models_status checks configuration. There is no meaningful overlap or ambiguity between them.
All tools share a consistent workforce_ prefix and snake_case style. The final word pattern varies slightly—verb-object, bare verb, and noun phrase—but the naming remains predictable and readable.
Three tools is well within the ideal well-scoped range, and each tool supports a clear step in the delegate-audit-status workflow. None feel redundant or unnecessary.
The server covers a coherent end-to-end workflow: readiness check, task delegation, and post-work audit. It lacks live progress tracking or cancellation, but the timeout and final summary provide reasonable workarounds.
Maintenance
Related MCP Connectors
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Autonomous AI developers on your own infrastructure: assign a task, get a pull request.
BYOK AI router & FinOps control plane: audit token waste, check tool safety, and rank models.
Run AI agent tasks in isolated sandboxes with a cost cap, saved workflows and scoped connections.
Related MCP Servers
- AlicenseAqualityDmaintenanceLets your primary coding agent delegate grunt work to a cheaper model via OpenCode, enabling cost-effective task distribution.51MIT
- AlicenseAqualityDmaintenanceLets Claude Code delegate tasks to OpenRouter-backed Claude Code sessions in isolated child processes, keeping Anthropic and OpenRouter credentials separate. It adds a model catalog, per-job cost tracking, and API-key management for running tasks on 400+ OpenRouter models.738 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude Code to delegate tasks to free OpenRouter models as callable tools while keeping the Anthropic endpoint for the orchestrator, with optional sandboxed file and shell access.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to delegate tasks to cheaper models via the OpenRouter API, with live pricing, cost-tier auto-selection, and policy-based delegation.87 npmMIT