Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Universal schema guidance:
- `sandbox-agent api sessions reply-question` ↔ `POST /v1/sessions/{sessionId}/questions/{questionId}/reply`
- `sandbox-agent api sessions reject-question` ↔ `POST /v1/sessions/{sessionId}/questions/{questionId}/reject`
- `sandbox-agent api sessions reply-permission` ↔ `POST /v1/sessions/{sessionId}/permissions/{permissionId}/reply`
- `sandbox-agent api sessions reply-mcp-tunnel` ↔ `POST /v1/sessions/{sessionId}/mcp-tunnel/calls/{callId}/response`

## Post-Release Testing

Expand Down
18 changes: 18 additions & 0 deletions docs/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ sandbox-agent api sessions create <SESSION_ID> [OPTIONS]
| `-m, --model <MODEL>` | Model override |
| `-v, --variant <VARIANT>` | Model variant |
| `-A, --agent-version <VERSION>` | Agent version |
| `--mcp-tunnel-tools <JSON>` | JSON array of MCP tool definitions |

```bash
sandbox-agent api sessions create my-session \
Expand Down Expand Up @@ -289,6 +290,22 @@ sandbox-agent api sessions reply-permission <SESSION_ID> <PERMISSION_ID> [OPTION
sandbox-agent api sessions reply-permission my-session perm1 --reply once
```

#### Reply to MCP Tunnel Tool Call

```bash
sandbox-agent api sessions reply-mcp-tunnel <SESSION_ID> <CALL_ID> [OPTIONS]
```

| Option | Description |
|--------|-------------|
| `-o, --output <TEXT>` | Tool output (required) |
| `--is-error` | Mark tool result as error |
| `--content <JSON>` | Optional MCP content payload |

```bash
sandbox-agent api sessions reply-mcp-tunnel my-session call-1 --output "ok"
```

---

## CLI to HTTP Mapping
Expand All @@ -308,3 +325,4 @@ sandbox-agent api sessions reply-permission my-session perm1 --reply once
| `api sessions reply-question` | `POST /v1/sessions/{sessionId}/questions/{questionId}/reply` |
| `api sessions reject-question` | `POST /v1/sessions/{sessionId}/questions/{questionId}/reject` |
| `api sessions reply-permission` | `POST /v1/sessions/{sessionId}/permissions/{permissionId}/reply` |
| `api sessions reply-mcp-tunnel` | `POST /v1/sessions/{sessionId}/mcp-tunnel/calls/{callId}/response` |
121 changes: 121 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,69 @@
}
}
},
"/v1/sessions/{session_id}/mcp-tunnel/calls/{call_id}/response": {
"post": {
"tags": [
"sessions"
],
"operationId": "reply_mcp_tunnel_call",
"parameters": [
{
"name": "session_id",
"in": "path",
"description": "Session id",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "call_id",
"in": "path",
"description": "MCP call id",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/McpTunnelToolResponseRequest"
}
}
},
"required": true
},
"responses": {
"204": {
"description": "MCP tool call responded"
},
"400": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"404": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
},
"/v1/sessions/{session_id}/messages": {
"post": {
"tags": [
Expand Down Expand Up @@ -1063,6 +1126,14 @@
"type": "string",
"nullable": true
},
"mcpTunnel": {
"allOf": [
{
"$ref": "#/components/schemas/McpTunnelConfig"
}
],
"nullable": true
},
"model": {
"type": "string",
"nullable": true
Expand Down Expand Up @@ -1258,6 +1329,56 @@
"failed"
]
},
"McpTunnelConfig": {
"type": "object",
"required": [
"tools"
],
"properties": {
"tools": {
"type": "array",
"items": {
"$ref": "#/components/schemas/McpTunnelTool"
}
}
}
},
"McpTunnelTool": {
"type": "object",
"required": [
"name"
],
"properties": {
"description": {
"type": "string",
"nullable": true
},
"inputSchema": {
"nullable": true
},
"name": {
"type": "string"
}
}
},
"McpTunnelToolResponseRequest": {
"type": "object",
"required": [
"output"
],
"properties": {
"content": {
"nullable": true
},
"isError": {
"type": "boolean",
"nullable": true
},
"output": {
"type": "string"
}
}
},
"MessageRequest": {
"type": "object",
"required": [
Expand Down
13 changes: 13 additions & 0 deletions sdks/typescript/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
EventsResponse,
HealthResponse,
MessageRequest,
McpTunnelToolResponseRequest,
PermissionReplyRequest,
ProblemDetails,
QuestionReplyRequest,
Expand Down Expand Up @@ -207,6 +208,18 @@ export class SandboxAgent {
);
}

async replyMcpTunnelCall(
sessionId: string,
callId: string,
request: McpTunnelToolResponseRequest,
): Promise<void> {
await this.requestJson(
"POST",
`${API_PREFIX}/sessions/${encodeURIComponent(sessionId)}/mcp-tunnel/calls/${encodeURIComponent(callId)}/response`,
{ body: request },
);
}

async terminateSession(sessionId: string): Promise<void> {
await this.requestJson("POST", `${API_PREFIX}/sessions/${encodeURIComponent(sessionId)}/terminate`);
}
Expand Down
Loading