Skip to content
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
91c168d
feat(mcp): add Model Context Protocol integration
yuchou87 Feb 15, 2026
ce3fc4b
feat(docker): add full-featured Docker image with MCP tools support
yuchou87 Feb 16, 2026
51ed54a
refactor(docker): switch to node:24-bookworm-slim base image
yuchou87 Feb 16, 2026
b9c2b35
fix(docker): override entrypoint in test script to avoid interactive …
yuchou87 Feb 16, 2026
c057423
refactor(docker): migrate to docker compose v2 syntax
yuchou87 Feb 16, 2026
1c9c320
fix(docker): ensure uv is accessible in system PATH
yuchou87 Feb 16, 2026
1764181
fix(docker): correct uv installation path
yuchou87 Feb 16, 2026
fcedba1
fix(docker): add profiles to build commands
yuchou87 Feb 16, 2026
e91e716
fix(docker): use service names instead of --profile flag for build
yuchou87 Feb 16, 2026
acb974f
Merge branch 'main' into mcp-tools-support
yuchou87 Feb 16, 2026
87e0336
chore(deps): format go.mod
yuchou87 Feb 16, 2026
2461069
chore(docker): add execute permission to test script
yuchou87 Feb 16, 2026
77d26e5
fix(mcp): return aggregated error when all servers fail to connect
yuchou87 Feb 16, 2026
a4265b3
fix(mcp): resolve relative envFile paths against workspace directory
yuchou87 Feb 16, 2026
a026d56
chore(deps): consolidate indirect require for uritemplate
yuchou87 Feb 16, 2026
20f8bb2
refactor(tools): use MCPManager interface in NewMCPTool constructor
yuchou87 Feb 16, 2026
02c1792
fix(tools): preserve MCP tool InputSchema via JSON marshal/unmarshal
yuchou87 Feb 16, 2026
aed7296
fix(agent): tie MCP connections to agent lifecycle context
yuchou87 Feb 16, 2026
2318232
fix(agent): ensure MCP cleanup on all Run() exit paths
yuchou87 Feb 16, 2026
0f6fadb
fix(agent): register MCP tools after server initialization
yuchou87 Feb 16, 2026
6892d00
perf(agent): reduce memory footprint by storing minimal MCP dependencies
yuchou87 Feb 17, 2026
4113190
chore(config): remove example MCP servers from default config
yuchou87 Feb 17, 2026
e38364b
build(docker): migrate full image from Debian to Alpine base
yuchou87 Feb 17, 2026
47533a0
style: format code with gofmt
yuchou87 Feb 19, 2026
a5d2e10
chore: merge main branch into mcp-tools-support
yuchou87 Feb 19, 2026
ffa0198
fix(agent): scope MCP manager cleanup to successful initialization
yuchou87 Feb 19, 2026
dea381c
improve(agent): clarify MCP tool registration logging
yuchou87 Feb 19, 2026
f0ce26f
style(config): use snake_case for EnvFile JSON field name
yuchou87 Feb 19, 2026
7577414
fix(mcp): ensure proper environment variable override semantics
yuchou87 Feb 19, 2026
f1b7984
fix(mcp): prevent race condition between CallTool and Close
yuchou87 Feb 19, 2026
a7a4e88
fix(agent): use fallback workspace path for MCP initialization
yuchou87 Feb 19, 2026
d867e86
Merge branch 'main' into mcp-tools-support
yuchou87 Feb 21, 2026
fb2b594
fix(scripts): specify service name in docker compose build
yuchou87 Feb 21, 2026
246fdf3
fix(mcp): guard against nil result from CallTool
yuchou87 Feb 21, 2026
59e9c55
docs(config): restore MCP server examples in config.example.json
yuchou87 Feb 21, 2026
33058b5
fix(mcp): reject empty keys in loadEnvFile
yuchou87 Feb 21, 2026
d2b3fc1
fix(mcp): include server name and cause in Close() errors
yuchou87 Feb 21, 2026
11dbc30
perf(agent): cache ListAgentIDs() result before MCP tool registration…
yuchou87 Feb 21, 2026
cfc29a1
fix(mcp): prevent use-after-close race between CallTool and Close
yuchou87 Feb 21, 2026
672da98
Merge branch 'main' into mcp-tools-support
yuchou87 Feb 22, 2026
6aade43
docs: add MCP tool configuration documentation
yuchou87 Feb 22, 2026
16a3b96
fix(mcp): validate workspace before resolving relative env_file
yuchou87 Feb 22, 2026
4e330b2
test(mcp): add manager behavior and lifecycle unit tests
yuchou87 Feb 22, 2026
257b0d8
Merge branch 'main' into mcp-tools-support
yuchou87 Feb 28, 2026
077d7c8
chore: fix lint issues in mcp and agent packages
yuchou87 Mar 1, 2026
ef738f4
fix: address PR review feedback for MCP tools support
yuchou87 Mar 1, 2026
0eec640
fix: correct MCP server install test in test-docker-mcp.sh
yuchou87 Mar 1, 2026
a2591e0
fix: improve MCP tool name collision safety and registry overwrite wa…
yuchou87 Mar 1, 2026
4e348e3
Merge branch 'main' into mcp-tools-support
yinwm Mar 2, 2026
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
44 changes: 44 additions & 0 deletions Dockerfile.full
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ============================================================
# Stage 1: Build the picoclaw binary
# ============================================================
FROM golang:1.26.0-alpine AS builder

RUN apk add --no-cache git make

WORKDIR /src

# Cache dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy source and build
COPY . .
RUN make build

# ============================================================
# Stage 2: Node.js-based runtime with full MCP support
# ============================================================
FROM node:24-alpine3.23

# Install runtime dependencies
RUN apk add --no-cache \
ca-certificates \
curl \
git \
python3 \
py3-pip

# Install uv and symlink to system path
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
ln -s /root/.local/bin/uv /usr/local/bin/uv && \
ln -s /root/.local/bin/uvx /usr/local/bin/uvx && \
uv --version

# Copy binary
COPY --from=builder /src/build/picoclaw /usr/local/bin/picoclaw

# Create picoclaw home directory
RUN /usr/local/bin/picoclaw onboard

ENTRYPOINT ["picoclaw"]
CMD ["gateway"]
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,44 @@ check: deps fmt vet test
run: build
@$(BUILD_DIR)/$(BINARY_NAME) $(ARGS)

## docker-build: Build Docker image (minimal Alpine-based)
docker-build:
@echo "Building minimal Docker image (Alpine-based)..."
docker compose build picoclaw-agent picoclaw-gateway

## docker-build-full: Build Docker image with full MCP support (Node.js 24)
docker-build-full:
@echo "Building full-featured Docker image (Node.js 24)..."
docker compose -f docker-compose.full.yml build picoclaw-agent picoclaw-gateway

## docker-test: Test MCP tools in Docker container
docker-test:
@echo "Testing MCP tools in Docker..."
@chmod +x scripts/test-docker-mcp.sh
@./scripts/test-docker-mcp.sh

## docker-run: Run picoclaw gateway in Docker (Alpine-based)
docker-run:
docker compose --profile gateway up

## docker-run-full: Run picoclaw gateway in Docker (full-featured)
docker-run-full:
docker compose -f docker-compose.full.yml --profile gateway up

## docker-run-agent: Run picoclaw agent in Docker (interactive, Alpine-based)
docker-run-agent:
docker compose run --rm picoclaw-agent

## docker-run-agent-full: Run picoclaw agent in Docker (interactive, full-featured)
docker-run-agent-full:
docker compose -f docker-compose.full.yml run --rm picoclaw-agent

## docker-clean: Clean Docker images and volumes
docker-clean:
docker compose down -v
docker compose -f docker-compose.full.yml down -v
docker rmi picoclaw:latest picoclaw:full 2>/dev/null || true

## help: Show this help message
help:
@echo "picoclaw Makefile"
Expand All @@ -219,6 +257,8 @@ help:
@echo " make install # Install to ~/.local/bin"
@echo " make uninstall # Remove from /usr/local/bin"
@echo " make install-skills # Install skills to workspace"
@echo " make docker-build # Build minimal Docker image"
@echo " make docker-test # Test MCP tools in Docker"
@echo ""
@echo "Environment Variables:"
@echo " INSTALL_PREFIX # Installation prefix (default: ~/.local)"
Expand Down
47 changes: 46 additions & 1 deletion config/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,51 @@
"cron": {
"exec_timeout_minutes": 5
},
"mcp": {
"enabled": false,
"servers": {
"filesystem": {
"enabled": false,
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/tmp"
]
},
"github": {
"enabled": false,
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_TOKEN"
}
},
"brave-search": {
"enabled": false,
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-brave-search"
],
"env": {
"BRAVE_API_KEY": "YOUR_BRAVE_API_KEY"
}
},
"postgres": {
"enabled": false,
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost/dbname"
]
}
}
},
"exec": {
"enable_deny_patterns": false,
"custom_deny_patterns": []
Expand Down Expand Up @@ -265,4 +310,4 @@
"host": "127.0.0.1",
"port": 18790
}
}
}
44 changes: 44 additions & 0 deletions docker-compose.full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
services:
# ─────────────────────────────────────────────
# PicoClaw Agent (one-shot query) - Full MCP Support
# docker compose -f docker-compose.full.yml run --rm picoclaw-agent -m "Hello"
# ─────────────────────────────────────────────
picoclaw-agent:
build:
context: .
dockerfile: Dockerfile.full
container_name: picoclaw-agent-full
profiles:
- agent
volumes:
- ./config/config.json:/root/.picoclaw/config.json:ro
- picoclaw-workspace:/root/.picoclaw/workspace
- picoclaw-npm-cache:/root/.npm # npm cache for faster MCP server installs
entrypoint: ["picoclaw", "agent"]
stdin_open: true
tty: true

# ─────────────────────────────────────────────
# PicoClaw Gateway (Long-running Bot) - Full MCP Support
# docker compose -f docker-compose.full.yml --profile gateway up
# ─────────────────────────────────────────────
picoclaw-gateway:
build:
context: .
dockerfile: Dockerfile.full
container_name: picoclaw-gateway-full
restart: unless-stopped
profiles:
- gateway
volumes:
# Configuration file
- ./config/config.json:/root/.picoclaw/config.json:ro
# Persistent workspace (sessions, memory, logs)
- picoclaw-workspace:/root/.picoclaw/workspace
# NPM cache for faster MCP server installs
- picoclaw-npm-cache:/root/.npm
command: ["gateway"]

volumes:
picoclaw-workspace:
picoclaw-npm-cache: # Cache npm packages to speed up MCP server installations
141 changes: 108 additions & 33 deletions docs/tools_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PicoClaw's tools configuration is located in the `tools` field of `config.json`.
{
"tools": {
"web": { ... },
"mcp": { ... },
"exec": { ... },
"cron": { ... },
"skills": { ... }
Expand All @@ -21,35 +22,35 @@ Web tools are used for web search and fetching.

### Brave

| Config | Type | Default | Description |
|--------|------|---------|-------------|
| `enabled` | bool | false | Enable Brave search |
| `api_key` | string | - | Brave Search API key |
| `max_results` | int | 5 | Maximum number of results |
| Config | Type | Default | Description |
| ------------- | ------ | ------- | ------------------------- |
| `enabled` | bool | false | Enable Brave search |
| `api_key` | string | - | Brave Search API key |
| `max_results` | int | 5 | Maximum number of results |

### DuckDuckGo

| Config | Type | Default | Description |
|--------|------|---------|-------------|
| `enabled` | bool | true | Enable DuckDuckGo search |
| `max_results` | int | 5 | Maximum number of results |
| Config | Type | Default | Description |
| ------------- | ---- | ------- | ------------------------- |
| `enabled` | bool | true | Enable DuckDuckGo search |
| `max_results` | int | 5 | Maximum number of results |

### Perplexity

| Config | Type | Default | Description |
|--------|------|---------|-------------|
| `enabled` | bool | false | Enable Perplexity search |
| `api_key` | string | - | Perplexity API key |
| `max_results` | int | 5 | Maximum number of results |
| Config | Type | Default | Description |
| ------------- | ------ | ------- | ------------------------- |
| `enabled` | bool | false | Enable Perplexity search |
| `api_key` | string | - | Perplexity API key |
| `max_results` | int | 5 | Maximum number of results |

## Exec Tool

The exec tool is used to execute shell commands.

| Config | Type | Default | Description |
|--------|------|---------|-------------|
| `enable_deny_patterns` | bool | true | Enable default dangerous command blocking |
| `custom_deny_patterns` | array | [] | Custom deny patterns (regular expressions) |
| Config | Type | Default | Description |
| ---------------------- | ----- | ------- | ------------------------------------------ |
| `enable_deny_patterns` | bool | true | Enable default dangerous command blocking |
| `custom_deny_patterns` | array | [] | Custom deny patterns (regular expressions) |

### Functionality

Expand Down Expand Up @@ -80,10 +81,7 @@ By default, PicoClaw blocks the following dangerous commands:
"tools": {
"exec": {
"enable_deny_patterns": true,
"custom_deny_patterns": [
"\\brm\\s+-r\\b",
"\\bkillall\\s+python"
]
"custom_deny_patterns": ["\\brm\\s+-r\\b", "\\bkillall\\s+python"]
}
}
}
Expand All @@ -93,23 +91,98 @@ By default, PicoClaw blocks the following dangerous commands:

The cron tool is used for scheduling periodic tasks.

| Config | Type | Default | Description |
|--------|------|---------|-------------|
| `exec_timeout_minutes` | int | 5 | Execution timeout in minutes, 0 means no limit |
| Config | Type | Default | Description |
| ---------------------- | ---- | ------- | ---------------------------------------------- |
| `exec_timeout_minutes` | int | 5 | Execution timeout in minutes, 0 means no limit |

## MCP Tool

The MCP tool enables integration with external Model Context Protocol servers.

### Global Config

| Config | Type | Default | Description |
| --------- | ------ | ------- | ----------------------------------- |
| `enabled` | bool | false | Enable MCP integration globally |
| `servers` | object | `{}` | Map of server name to server config |

### Per-Server Config

| Config | Type | Required | Description |
| ---------- | ------ | -------- | ------------------------------------------ |
| `enabled` | bool | yes | Enable this MCP server |
| `type` | string | no | Transport type: `stdio`, `sse`, `http` |
| `command` | string | stdio | Executable command for stdio transport |
| `args` | array | no | Command arguments for stdio transport |
| `env` | object | no | Environment variables for stdio process |
| `env_file` | string | no | Path to environment file for stdio process |
| `url` | string | sse/http | Endpoint URL for `sse`/`http` transport |
| `headers` | object | no | HTTP headers for `sse`/`http` transport |

### Transport Behavior

- If `type` is omitted, transport is auto-detected:
- `url` is set → `sse`
- `command` is set → `stdio`
- `http` and `sse` both use `url` + optional `headers`.
- `env` and `env_file` are only applied to `stdio` servers.

### Configuration Examples

#### 1) Stdio MCP server

```json
{
"tools": {
"mcp": {
"enabled": true,
"servers": {
"filesystem": {
"enabled": true,
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
}
}
}
}
}
```

#### 2) Remote SSE/HTTP MCP server

```json
{
"tools": {
"mcp": {
"enabled": true,
"servers": {
"remote-mcp": {
"enabled": true,
"type": "sse",
"url": "https://example.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}
}
}
```

## Skills Tool

The skills tool configures skill discovery and installation via registries like ClawHub.

### Registries

| Config | Type | Default | Description |
|--------|------|---------|-------------|
| `registries.clawhub.enabled` | bool | true | Enable ClawHub registry |
| `registries.clawhub.base_url` | string | `https://clawhub.ai` | ClawHub base URL |
| `registries.clawhub.search_path` | string | `/api/v1/search` | Search API path |
| `registries.clawhub.skills_path` | string | `/api/v1/skills` | Skills API path |
| `registries.clawhub.download_path` | string | `/api/v1/download` | Download API path |
| Config | Type | Default | Description |
| ---------------------------------- | ------ | -------------------- | ----------------------- |
| `registries.clawhub.enabled` | bool | true | Enable ClawHub registry |
| `registries.clawhub.base_url` | string | `https://clawhub.ai` | ClawHub base URL |
| `registries.clawhub.search_path` | string | `/api/v1/search` | Search API path |
| `registries.clawhub.skills_path` | string | `/api/v1/skills` | Skills API path |
| `registries.clawhub.download_path` | string | `/api/v1/download` | Download API path |

### Configuration Example

Expand All @@ -136,8 +209,10 @@ The skills tool configures skill discovery and installation via registries like
All configuration options can be overridden via environment variables with the format `PICOCLAW_TOOLS_<SECTION>_<KEY>`:

For example:

- `PICOCLAW_TOOLS_WEB_BRAVE_ENABLED=true`
- `PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS=false`
- `PICOCLAW_TOOLS_CRON_EXEC_TIMEOUT_MINUTES=10`
- `PICOCLAW_TOOLS_MCP_ENABLED=true`

Note: Array-type environment variables are not currently supported and must be set via the config file.
Note: Nested map-style config (for example `tools.mcp.servers.<name>.*`) is configured in `config.json` rather than environment variables.
Loading
Loading