feat: web access via MCP (Firecrawl search/scrape) + mcp server attach support
- agent/web_mcp.py: stdio MCP server exposing web_search and web_scrape, backed by the self-hosted Firecrawl stack on xNAS (no API key needed) - agent.py: Agent now attaches mcp_servers built from config; EXTRA_MCP_SERVERS env var allows adding arbitrary HTTP/SSE MCP servers as JSON - Dockerfile: installs livekit-agents[mcp], copies web_mcp.py - .env.example: WEB_MCP_ENABLED, FIRECRAWL_BASE, EXTRA_MCP_SERVERS documented
This commit is contained in:
+12
-10
@@ -17,7 +17,7 @@ COPY agent/pyproject.toml ./agent/
|
||||
RUN cd /app/agent && \
|
||||
uv venv .venv && \
|
||||
uv pip install --python .venv/bin/python \
|
||||
"livekit-agents~=1.7" \
|
||||
"livekit-agents[mcp]~=1.7" \
|
||||
"livekit-plugins-azure~=1.7" \
|
||||
"livekit-plugins-openai~=1.7" \
|
||||
"python-dotenv"
|
||||
@@ -29,7 +29,7 @@ ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Install LiveKit server binary + supervisord + nginx
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl ca-certificates supervisor nginx libasound2 \
|
||||
curl ca-certificates supervisor nginx libasound2 iproute2 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Download LiveKit server (latest stable)
|
||||
@@ -43,6 +43,7 @@ RUN curl -sSL "https://github.com/livekit/livekit/releases/download/${LIVEKIT_VE
|
||||
# Copy Python agent + venv from build stage
|
||||
COPY --from=build /app/agent/.venv /opt/voice-agent/.venv
|
||||
COPY agent/agent.py /opt/voice-agent/agent.py
|
||||
COPY agent/web_mcp.py /opt/voice-agent/web_mcp.py
|
||||
|
||||
# Copy web frontend + token endpoint
|
||||
COPY web/ /var/www/voice/
|
||||
@@ -52,22 +53,23 @@ COPY web/token_server.py /opt/voice/token_server.py
|
||||
COPY livekit.yaml /etc/livekit.yaml
|
||||
COPY supervisord.conf /etc/supervisor/conf.d/voice.conf
|
||||
|
||||
# Configure nginx to serve the voice UI on port 8090 over HTTPS (self-signed)
|
||||
# Configure nginx to serve the voice UI on port 8090 over HTTPS.
|
||||
# Browsers require a secure context (HTTPS or localhost) for microphone access.
|
||||
# The self-signed cert (with the LAN IP in the SAN) is generated at container
|
||||
# start by entrypoint.sh.
|
||||
RUN rm -f /etc/nginx/sites-enabled/default \
|
||||
&& mkdir -p /etc/voice/certs \
|
||||
&& openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
|
||||
-keyout /etc/voice/certs/key.pem \
|
||||
-out /etc/voice/certs/cert.pem \
|
||||
-subj "/CN=voice.local" \
|
||||
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1" \
|
||||
&& printf 'server {\n listen 8090;\n root /var/www/voice;\n index index.html;\n ssl_certificate /etc/voice/certs/cert.pem;\n ssl_certificate_key /etc/voice/certs/key.pem;\n location /token {\n proxy_pass http://127.0.0.1:8091/token;\n proxy_set_header Content-Type application/json;\n }\n location / {\n try_files $uri $uri/ =404;\n }\n}\n' \
|
||||
&& printf 'server {\n listen 8090 ssl;\n root /var/www/voice;\n index index.html;\n ssl_certificate /etc/voice/certs/cert.pem;\n ssl_certificate_key /etc/voice/certs/key.pem;\n location /token {\n proxy_pass http://127.0.0.1:8091/token;\n proxy_set_header Content-Type application/json;\n }\n location = /livekit {\n return 301 /livekit/;\n }\n location /livekit/ {\n proxy_pass http://127.0.0.1:7880/;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection "upgrade";\n proxy_set_header Host $host;\n proxy_read_timeout 3600s;\n proxy_send_timeout 3600s;\n }\n location / {\n try_files $uri $uri/ =404;\n }\n}\n' \
|
||||
> /etc/nginx/sites-available/voice \
|
||||
&& ln -sf /etc/nginx/sites-available/voice /etc/nginx/sites-enabled/voice
|
||||
|
||||
# Create non-root user for agent
|
||||
RUN useradd -m -s /bin/bash voiceuser || true
|
||||
|
||||
EXPOSE 7880 7881 8090 50000-60000/udp
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
EXPOSE 7880 7881 7882/udp 8090
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["supervisord", "-n", "-c", "/etc/supervisor/conf.d/voice.conf"]
|
||||
|
||||
Reference in New Issue
Block a user