SU
OfficialProductivity

Sugar MCP Server for Claude Code Automation

Automate Claude Code workflows with the Sugar MCP server, enabling task management, specialized agents, and Python CLI-driven autonomous execution.

Overview

Sugar is an open-source Model Context Protocol (MCP) server designed to automate Claude Code workflows. It provides a lightweight HTTP/MCP interface and a Python CLI that let you define tasks, attach specialized agents, and run autonomous or semi-autonomous code-oriented workflows. Sugar is useful when you want to orchestrate multi-step code operations (generate code, run tests, review changes, commit) while keeping the orchestration logic outside of the model itself.

The server implements MCP-compatible endpoints so Claude Code or other MCP-aware models can connect and exchange structured context and actions. Developers use Sugar to manage task state, persist task histories, and hand off subtasks to specialized agents (for example: code-generation, testing, linting, or deployment agents). A small Python client/CLI makes it easy to script or run autonomous task loops from local development environments or CI pipelines.

Features

  • MCP-compatible HTTP server that exposes task and agent endpoints
  • Python client and CLI for creating, listing, and running tasks/agents
  • Task lifecycle management (create, update, status, history)
  • Agent orchestration: register specialized agents and route subtasks
  • Autonomous run mode: CLI-driven loops that execute until task completion
  • Pluggable configuration for model keys, timeouts, and persistence backends
  • Simple JSON-based API suitable for integration with Claude Code or other MCP consumers

Installation / Configuration

Prerequisites:

  • Python 3.10+
  • Git
  • An API key for your model provider (Claude Code or other MCP-capable endpoint)

Quick start:

  1. Clone the repo and create a virtual environment
git clone https://github.com/cdnsteve/sugar.git
cd sugar
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
  1. Configure environment variables (example)
export SUGAR_HOST=0.0.0.0
export SUGAR_PORT=8080
export CLAUDE_API_KEY=your_claude_api_key_here
# Optional: persistence settings, timeouts
export SUGAR_DB_URL=sqlite:///./sugar.db
  1. Run the MCP server
# Start the server (example)
python -m sugar.server
# Or use the provided CLI:
sugar server start --host 0.0.0.0 --port 8080

Example configuration file (YAML)

host: 0.0.0.0
port: 8080
db_url: sqlite:///./sugar.db
model:
  provider: claude
  api_key_env: CLAUDE_API_KEY
agents:
  - name: code-generator
    role: generator
  - name: test-runner
    role: tester

Available Tools

  • Python CLI: sugar
    • Commands: server start, tasks create/list/get, agents register/run, run-autonomy
  • HTTP API endpoints (examples)
    • POST /tasks — create a new task
    • GET /tasks — list tasks
    • GET /tasks/{id} — fetch task status/history
    • POST /agents/{agent_name}/run — request an agent to process a task
  • Python client library (import sugar.client)
    • sugar.client.SugarClient for programmatic access from scripts and CI

CLI quick reference

CommandPurpose
sugar server startLaunch the MCP server
sugar tasks createCreate a new task from CLI
sugar tasks listList all tasks
sugar agents registerRegister a new agent
sugar run-autonomyRun an autonomous loop for a task

Example: create a task via curl

curl -X POST "http://localhost:8080/tasks" \
  -H "Content-Type: application/json" \
  -d '{"title":"Add unit tests","description":"Generate unit tests for module X","priority":"high"}'

Example: Python client usage

from sugar.client import SugarClient

client = SugarClient(base_url="http://localhost:8080", api_key=None)
task = client.create_task(title="Refactor utils", description="Refactor and add tests")
client.run_agent("code-generator", task_id=task["id"])

Use Cases

  1. Automated test generation and execution

    • Use Sugar to create a “generate tests” task, call a code-generator agent to produce test code, then pass the result to a test-runner agent that executes the tests and records results in the task history.
  2. Codebase refactor with CI integration

    • Define a refactor task, have a generator agent propose changes, run a linter/formatter agent, and then a reviewer agent to produce a summary. Use the autonomous run mode in CI to apply, test, and report changes.
  3. Multi-agent code review workflow

    • Register different agents (static analysis, security scan, human reviewer). When a new task (PR or change) appears, route it through agents sequentially and aggregate their outputs into a single task report.
  4. Prototyping autonomous developer agents

    • Experiment with an autonomous loop: create a task like “implement feature X”, set a sequence of agents (plan -> generate -> test -> iterate), and run sugar run-autonomy to let agents drive the workflow until the task reaches a terminal status.

Resources

  • Source code and issues: https://github.com/cdnsteve/sugar
  • Python package entry points and CLI live in the repository (see sugar/cli and sugar/server)
  • Use