Jinal-Sarvaiya opened a new pull request, #209:
URL: https://github.com/apache/camel-kit/pull/209
## Summary
Fixes #113 by enabling OpenCode headless execution without requiring the
`--auto` flag and preventing MCP server timeout failures on first run.
## Problem
The generated `opencode.json` configuration broke headless OpenCode
execution:
1. **Permission issue**: All Camel MCP tools (`camel_*`,
`camel-knowledge_*`, `citrus_*`) were set to `"ask"` permission. In headless
mode (`opencode run "..."`, scripts, CI), OpenCode auto-rejects "ask"
permissions, causing every MCP call to fail. This prevented Iron Law 1 ("Verify
ALL components/EIPs/dataformats via MCP") from being followed.
2. **Timeout issue**: No timeout was configured for MCP servers. OpenCode's
default 30-second timeout fails on first run when JBang downloads the server
runner JARs, which can take longer.
Evidence from camel-evals: OpenCode trials required `--auto` flag to make
MCP calls work, but that approves all operations including shell commands.
## Solution
### 1. Changed MCP permissions to "allow"
**File:**
`kit/camel-kit-core/src/main/resources/templates/mcp-configs/opencode-mcp.json`
Changed all Camel MCP tool permissions from `"ask"` to `"allow"`:
- `camel_*`: 29 read-only tools (catalog queries, validation, migration
analysis)
- `camel-knowledge_*`: 5 read-only tools (documentation search, CVE lookup,
release info)
- `citrus_*`: 9 read-only tools (test action catalog, endpoint schemas,
documentation)
**Rationale:** All 38 MCP tools across the three servers perform read-only
operations:
- Catalog lookups (`camel_catalog_component_doc`, `camel_catalog_eip_doc`,
etc.)
- Validation (`camel_validate_route`, `camel_validate_yaml_dsl`)
- Documentation search (`camel_docs_search`, `camel_docs_cve_search`)
- Analysis (`camel_migration_analyze`, `camel_error_diagnose`)
None write files or execute shell commands, making them safe to allow by
default.
### 2. Added 120-second timeout
Added `"timeout": 120000` to all three MCP server configurations:
- `camel`
- `camel-knowledge`
- `citrus`
**Rationale:** Prevents timeout failures during first-run JBang dependency
downloads. 120 seconds matches the timeout used in camel-evals.
### 3. Updated tests
**File:**
`kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/OpenCodeGeneratorTest.java`
Updated all test assertions to expect:
- `"allow"` instead of `"ask"` for MCP permissions
- `120000` timeout value for MCP servers
### 4. Documented headless mode behavior
**File:** `docs/modules/ROOT/pages/agents.adoc`
Added new section "MCP permissions and headless mode" under OpenCode
documentation explaining:
- Default "allow" permission for all Camel MCP tools
- Why headless mode requires this (auto-rejection of "ask" permissions)
- Security rationale (all tools are read-only)
- 120-second timeout for first-run initialization
- How to override to "ask" for interactive approval if desired
## Testing
- [x] `./mvnw -Psourcecheck validate -B` passes
- [x] All OpenCodeGeneratorTest assertions updated and passing
- [x] Documentation renders correctly in Antora
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]