Polyagent is a Claude Code native research and execution environment for Polymarket.
The repository is organized around three rules:
Claude Codeowns research, synthesis, and order expressionMCP serversexpose capability without embedding strategy opinionAPIs and UIpersist artifacts, runtime state, schedules, and replayable execution records
services/artifact-apiStructured journal for artifacts, linked sessions, and execution records.services/artifact-mcpThin MCP wrapper overartifact-apiso Claude can read and write journal state directly.services/supervisorSession orchestration layer that runs the nativeclaudeCLI with persistent session ids, cron schedules, and trigger records.services/supervisor-mcpThin MCP wrapper oversupervisorso Claude can manage sessions, schedules, and trigger programs directly.services/polymarket-mcpThin MCP server that wraps Polymarket Gamma/CLOB reads and live order operations.apps/audit-uiMobile-aware research terminal for theses, sessions, schedules, triggers, and execution journals..claudeProject policy layer for skills, commands, agents, and memory.
supervisorinvokesclaude -pwith persistent--session-idvalues.- Docker
supervisorruns as a non-root user so Claude Code can usebypassPermissionswith--dangerously-skip-permissions. .mcp.jsonand.mcp.docker.jsonmount the local MCP servers into those Claude sessions.- Schedules are infra-level cron jobs; prompts remain agent-defined.
- The codebase does not contain a backend-owned alpha engine.
services/supervisorOwns Claude Code session lifecycle, prompt dispatch, cron schedules, trigger metadata, and runtime health.services/artifact-apiOwns durable structured state forartifact,research_session, andexecution_record.
services/artifact-mcpClaude-facing MCP server for journal operations.services/supervisor-mcpClaude-facing MCP server for session lifecycle, schedule management, and trigger programming.services/polymarket-mcpThin MCP tool server for Polymarket market reads and live order actions.- future MCPs News, macro, Tiingo, social, or other context providers should follow the same MCP pattern instead of being embedded into app logic.
Claude CodeRuns as the research and decision engine..claude/agentsSpecialized subagents such as research, skepticism, and order planning..claude/skillsReusable policy and workflow guidance..claude/commandsOperator-facing project commands.
apps/audit-uiResearch terminal for theses, session state, schedules, triggers, and execution replay.
supervisorstarts or resumes a Claude Code session.- Claude Code loads MCP config and can call
artifact-mcp,supervisor-mcp, andpolymarket-mcp. - Claude or operator flows write artifacts and execution records into
artifact-api. audit-uireadsartifact-apiandsupervisorto present the current system state.
+----------------------+
| Claude Code |
| skills / agents / |
| commands / memory |
+----------+-----------+
|
loads `.mcp.json` / `.mcp.docker.json`
|
+-------------------+-------------------+-------------------+
| | | |
v v v v
+----------------------+ +----------------------+ +----------------------+ +----------------------+
| artifact-mcp | | supervisor-mcp | | polymarket-mcp | | future MCPs |
| journal tools | | lifecycle / triggers | | Gamma / CLOB tools | | news / Tiingo / etc. |
+----------+-----------+ +----------+-----------+ +----------+-----------+ +----------------------+
| | |
+-------------+------------+------------------------+
|
v
+----------------------+ +----------------------+
| supervisor |<----->| artifact-api |
| sessions / prompts / | | artifacts / journal /|
| schedules / triggers | | execution records |
+----------+-----------+ +----------+-----------+
| |
+---------------+---------------+
|
v
+----------------------+
| audit-ui |
| thesis + session + |
| execution terminal |
+----------------------+
Copy .env.example to .env and set at minimum:
DATABASE_URL
Claude credentials:
- direct Anthropic API:
ANTHROPIC_API_KEY
- gateway / proxy / custom bearer auth:
ANTHROPIC_AUTH_TOKENANTHROPIC_BASE_URL
Supervisor runtime:
CLAUDE_PERMISSION_MODECLAUDE_DANGEROUSLY_SKIP_PERMISSIONSCLAUDE_MCP_CONFIG_PATHSUPERVISOR_UIDSUPERVISOR_GID
For Polymarket live tools:
POLY_DATA_API_URL: override for Data API if needed.POLY_PRIVATE_KEY: L1 signer private key used to sign auth payloads and orders.POLY_API_KEY,POLY_SECRET,POLY_PASSPHRASE: CLOB L2 API credentials.POLY_SIGNATURE_TYPE: wallet mode for the signer.0=EOA,1=POLY_PROXY,2=GNOSIS_SAFE.POLY_ADDRESS: wallet / funder address used by this repo for default position queries.POLY_FUNDER: set this explicitly when the funded proxy/safe address differs from the signer key.POLY_ALLOW_LIVE_TRADING=true: hard switch for write tools.
Notes:
- In proxy/safe setups, the address visible in Polymarket is usually the wallet/funder, not the raw signer.
- This repo does not currently use Polymarket Builder / Relayer credentials. Those are separate from the CLOB user credentials above.
docker compose up --buildServices:
artifact-apion:8080artifact-mcpon:8802polymarket-mcpon:8801supervisoron:8081supervisor-mcpon:8803audit-uion:4174by default
Docker runtime notes:
supervisordefaults toCLAUDE_PERMISSION_MODE=bypassPermissionsCLAUDE_DANGEROUSLY_SKIP_PERMISSIONS=trueis expected for the dedicated containerized runtime- the container runs as a non-root user and persists Claude home state in the
supervisor-homevolume - if your host uid/gid is not
1000:1000, setSUPERVISOR_UIDandSUPERVISOR_GIDin.envbefore build
MCP services run as standalone HTTP MCP services:
- local Claude Code uses .mcp.json
- Docker supervisor uses .mcp.docker.json
artifact-mcpdefault endpoint ishttp://127.0.0.1:8802/mcpsupervisor-mcpdefault endpoint ishttp://127.0.0.1:8803/mcppolymarket-mcpdefault endpoint ishttp://127.0.0.1:8801/mcppolymarket-mcpcurrent tool surface is 64 tools, including raw Gamma/Data/CLOB wrappers plus curated discovery, pricing, positions, and order-management tools
For environments that should not build locally, use the image-based compose file:
docker compose -f docker-compose.images.yml up -dRequired env:
POLYAGENT_IMAGE_NAMESPACEPOLYAGENT_IMAGE_TAG
The image tags are intended to match the Docker Hub publish workflow in .github/workflows/docker-publish.yml.
Published image names:
polyagent-artifact-apipolyagent-artifact-mcppolyagent-polymarket-mcppolyagent-supervisorpolyagent-supervisor-mcppolyagent-audit-ui
cp .env.example .envFill one Claude auth mode:
- direct Anthropic:
ANTHROPIC_API_KEY
- gateway / proxy:
ANTHROPIC_AUTH_TOKENANTHROPIC_BASE_URL
If you want the web UI to force a login page before entering the app, also set:
AUTH_ENABLED=trueAUTH_JWT_SECRET=<long random secret>AUTH_OPERATOR_USERNAME=<operator username>AUTH_OPERATOR_PASSWORD_HASH=<pbkdf2 hash>
Generate the password hash with:
cd services/supervisor
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run python -c "from passlib.hash import pbkdf2_sha256; print(pbkdf2_sha256.hash('change-me'))"Python services use pytest; the frontend uses vitest.
Run backend tests:
cd services/supervisor && uv sync --locked --dev && uv run pytest
cd services/artifact-api && uv sync --locked --dev && uv run pytest
cd services/polymarket-mcp && uv sync --locked --dev && uv run pytestRun frontend tests:
cd apps/audit-ui
npm ci
npm run test
npm run buildGitHub Actions:
- test.yml Runs Python tests, frontend tests, and validates both compose files.
- docker-publish.yml Builds and pushes all runtime images to Docker Hub.
Runtime behavior:
- when
AUTH_ENABLED=true, unauthenticated users are redirected to/auth POST /api/v1/auth/loginreturns a JWT bearer token- the UI stores that token in browser
sessionStorage supervisorandartifact-apirequireAuthorization: Bearer <token>on protected routes
artifact-api
cd services/artifact-api
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run uvicorn app.main:app --host 0.0.0.0 --port 8080supervisor
cd services/supervisor
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run uvicorn app.main:app --host 0.0.0.0 --port 8081artifact-mcp
cd services/artifact-mcp
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run python -m app.mainsupervisor-mcp
cd services/supervisor-mcp
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run python -m app.mainpolymarket-mcp
cd services/polymarket-mcp
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run python -m app.mainaudit-ui
cd apps/audit-ui
npm install
npm run devYes. For inner-loop development, local terminal debugging is the preferred path.
You do not need to go through supervisor just to test MCP wiring, prompts, skills, or .claude policy. Run Claude Code directly from the repo root so it picks up:
CLAUDE.md.claude/agents.claude/skills.claude/commands.mcp.json
Important: .mcp.json is now an HTTP MCP config, not a stdio autostart config.
That means Claude Code will try to connect to all configured MCP endpoints; it will not start any of them for you.
Start the MCP services you want to expose first:
cd /home/bryantsuen/workspace/finance/polyagent/services/artifact-mcp
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run python -m app.main
cd /home/bryantsuen/workspace/finance/polyagent/services/supervisor-mcp
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run python -m app.main
cd /home/bryantsuen/workspace/finance/polyagent/services/polymarket-mcp
UV_CACHE_DIR=/tmp/uv-cache uv sync --locked
uv run python -m app.mainInteractive debugging:
cd /home/bryantsuen/workspace/finance/polyagent
claude --mcp-config .mcp.json --add-dir /home/bryantsuen/workspace/finance/polyagentNon-interactive prompt test:
cd /home/bryantsuen/workspace/finance/polyagent
claude -p "Search Polymarket markets about Fed cuts and summarize the top candidates." \
--mcp-config .mcp.json \
--add-dir /home/bryantsuen/workspace/finance/polyagent \
--setting-sources project,local \
--permission-mode dontAskUseful local debug targets:
- MCP wiring:
ask Claude to call
list_artifacts,list_managed_sessions, orsearch_markets - policy wiring:
run project commands in
.claude/commands - subagent wiring: ask Claude to delegate to one of the project agents
- supervisor parity:
compare local
claude -p ... --session-id ...behavior withsupervisor
Use supervisor when you want:
- persistent managed sessions
- HTTP prompt dispatch
- schedules
- trigger metadata
- audit UI integration