Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# change if required
MCP_SERVER_PORT=8050
20 changes: 16 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
jobs:
build:
runs-on: ubuntu-latest
services:
docker:
image: docker:dind
options: --privileged
volumes:
- /var/run/docker.sock:/var/run/docker.sock
env:
MCP_SERVER_PORT: ${{ secrets.MCP_SERVER_PORT }}
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
Expand All @@ -16,11 +22,17 @@ jobs:
steps:
- uses: actions/[email protected]

- name: Build production and development docker images
run: |
./community/youtube/build.sh
docker compose build

- name: Run docker compose
uses: hoverkraft-tech/[email protected]
with:
compose-file: "compose-dev.yaml"

- name: Build production and development docker images
run: |
docker compose build
env:
MCP_SERVER_PORT: ${{ secrets.MCP_SERVER_PORT }}
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
POSTGRES_DSN: ${{ secrets.POSTGRES_DSN }}
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
- [Core Features](#core-features)
- [Technology Stack and Features](#technology-stack-and-features)
- [Planned Features](#planned-features)
- [Getting Started](#getting-started)
- [Development](#development)
- [VSCode Devcontainer](#vscode-devcontainer)
- [Without VSCode Devcontainer](#without-vscode-devcontainer)
- [Refactored Markdown Files](#refactored-markdown-files)
<!--toc:end-->

## Core Features
Expand Down Expand Up @@ -39,3 +44,86 @@
- :dollar: Deploy live demo to [![Fargate](https://img.shields.io/badge/Fargate-white.svg?logo=awsfargate)](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html)
- Provision with [![Terraform](https://img.shields.io/github/stars/hashicorp/terraform?logo=terraform&label=Terraform)](https://github.com/hashicorp/terraform) IaC
- Push built images to ECR and Dockerhub

## Getting Started

Build community youtube MCP image with:

```bash
./community/youtube/build.sh
```

> [!TIP]
> Instead of cloning or submoduling the repository locally, then building the image, this script builds the Docker image inside a temporary Docker-in-Docker container. This approach avoids polluting your local environment with throwaway files by cleaning up everything once the container exits.

Then build the other images with:

```bash
docker compose -f compose-dev.yaml build
```

Copy environment file:

```bash
cp .env.sample .env
```

Add your following API keys and value to the respective file: `./envs/backend.env`, `./envs/youtube.env` and `.env`.

```bash
OPENAI_API_KEY=sk-proj-...
POSTGRES_DSN=postgresql://postgres...
YOUTUBE_API_KEY=...
```

Set environment variables in shell: (compatible with `bash` and `zsh`)

```bash
set -a; for env_file in ./envs/*; do source $env_file; done; set +a
```

Start production containers:

```bash
docker compose up -d
```

## Development

### VSCode Devcontainer

> [!WARNING]
> Only replace the following if you plan to start debugger for FastAPI server in VSCode.

Replace `./compose-dev.yaml` entrypoint to allow debugging FastAPI server:

```yaml
# ...
api:
# ...
# entrypoint: uv run fastapi run api/main.py --root-path=/api --reload
# replace above with:
entrypoint: bash -c "sleep infinity"
# ...
```

```bash
code --no-sandbox .
```

Press `F1` and type `Dev Containers: Rebuild and Reopen in Container` to open containerized environment with IntelliSense and Debugger for FastAPI.

### Without VSCode Devcontainer

Run development environment with:

```bash
docker compose -f compose-dev.yaml up -d
```

## Refactored Markdown Files

The following markdown files provide additional details on other features:

- [`./docs/mcp.md`](./docs/mcp.md)
- [`./docs/supabase.md`](./docs/supabase.md)
1 change: 1 addition & 0 deletions backend/api/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"args": [
"run",
"api/main.py",
"--root-path=/api",
"--reload"
]
}
Expand Down
10 changes: 7 additions & 3 deletions backend/api/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ class Settings(BaseSettings):
mcp_server_port: int = 8050

postgres_dsn: PostgresDsn = (
"postgresql+psycopg://postgres:[email protected]:6543/postgres"
"postgresql://postgres:[email protected]:6543/postgres"
)

@computed_field
@property
def orm_conn_str(self) -> str:
return self.postgres_dsn.encoded_string()
# NOTE: Explicitly follow LangGraph AsyncPostgresSaver
# and use psycopg driver for ORM
return self.postgres_dsn.encoded_string().replace(
"postgresql://", "postgresql+psycopg://"
)

@computed_field
@property
def checkpoint_conn_str(self) -> str:
# NOTE: LangGraph AsyncPostgresSaver has some issues
# with specifying psycopg driver explicitly
return self.postgres_dsn.encoded_string().replace("+psycopg", "")
return self.postgres_dsn.encoded_string()


settings = Settings()
4 changes: 1 addition & 3 deletions backend/mcp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ FROM ghcr.io/astral-sh/uv:python3.13-bookworm
WORKDIR /app
COPY ./backend/mcp/uv.lock ./backend/mcp/pyproject.toml .
RUN uv sync --frozen && rm ./uv.lock ./pyproject.toml
RUN apt-get update && apt-get install -y --no-install-recommends \
curl
RUN apt-get update && apt-get install -y --no-install-recommends curl
COPY ./backend/mcp ./mcp
COPY ./backend/shared_mcp ./shared_mcp
ENV PYTHONPATH /app:$PYTHONPATH
ENV PATH /app:$PATH
ENTRYPOINT ["uv", "run", "mcp/main.py"]
1 change: 0 additions & 1 deletion backend/shared_mcp/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

mcp = FastMCP(
"MCP Server",
host=os.environ["MCP_SERVER_HOST"],
port=os.environ["MCP_SERVER_PORT"],
)

Expand Down
11 changes: 11 additions & 0 deletions community/youtube/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

docker run --rm --entrypoint sh \
--volume /var/run/docker.sock:/var/run/docker.sock \
--workdir /app \
docker:dind \
-c "
git clone https://github.com/Klavis-AI/klavis.git . && \
touch mcp_servers/youtube/.env && \
docker build -t youtube-mcp-server -f mcp_servers/youtube/Dockerfile .
"
36 changes: 30 additions & 6 deletions compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ services:
api:
image: api:prod
build:
context: .
dockerfile: ./backend/api/Dockerfile
entrypoint: uv run fastapi run api/main.py --root-path=/api --reload
env_file:
- ./envs/shared_mcp.env
- ./envs/backend.env
ports:
- 8000:8000
volumes:
Expand All @@ -17,16 +16,41 @@ services:
mcp:
image: mcp:prod
build:
context: .
dockerfile: ./backend/mcp/Dockerfile
env_file:
- ./envs/shared_mcp.env
environment:
- MCP_SERVER_PORT=${MCP_SERVER_PORT}
ports:
- 8050:8050
- ${MCP_SERVER_PORT}:${MCP_SERVER_PORT}
volumes:
- ./backend/mcp:/app/mcp
- ./backend/shared_mcp:/app/shared_mcp

youtube:
image: youtube-mcp-server
env_file:
- ./envs/youtube.env
environment:
- YOUTUBE_MCP_SERVER_PORT=${MCP_SERVER_PORT}
ports:
- 5000:${MCP_SERVER_PORT}

dbhub:
image: bytebase/dbhub:0.3.3
ports:
- 8080:${MCP_SERVER_PORT}
command: >
--transport sse
--port ${MCP_SERVER_PORT}
--dsn ${POSTGRES_DSN}

inspector:
image: inspector:prod
build:
dockerfile: ./inspector/Dockerfile
ports:
- 6274:6274
- 6277:6277

nginx:
image: nginx:1.26.3-alpine
ports:
Expand Down
Empty file added docs/mcp.md
Empty file.
Empty file added docs/supabase.md
Empty file.
1 change: 1 addition & 0 deletions envs/backend.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
OPENAI_API_KEY=
# do not specify driver (do not specify `+psycopg`)
POSTGRES_DSN=
2 changes: 0 additions & 2 deletions envs/shared_mcp.env

This file was deleted.

1 change: 1 addition & 0 deletions envs/youtube.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
YOUTUBE_API_KEY=
6 changes: 6 additions & 0 deletions inspector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:22.15.0-alpine

WORKDIR /app
RUN apk update && apk add curl && \
npm install -g @modelcontextprotocol/inspector
ENTRYPOINT ["npx", "@modelcontextprotocol/inspector"]