Skip to content

Commit 9ba7058

Browse files
committed
fixups
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 0895850 commit 9ba7058

5 files changed

Lines changed: 137 additions & 65 deletions

File tree

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,124 @@ mcp:
13561356
}
13571357
```
13581358

1359+
### 🤖 Claude Server
1360+
1361+
An MCP server for controlling Claude Code CLI sessions asynchronously. Start sessions, monitor progress, retrieve logs, and manage multiple concurrent Claude Code processes. It follows the same pattern as the opencode MCP server but is specifically designed for Claude Code.
1362+
1363+
**Features:**
1364+
- Background task delegation to Claude Code
1365+
- Async session management with unique session IDs
1366+
- Start Claude Code sessions with full command-line option support
1367+
- Monitor session status (starting, running, completed, failed, stopped)
1368+
- Retrieve stdout/stderr logs from sessions
1369+
- Stop running sessions gracefully
1370+
- List all sessions with filtering by status
1371+
- Tool restrictions via `--allowedTools` and `--tools` flags
1372+
- Environment passthrough to Claude subprocesses
1373+
- Configurable concurrent session limits
1374+
- Automatic log cleanup based on retention policy
1375+
1376+
**Tools:**
1377+
- `start_session` - Start a new Claude session with a prompt and options
1378+
- `get_session_status` - Get the current status of a session by ID
1379+
- `get_session_logs` - Retrieve stdout and stderr logs from a session
1380+
- `stop_session` - Stop a running session
1381+
- `list_sessions` - List all sessions with optional status filtering
1382+
1383+
**Configuration:**
1384+
- `CLAUDE_SESSION_DIR` - Directory for session state and logs (default: `/tmp/claude-sessions`)
1385+
- `CLAUDE_BINARY` - Path to Claude binary (default: `claude`)
1386+
- `CLAUDE_MAX_SESSIONS` - Maximum number of concurrent sessions (default: `10`)
1387+
- `CLAUDE_LOG_RETENTION_HOURS` - Hours to retain session logs before cleanup (default: `24`)
1388+
- `CLAUDE_WORK_DIR` - Working directory for Claude processes (default: `/root`)
1389+
- `CLAUDE_MODEL` - Default model to use (e.g., `sonnet`, `opus`)
1390+
- `CLAUDE_AGENT` - Specify an agent for sessions
1391+
- `CLAUDE_FORMAT` - Output format (default: `json`)
1392+
- `CLAUDE_SHARE` - Whether to share sessions (`true`/`false`)
1393+
- `CLAUDE_ATTACH` - Files to attach to sessions
1394+
- `CLAUDE_PORT` - Port for remote control
1395+
- `CLAUDE_VARIANT` - Model variant
1396+
- `CLAUDE_ALLOWED_TOOLS` - Tools allowed without prompting (e.g., `"Bash,Read,Edit"`)
1397+
- `CLAUDE_TOOLS` - Restrict which tools Claude can use (e.g., `"Bash,Read,Edit"`)
1398+
- `CLAUDE_TOOL_START_SESSION_NAME` - Override the start_session tool name
1399+
- `CLAUDE_TOOL_GET_SESSION_STATUS_NAME` - Override the get_session_status tool name
1400+
- `CLAUDE_TOOL_GET_SESSION_LOGS_NAME` - Override the get_session_logs tool name
1401+
- `CLAUDE_TOOL_STOP_SESSION_NAME` - Override the stop_session tool name
1402+
- `CLAUDE_TOOL_LIST_SESSIONS_NAME` - Override the list_sessions tool name
1403+
1404+
**Start Session Example:**
1405+
```json
1406+
{
1407+
"message": "Find and fix the bug in auth.py",
1408+
"allowed_tools": "Bash,Read,Edit",
1409+
"title": "Bug Fix Task"
1410+
}
1411+
```
1412+
1413+
**Start Session Output:**
1414+
```json
1415+
{
1416+
"session_id": "550e8400-e29b-41d4-a716-446655440000",
1417+
"status": "starting",
1418+
"message": "Session started successfully"
1419+
}
1420+
```
1421+
1422+
**Get Session Status Output:**
1423+
```json
1424+
{
1425+
"session_id": "550e8400-e29b-41d4-a716-446655440000",
1426+
"status": "completed",
1427+
"pid": "12345",
1428+
"exit_code": "0",
1429+
"created_at": "2025-01-15T10:30:00Z",
1430+
"started_at": "2025-01-15T10:30:01Z",
1431+
"stopped_at": "2025-01-15T10:30:15Z",
1432+
"duration": "14s"
1433+
}
1434+
```
1435+
1436+
**Get Session Logs Output:**
1437+
```json
1438+
{
1439+
"session_id": "550e8400-e29b-41d4-a716-446655440000",
1440+
"stdout": "Working on the bug fix...",
1441+
"stderr": "",
1442+
"line_count": 50
1443+
}
1444+
```
1445+
1446+
**Adding the Server:**
1447+
```bash
1448+
claude mcp add claude-mcp -- npx -y mudler/MCPs/claude
1449+
```
1450+
1451+
**Docker Image:**
1452+
```bash
1453+
docker run -e CLAUDE_MAX_SESSIONS=5 -e CLAUDE_LOG_RETENTION_HOURS=48 ghcr.io/mudler/mcps/claude:latest
1454+
```
1455+
1456+
**LocalAI configuration (to add to the model config):**
1457+
```yaml
1458+
mcp:
1459+
stdio: |
1460+
{
1461+
"mcpServers": {
1462+
"claude": {
1463+
"command": "docker",
1464+
"env": {
1465+
"CLAUDE_MAX_SESSIONS": "5",
1466+
"CLAUDE_LOG_RETENTION_HOURS": "48"
1467+
},
1468+
"args": [
1469+
"run", "-i", "--rm",
1470+
"ghcr.io/mudler/mcps/claude:master"
1471+
]
1472+
}
1473+
}
1474+
}
1475+
```
1476+
13591477
### 🚀 Opencode Server
13601478

13611479
An MCP server for controlling opencode AI sessions asynchronously. Start sessions, monitor progress, retrieve logs, and manage multiple concurrent opencode processes.
@@ -1510,6 +1628,7 @@ make MCP_SERVER=localrecall build
15101628
make MCP_SERVER=todo build
15111629
make MCP_SERVER=mailbox build
15121630
make MCP_SERVER=filesystem build
1631+
make MCP_SERVER=claude build
15131632
15141633
# Run tests and checks
15151634
make ci-local

claude/go.mod

Lines changed: 0 additions & 18 deletions
This file was deleted.

claude/go.sum

Lines changed: 0 additions & 40 deletions
This file was deleted.

go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/mudler/mcps
22

3-
go 1.24.7
3+
go 1.25.0
44

55
require (
66
github.com/blevesearch/bleve/v2 v2.5.7
@@ -9,7 +9,7 @@ require (
99
github.com/gofrs/flock v0.13.0
1010
github.com/google/uuid v1.6.0
1111
github.com/mkelcik/go-ha-client v1.0.0
12-
github.com/modelcontextprotocol/go-sdk v1.0.0
12+
github.com/modelcontextprotocol/go-sdk v1.4.0
1313
github.com/mudler/go-processmanager v0.1.0
1414
github.com/onsi/ginkgo/v2 v2.28.1
1515
github.com/onsi/gomega v1.39.1
@@ -46,19 +46,22 @@ require (
4646
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
4747
github.com/golang/snappy v0.0.4 // indirect
4848
github.com/google/go-cmp v0.7.0 // indirect
49-
github.com/google/jsonschema-go v0.3.0 // indirect
49+
github.com/google/jsonschema-go v0.4.2 // indirect
5050
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
5151
github.com/json-iterator/go v1.1.12 // indirect
5252
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5353
github.com/modern-go/reflect2 v1.0.2 // indirect
5454
github.com/mschoch/smat v0.2.0 // indirect
5555
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
56+
github.com/segmentio/asm v1.1.3 // indirect
57+
github.com/segmentio/encoding v0.5.3 // indirect
5658
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
5759
go.etcd.io/bbolt v1.4.0 // indirect
5860
go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 // indirect
5961
go.yaml.in/yaml/v3 v3.0.4 // indirect
6062
golang.org/x/mod v0.32.0 // indirect
6163
golang.org/x/net v0.49.0 // indirect
64+
golang.org/x/oauth2 v0.34.0 // indirect
6265
golang.org/x/sync v0.19.0 // indirect
6366
golang.org/x/sys v0.40.0 // indirect
6467
golang.org/x/text v0.33.0 // indirect

go.sum

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
8080
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
8181
github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
8282
github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0=
83+
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
84+
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
8385
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
8486
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
8587
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -101,8 +103,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
101103
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
102104
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
103105
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
104-
github.com/google/jsonschema-go v0.3.0 h1:6AH2TxVNtk3IlvkkhjrtbUc4S8AvO0Xii0DxIygDg+Q=
105-
github.com/google/jsonschema-go v0.3.0/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
106+
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
107+
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
106108
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc=
107109
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
108110
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -121,8 +123,8 @@ github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3v
121123
github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A=
122124
github.com/mkelcik/go-ha-client v1.0.0 h1:L49uN3ucuG0jTW27MoAc5kY8JblznGXVs83/ZHxUEB8=
123125
github.com/mkelcik/go-ha-client v1.0.0/go.mod h1:X8bXN+jvTbDsyw6Km6f6Hq6Fof+cgW9Bd5DOTiNcwHA=
124-
github.com/modelcontextprotocol/go-sdk v1.0.0 h1:Z4MSjLi38bTgLrd/LjSmofqRqyBiVKRyQSJgw8q8V74=
125-
github.com/modelcontextprotocol/go-sdk v1.0.0/go.mod h1:nYtYQroQ2KQiM0/SbyEPUWQ6xs4B95gJjEalc9AQyOs=
126+
github.com/modelcontextprotocol/go-sdk v1.4.0 h1:u0kr8lbJc1oBcawK7Df+/ajNMpIDFE41OEPxdeTLOn8=
127+
github.com/modelcontextprotocol/go-sdk v1.4.0/go.mod h1:Nxc2n+n/GdCebUaqCOhTetptS17SXXNu9IfNTaLDi1E=
126128
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
127129
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
128130
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -149,6 +151,10 @@ github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR
149151
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
150152
github.com/sashabaranov/go-openai v1.41.2 h1:vfPRBZNMpnqu8ELsclWcAvF19lDNgh1t6TVfFFOPiSM=
151153
github.com/sashabaranov/go-openai v1.41.2/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
154+
github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=
155+
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
156+
github.com/segmentio/encoding v0.5.3 h1:OjMgICtcSFuNvQCdwqMCv9Tg7lEOXGwm1J5RPQccx6w=
157+
github.com/segmentio/encoding v0.5.3/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
152158
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
153159
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
154160
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -199,6 +205,8 @@ golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
199205
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
200206
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
201207
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
208+
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
209+
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
202210
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
203211
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
204212
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

0 commit comments

Comments
 (0)