feat(cli): phase 1 - local cli with docker integration

This commit is contained in:
2025-03-10 21:08:48 -06:00
parent fde6529d54
commit 64430830d8
21 changed files with 1711 additions and 9 deletions

42
drivers/goose/Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
FROM python:3.12-slim
LABEL maintainer="team@monadical.com"
LABEL description="Goose with MCP servers"
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
openssh-server \
bash \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set up SSH server
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
# Create app directory
WORKDIR /app
# Copy initialization scripts
COPY mai-init.sh /mai-init.sh
COPY entrypoint.sh /entrypoint.sh
COPY mai-driver.yaml /mai-driver.yaml
# Make scripts executable
RUN chmod +x /mai-init.sh /entrypoint.sh
# Install python dependencies
RUN pip install --no-cache-dir goose-ai langfuse
# Set up environment
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Expose ports
EXPOSE 8000 22
# Set entrypoint
ENTRYPOINT ["/entrypoint.sh"]

47
drivers/goose/README.md Normal file
View File

@@ -0,0 +1,47 @@
# Goose Driver for MC
This driver provides a containerized environment for running [Goose](https://goose.ai) with MCP servers.
## Features
- Pre-configured environment for Goose AI
- MCP server integration
- SSH access
- Git repository integration
- Langfuse logging support
## Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| `MCP_HOST` | MCP server host | Yes |
| `GOOSE_API_KEY` | Goose API key | Yes |
| `GOOSE_ID` | Goose instance ID | No |
| `LANGFUSE_PUBLIC_KEY` | Langfuse public key | No |
| `LANGFUSE_SECRET_KEY` | Langfuse secret key | No |
| `LANGFUSE_HOST` | Langfuse API host | No |
| `MC_PROJECT_URL` | Project repository URL | No |
| `MC_GIT_SSH_KEY` | SSH key for Git authentication | No |
| `MC_GIT_TOKEN` | Token for Git authentication | No |
## Build
To build this driver:
```bash
cd drivers/goose
docker build -t monadical/mc-goose:latest .
```
## Usage
```bash
# Create a new session with this driver
mc session create --driver goose
# Create with specific MCP server
mc session create --driver goose -e MCP_HOST=http://mcp.example.com:8000
# Create with project repository
mc session create --driver goose --project github.com/username/repo
```

17
drivers/goose/entrypoint.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Entrypoint script for Goose driver
# Run the standard initialization script
/mai-init.sh
# Start SSH server in the background
/usr/sbin/sshd
# Print welcome message
echo "==============================================="
echo "Goose driver container started"
echo "SSH server running on port 22"
echo "==============================================="
# Keep container running
exec tail -f /dev/null

View File

@@ -0,0 +1,66 @@
name: goose
description: Goose with MCP servers
version: 1.0.0
maintainer: team@monadical.com
init:
pre_command: /mai-init.sh
command: /entrypoint.sh
environment:
- name: MCP_HOST
description: MCP server host
required: true
default: http://localhost:8000
- name: GOOSE_API_KEY
description: Goose API key
required: true
sensitive: true
- name: GOOSE_ID
description: Goose instance ID
required: false
- name: LANGFUSE_PUBLIC_KEY
description: Langfuse public key
required: false
sensitive: true
- name: LANGFUSE_SECRET_KEY
description: Langfuse secret key
required: false
sensitive: true
- name: LANGFUSE_HOST
description: Langfuse API host
required: false
default: https://api.langfuse.com
# Project environment variables
- name: MC_PROJECT_URL
description: Project repository URL
required: false
- name: MC_PROJECT_TYPE
description: Project repository type (git, svn, etc.)
required: false
default: git
- name: MC_GIT_SSH_KEY
description: SSH key for Git authentication
required: false
sensitive: true
- name: MC_GIT_TOKEN
description: Token for Git authentication
required: false
sensitive: true
ports:
- 8000 # Main application
- 22 # SSH server
volumes:
- mountPath: /app
description: Application directory

54
drivers/goose/mai-init.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
# Standardized initialization script for MC drivers
# Project initialization
if [ -n "$MC_PROJECT_URL" ]; then
echo "Initializing project: $MC_PROJECT_URL"
# Set up SSH key if provided
if [ -n "$MC_GIT_SSH_KEY" ]; then
mkdir -p ~/.ssh
echo "$MC_GIT_SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
ssh-keyscan gitlab.com >> ~/.ssh/known_hosts 2>/dev/null
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts 2>/dev/null
fi
# Set up token if provided
if [ -n "$MC_GIT_TOKEN" ]; then
git config --global credential.helper store
echo "https://$MC_GIT_TOKEN:x-oauth-basic@github.com" > ~/.git-credentials
fi
# Clone repository
git clone $MC_PROJECT_URL /app
cd /app
# Run project-specific initialization if present
if [ -f "/app/.mc/init.sh" ]; then
bash /app/.mc/init.sh
fi
fi
# Set up Goose API key if provided
if [ -n "$GOOSE_API_KEY" ]; then
echo "Setting up Goose API key"
export GOOSE_API_KEY="$GOOSE_API_KEY"
fi
# Set up MCP connection if provided
if [ -n "$MCP_HOST" ]; then
echo "Setting up MCP connection to $MCP_HOST"
export MCP_HOST="$MCP_HOST"
fi
# Set up Langfuse logging if credentials are provided
if [ -n "$LANGFUSE_SECRET_KEY" ] && [ -n "$LANGFUSE_PUBLIC_KEY" ]; then
echo "Setting up Langfuse logging"
export LANGFUSE_SECRET_KEY="$LANGFUSE_SECRET_KEY"
export LANGFUSE_PUBLIC_KEY="$LANGFUSE_PUBLIC_KEY"
export LANGFUSE_HOST="${LANGFUSE_HOST:-https://api.langfuse.com}"
fi
echo "MC driver initialization complete"