Skip to content

Commit 5b1e702

Browse files
markturanskyuserclaude
authored
fix(runner): restore acp backend MCP tools as fallback when sidecar is absent (#1607)
## Summary - PR #1593 removed the `acp` backend MCP server (9 session management tools: `acp_list_sessions`, `acp_get_session`, `acp_create_session`, `acp_stop_session`, `acp_send_message`, `acp_get_session_status`, `acp_restart_session`, `acp_list_workflows`, `acp_get_api_reference`) when adding dynamic credential-aware MCP servers - The ambient MCP sidecar only provides equivalents for 5 of those 9 tools — `stop_session`, `restart_session`, `list_workflows`, and `get_api_reference` have no sidecar equivalent - Sessions without the sidecar (e.g. older CPs, missing `MCP_IMAGE` config, or `CP_TOKEN_URL`/`CPTokenPublicKey` not configured) lost **all** session management tooling - This re-registers the `acp` backend tools as a fallback when `AMBIENT_MCP_URL` is not set. When the sidecar IS present, its tools take precedence ## Test plan - [x] 549/549 runner tests pass (1 pre-existing mlflow skip) - [x] 66/66 MCP + backend_tools tests pass - [ ] Deploy to staging and verify `acp_*` tools appear when sidecar is absent - [ ] Verify tools are NOT registered when sidecar IS present (no duplicates) 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Backend API tools are now automatically available in more deployment configurations, expanding functionality and flexibility. * Improved logging now surfaces discovered backend tools and their availability. * **Tests** * End-to-end scheduled-session test now uses a stubbed workflow API to stabilize editing assertions and ensure OOTB workflow display and custom-field hiding. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: user <u@example.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent d45e631 commit 5b1e702

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

components/runners/ambient-runner/ambient_runner/bridges/claude/mcp.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def build_mcp_servers(
6262
load_rubric_content,
6363
)
6464
from ambient_runner.bridges.claude.corrections import create_correction_mcp_tool
65+
from ambient_runner.bridges.claude.backend_tools import create_backend_mcp_tools
6566

6667
mcp_servers = load_mcp_config(context, cwd_path) or {}
6768

@@ -117,6 +118,20 @@ def build_mcp_servers(
117118
mcp_servers["corrections"] = correction_server
118119
logger.info("Added corrections feedback MCP tool (log_correction)")
119120

121+
# Backend API tools (session management) — fallback when ambient MCP sidecar is absent
122+
if not ambient_mcp_url:
123+
backend_tools = create_backend_mcp_tools(sdk_tool_decorator=sdk_tool)
124+
if backend_tools:
125+
backend_server = create_sdk_mcp_server(
126+
name="acp", version="1.0.0", tools=backend_tools
127+
)
128+
mcp_servers["acp"] = backend_server
129+
logger.info(
130+
"Added backend API MCP tools (%d): %s",
131+
len(backend_tools),
132+
", ".join(t.name for t in backend_tools),
133+
)
134+
120135
# Credential-aware MCP servers (dynamically configured per bound credentials)
121136
credential_mcp_servers = build_credential_mcp_servers()
122137
mcp_servers.update(credential_mcp_servers)

e2e/cypress/e2e/scheduled-sessions.cy.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,29 @@ describe('Scheduled Sessions', () => {
411411
expect(resp.status).to.be.oneOf([200, 201])
412412
const scheduleName = resp.body.name
413413

414+
// Stub the OOTB workflows API so the test doesn't depend on live GitHub access
415+
cy.intercept('GET', `/api/workflows/ootb*`, {
416+
statusCode: 200,
417+
body: {
418+
workflows: [
419+
{
420+
id: 'bugfix',
421+
name: 'Fix a bug',
422+
description: 'Systematic workflow for analyzing, fixing, and verifying software bugs.',
423+
gitUrl: 'https://github.com/ambient-code/workflows.git',
424+
branch: 'main',
425+
path: 'workflows/bugfix',
426+
enabled: true,
427+
},
428+
],
429+
},
430+
}).as('ootbWorkflows')
431+
414432
// Navigate to edit page
415433
cy.visit(`/projects/${workspaceSlug}/scheduled-sessions/${scheduleName}/edit`)
416434

435+
cy.wait('@ootbWorkflows')
436+
417437
// The workflow select should show the OOTB workflow name, not "Custom workflow..."
418438
cy.get('[data-testid="workflow-select"]', { timeout: 10000 })
419439
.should('contain.text', 'Fix a bug')

0 commit comments

Comments
 (0)