Skip to main content
Glama
ClydeLemot

Claude Code Directive MCP

by ClydeLemot
README.md
# Claude Code Directive MCP

`claude-code-directive-mcp` is a local stdio MCP server that lets an agent temporarily add a global Codex `AGENTS` directive requiring Claude Code usage until a configured expiry date.

It is designed for temporary, opt-in delegation policy:

- Adds one clearly marked block to the effective global Codex instruction file.
- Uses Codex precedence: non-empty `AGENTS.override.md`, otherwise `AGENTS.md`.
- Skips project-local `.codex` directories unless explicitly opted in.
- Records a manifest and creates a user-level cleanup timer.
- Removes only the exact marked block recorded in the manifest.
- Adds guardrails for Claude context, Main Codex context, retries, parallelism, and rate limits.
- Never asks for or stores secrets.

## Install

```bash
git clone <repo-url>
cd claude-code-directive-mcp
npm install
npm run install:codex
```

Restart Codex after installation so the new MCP server is loaded.

The installer writes a user wrapper to:

```text
~/.local/bin/codex-claude-code-directive-mcp
```

and registers this MCP server in:

```text
${CODEX_HOME:-~/.codex}/config.toml
```

## MCP Tools

`claude_directive_enable`

Enable or update the temporary directive.

Example arguments:

```json
{
  "expiresAt": "2026-08-17T23:59:59",
  "timezone": "Europe/Berlin",
  "cleanupDelayMinutes": 5,
  "maxClaudePromptChars": 60000,
  "maxClaudeOutputChars": 20000,
  "maxClaudeRuntimeSeconds": 900,
  "maxClaudeRetries": 1,
  "mainContextReservePercent": 25,
  "maxClaudeCallsPerTask": 3,
  "maxParallelClaudeAgents": 2,
  "minSecondsBetweenClaudeCalls": 30
}
```

`claude_directive_status`

Reports discovered Codex homes, effective global instruction files, marker counts, scheduler state, manifest content, and optional Claude CLI status.

`claude_directive_disable`

Runs the idempotent cleanup and disables/removes the one-time user scheduler.

## Cleanup

On Linux with a working user systemd, the MCP creates a user timer named:

```text
codex-claude-code-directive-cleanup.timer
```

The timer executes:

```text
${CODEX_HOME:-~/.codex}/maintenance/cleanup-temporary-claude-code-directive.py
```

The cleanup script uses the manifest to remove only the exact marked directive block. It is safe to run repeatedly.

## Budget And Rate Guardrails

The directive generated by this MCP tells the main agent to:

- keep a Main Codex context reserve,
- cap Claude prompt and output size,
- cap Claude runtime and retries,
- limit per-task Claude calls and parallel Claude agents,
- wait between separate Claude calls unless parallelism is justified,
- stop fast retry loops on rate limits, context limits, timeouts, or overload.

The MCP writes these rules into the global instruction block; it does not have privileged access to live provider token counters.

TDQS

A3.5/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct function: enabling, checking status, or disabling the directive. No overlap in purposes.

Naming Consistency5/5

All tools follow a consistent `claude_directive_` prefix with verb_noun pattern (enable, status, disable), making them easily identifiable.

Tool Count5/5

Three tools is exactly right for managing a lifecycle (create/read/delete) of a single directive; compact and well-scoped.

Completeness5/5

The set covers the full lifecycle: enabling (create/update), checking status (read), and disabling (delete). No obvious gaps for the stated domain.

Maintenance

ActivityStale
ResponsivenessNo issues