|
| 1 | +# Configuration |
| 2 | + |
| 3 | +This document explains all configuration options for the Code Mode Unified MCP server. |
| 4 | + |
| 5 | +## Environment Variables |
| 6 | + |
| 7 | +### CODEMODE_ENABLE_MCP_INTEGRATION |
| 8 | + |
| 9 | +**Type:** `boolean` (presence check) |
| 10 | +**Default:** `false` (disabled) |
| 11 | +**Description:** Enable integration with other MCP servers |
| 12 | + |
| 13 | +When enabled, the server: |
| 14 | +- Loads `.mcp.json` configuration |
| 15 | +- Connects to configured MCP servers |
| 16 | +- Makes their tools available via `mcp.*` proxy |
| 17 | +- Generates TypeScript declarations |
| 18 | + |
| 19 | +**Usage:** |
| 20 | +```bash |
| 21 | +CODEMODE_ENABLE_MCP_INTEGRATION=true npx tsx src/mcp-server.ts |
| 22 | +``` |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +### CODEMODE_TYPE_EXPOSURE |
| 27 | + |
| 28 | +**Type:** `'on-demand' | 'auto-include'` |
| 29 | +**Default:** `'on-demand'` |
| 30 | +**Description:** Controls how TypeScript type information is exposed to agents |
| 31 | + |
| 32 | +#### on-demand Mode (Default) |
| 33 | + |
| 34 | +**Best for:** Production use, token efficiency |
| 35 | +**Behavior:** |
| 36 | +- Types available via `mcp://types/declarations` resource |
| 37 | +- Agent must explicitly read resource to get types |
| 38 | +- Minimal tool description, stays under token limits |
| 39 | +- Works well with smart agents that explore capabilities |
| 40 | + |
| 41 | +**Tool Description:** |
| 42 | +``` |
| 43 | +Execute JavaScript/TypeScript code in a sandboxed runtime environment. |
| 44 | +When MCP integration is enabled, code has access to MCP tools via the |
| 45 | +global mcp object. For TypeScript type definitions and API documentation, |
| 46 | +read the resource mcp://types/declarations before writing code. |
| 47 | +``` |
| 48 | + |
| 49 | +**Agent Workflow:** |
| 50 | +1. Sees execute_code tool |
| 51 | +2. Reads mcp://types/declarations resource |
| 52 | +3. Gets full type information |
| 53 | +4. Writes type-safe code |
| 54 | + |
| 55 | +#### auto-include Mode |
| 56 | + |
| 57 | +**Best for:** Testing, less capable agents, immediate visibility |
| 58 | +**Behavior:** |
| 59 | +- Tool list directly in execute_code description |
| 60 | +- Agent sees available tools immediately |
| 61 | +- Higher token usage per request |
| 62 | +- No need to read resource first (but still available) |
| 63 | + |
| 64 | +**Tool Description:** |
| 65 | +``` |
| 66 | +Execute JavaScript/TypeScript code in a sandboxed runtime environment. |
| 67 | +When MCP integration is enabled, code has access to MCP tools via the |
| 68 | +global mcp object. |
| 69 | +
|
| 70 | +Available MCP Tools: |
| 71 | +
|
| 72 | +mcp.automem: |
| 73 | + - store_memory(content, tags, importance) // Store a memory with optional... |
| 74 | + - recall_memory(query, embedding, limit, ...) // Recall memories with hybrid... |
| 75 | + - associate_memories(memory1_id, memory2_id, type) // Create an association... |
| 76 | + [... all tools listed ...] |
| 77 | +
|
| 78 | +mcp["sequential-thinking"]: |
| 79 | + - sequentialthinking(thought, nextThoughtNeeded, thoughtNumber) // A detailed... |
| 80 | +
|
| 81 | +mcp.context7: |
| 82 | + - "resolve-library-id"(libraryName) // Resolves a package/product name... |
| 83 | + [...] |
| 84 | +
|
| 85 | +For complete TypeScript type definitions, read the resource mcp://types/declarations. |
| 86 | +``` |
| 87 | + |
| 88 | +**Agent Workflow:** |
| 89 | +1. Sees execute_code tool WITH full tool list |
| 90 | +2. Already knows what's available |
| 91 | +3. Optionally reads resource for complete types |
| 92 | +4. Writes code immediately |
| 93 | + |
| 94 | +**Usage:** |
| 95 | +```bash |
| 96 | +CODEMODE_TYPE_EXPOSURE=auto-include npx tsx src/mcp-server.ts |
| 97 | +``` |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Comparison: on-demand vs auto-include |
| 102 | + |
| 103 | +| Feature | on-demand | auto-include | |
| 104 | +|---------|-----------|--------------| |
| 105 | +| **Token Usage** | Low (~300 tokens) | High (~1500+ tokens) | |
| 106 | +| **Agent Discovery** | Must read resource | Immediate visibility | |
| 107 | +| **Tool List Updates** | No re-listing needed | Every tool list request | |
| 108 | +| **Best For** | Smart agents, production | Testing, visibility | |
| 109 | +| **Type Detail** | Full (via resource) | Summary + resource | |
| 110 | + |
| 111 | +## Recommendations |
| 112 | + |
| 113 | +### Use `on-demand` (default) when: |
| 114 | +- ✅ Deploying to production |
| 115 | +- ✅ Working with capable LLM agents (Claude, GPT-4) |
| 116 | +- ✅ Token efficiency matters |
| 117 | +- ✅ Agent can discover resources |
| 118 | + |
| 119 | +### Use `auto-include` when: |
| 120 | +- ✅ Testing MCP integration |
| 121 | +- ✅ Debugging agent behavior |
| 122 | +- ✅ Working with less capable agents |
| 123 | +- ✅ You want immediate tool visibility |
| 124 | +- ✅ Experimenting with different approaches |
| 125 | + |
| 126 | +## Testing Both Modes |
| 127 | + |
| 128 | +### Test on-demand Mode |
| 129 | + |
| 130 | +```bash |
| 131 | +# Start server (on-demand is default) |
| 132 | +CODEMODE_ENABLE_MCP_INTEGRATION=true npx tsx src/mcp-server.ts |
| 133 | + |
| 134 | +# Agent should: |
| 135 | +# 1. See execute_code tool |
| 136 | +# 2. Read mcp://types/declarations resource |
| 137 | +# 3. Get full type information |
| 138 | +# 4. Write code |
| 139 | +``` |
| 140 | + |
| 141 | +### Test auto-include Mode |
| 142 | + |
| 143 | +```bash |
| 144 | +# Start server with auto-include |
| 145 | +CODEMODE_ENABLE_MCP_INTEGRATION=true \ |
| 146 | +CODEMODE_TYPE_EXPOSURE=auto-include \ |
| 147 | +npx tsx src/mcp-server.ts |
| 148 | + |
| 149 | +# Agent should: |
| 150 | +# 1. See execute_code tool with full tool list |
| 151 | +# 2. Immediately know what's available |
| 152 | +# 3. Optionally read resource for complete types |
| 153 | +# 4. Write code |
| 154 | +``` |
| 155 | + |
| 156 | +## Future Configuration Options |
| 157 | + |
| 158 | +Planned environment variables: |
| 159 | + |
| 160 | +- `CODEMODE_TYPE_CACHE_TTL` - How long to cache generated types |
| 161 | +- `CODEMODE_TYPE_REFRESH_INTERVAL` - Auto-regenerate types periodically |
| 162 | +- `CODEMODE_DEFAULT_RUNTIME` - Change default from QuickJS |
| 163 | +- `CODEMODE_MAX_EXECUTION_TIME` - Global timeout limit |
| 164 | +- `CODEMODE_ENABLE_PROMPTS` - Toggle prompt templates feature |
0 commit comments