Twynity Codex Harness MCP
Integrates with GitHub to check out a configured repository using a fine-grained token, commit changes locally, and publish a dedicated work branch without pushing directly to the default branch.
Integrates with OpenAI's Agents API and managed Codex sessions to start or resume coding sessions, run tasks, and manage model interactions for each authenticated Twyn.
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., "@Twynity Codex Harness MCPhave codex fix the failing tests in src/ and commit the changes"
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.
Twynity Codex Harness MCP
A Twynity MCP server that assigns a long-lived OpenAI-managed Codex session and
isolated workspace to the authenticated Twyn. It follows the
twynity-mcp-project-template
structure for JWT authentication, persona-scoped configuration, encrypted
connections, manifest/schema routes, usage reporting, and licensing.
Version one flow
Twynity sends its JWT and Persona-Id
-> MCP resolves that user's configured repository
-> GitHub token checks out the repo into an opaque per-Twyn workspace
-> OpenAI Agents API creates or resumes the Twyn's Codex session
-> an isolated Docker executor mounts only that workspace
-> publisher pushes commits to the Twyn's dedicated work branchOpenAI's managed harness owns the model/API key. The Docker executor receives a restricted environment key from the same OpenAI project and does not receive the application API key. The GitHub token is used by the MCP service for checkout and branch publishing; it is not passed into the Codex container.
The MVP stores one project/repository per (verified user_id, Persona-Id).
Project names are display labels. Workspace directory names are hashes of the
verified identity pair, never user-provided strings.
Related MCP server: workflow-studio
MCP tools
run_task(task): start or continue the active Twyn's Codex conversation, commit completed changes locally, and publish the work branch.get_task_status(): return only the current Twyn's latest status and branch.
Configure
Install Docker Engine on the Linux host that will run the service. The executor makes outbound connections to OpenAI; no inbound port is opened for it. Create the workspace root and give it to UID 1000 (the service and executor account):
sudo mkdir -p /srv/twynity-workspaces sudo chown 1000:1000 /srv/twynity-workspaces export DOCKER_GID="$(stat -c '%g' /var/run/docker.sock)"Create an OpenAI Platform project API key with
api.agents.read,api.agents.write, andapi.responses.write. Create a separate executor environment key in that same project with only environment-connection permission. Keep both in the server's secret configuration. The API key is never mounted into executor containers.Generate a Fernet encryption key:
uv run python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"Copy
.env.exampleto.envand set the account, license, usage, MongoDB, OpenAI, Docker, and workspace settings.WORKSPACE_ROOTmust be an absolute path visible at the same location to both the MCP process and Docker daemon.Build the isolated executor image:
docker build -f Dockerfile.executor -t twynity-codex-executor:local .Build and start the MCP service with Docker Compose:
docker compose up --build -dCompose mounts the Docker socket into the MCP service so it can create one executor container per Twyn. Restrict access to this MCP service because Docker socket access grants substantial control over the host.
In Twynity's external-connection setup, provide a project name, the
https://github.com/owner/repoURL, and a fine-grained GitHub token with Contents read/write access for that repository. The default branch is read from GitHub unless explicitly supplied. Credentials are encrypted in MongoDB; configuration GET responses expose project metadata only.Add this MCP to Twynity with its standard JWT connection. Twynity must forward the bearer JWT and
Persona-Idheader for both model and MCP App calls, as required by the project template.
The model is configured with CODEX_MODEL (default gpt-6-astra). OpenAI model
availability depends on the shared Platform project. ChatGPT subscriptions and
OpenAI API billing are separate.
Storage and task behavior
project_connectionsstores encrypted GitHub tokens with project metadata, strictly keyed by the verified user and persona.codex_sessionsstores the OpenAI session and executor IDs for that same pair. The session and workspace are reused on subsequent task calls.Workspaces live under
WORKSPACE_ROOT/<opaque-hash>and are mounted into that Twyn's executor only.Codex commits locally. The publisher pushes
HEADto a generated branch namedtwynity/<opaque-hash>; it never pushes directly to the default branch.One task per Twyn runs at a time. Use
get_task_statusto inspect the last run. Branch publication requires the agent to create a local commit.
Operations
Back up MongoDB and the Fernet key together. Losing the key makes saved GitHub tokens unreadable.
Do not log credentials, pass them in tool arguments, or place them in agent instructions. The OpenAI application key and GitHub tokens belong only in trusted server-side storage/configuration.
Executor containers persist across requests to preserve Codex session state. Workspace and container cleanup/retention policy should be configured before exposing the service broadly.
The initial executor image uses the Codex CLI alpha package because the self-hosted Agents API currently uses
codex exec-server; pin a tested release before production rollout.
Template adaptation
app/auth.pyverifies Twynity identity.app/twynity.pydeclares and manages the external project connection.app/connection_store.pyencrypts GitHub credentials.app/agent_store.pystores session state under the same strict identity pair.app/codex_runtime.py,app/executor.py,app/workspaces.py, andapp/publisher.pyimplement task execution and branch publishing.app/tools/run_task.pyregisters the MCP tools.
This server cannot be deployed
Maintenance
Related MCP Connectors
Check if a repo will deploy, plan a deploy to your own cloud, and see status, logs and redeploys.
Task management for people and autonomous AI developers: tasks, stories, work logs, pull requests.
Shared task layer for AI coding agents. One MCP surface: task_search, task_get, task_mutate.
- uploads.shOAuthsh.uploads
Host files from coding agents; stage on a branch and attach to GitHub PRs.
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables MCP clients to securely execute bounded coding tasks through registered backends, with idempotent job submission, status polling, and artifact retrieval. It isolates each job in Git worktrees and supports optional branch publishing and pull request creation under strict policy constraints.-
- AlicenseNot gradedqualityAmaintenanceEnables bounded, multi-phase coding workflows inside Codex that plan, implement, independently review, repair, and verify repository changes, with an inline dashboard for inspecting runs.MIT
- AlicenseNot gradedqualityBmaintenanceEnables Codex to dispatch well-scoped development tasks to a remote CodeBuddy Code instance, specify model and reasoning effort, monitor progress, retrieve results, and review Git changes without auto-merging.6 npmMIT
- AlicenseAqualityAmaintenanceEnables a Chief of Staff client to find Codex tasks, create and submit project work with exact prompts, track progress via durable receipts, and continue or manage the same conversation locally.10147 npm3MIT