Skip to content

Commit f562c02

Browse files
authored
Merge pull request #7 from NicholasGoh/feat/mcp-inspector
Feat/mcp inspector
2 parents 8a21a98 + 1955f4c commit f562c02

File tree

15 files changed

+164
-19
lines changed

15 files changed

+164
-19
lines changed

.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# change if required
2+
MCP_SERVER_PORT=8050

.github/workflows/build.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
services:
11+
docker:
12+
image: docker:dind
13+
options: --privileged
14+
volumes:
15+
- /var/run/docker.sock:/var/run/docker.sock
1016
env:
1117
MCP_SERVER_PORT: ${{ secrets.MCP_SERVER_PORT }}
1218
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
@@ -16,11 +22,17 @@ jobs:
1622
steps:
1723
- uses: actions/[email protected]
1824

25+
- name: Build production and development docker images
26+
run: |
27+
./community/youtube/build.sh
28+
docker compose build
29+
1930
- name: Run docker compose
2031
uses: hoverkraft-tech/[email protected]
2132
with:
2233
compose-file: "compose-dev.yaml"
23-
24-
- name: Build production and development docker images
25-
run: |
26-
docker compose build
34+
env:
35+
MCP_SERVER_PORT: ${{ secrets.MCP_SERVER_PORT }}
36+
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
37+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
38+
POSTGRES_DSN: ${{ secrets.POSTGRES_DSN }}

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
- [Core Features](#core-features)
66
- [Technology Stack and Features](#technology-stack-and-features)
77
- [Planned Features](#planned-features)
8+
- [Getting Started](#getting-started)
9+
- [Development](#development)
10+
- [VSCode Devcontainer](#vscode-devcontainer)
11+
- [Without VSCode Devcontainer](#without-vscode-devcontainer)
12+
- [Refactored Markdown Files](#refactored-markdown-files)
813
<!--toc:end-->
914

1015
## Core Features
@@ -39,3 +44,86 @@
3944
- :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)
4045
- Provision with [![Terraform](https://img.shields.io/github/stars/hashicorp/terraform?logo=terraform&label=Terraform)](https://github.com/hashicorp/terraform) IaC
4146
- Push built images to ECR and Dockerhub
47+
48+
## Getting Started
49+
50+
Build community youtube MCP image with:
51+
52+
```bash
53+
./community/youtube/build.sh
54+
```
55+
56+
> [!TIP]
57+
> 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.
58+
59+
Then build the other images with:
60+
61+
```bash
62+
docker compose -f compose-dev.yaml build
63+
```
64+
65+
Copy environment file:
66+
67+
```bash
68+
cp .env.sample .env
69+
```
70+
71+
Add your following API keys and value to the respective file: `./envs/backend.env`, `./envs/youtube.env` and `.env`.
72+
73+
```bash
74+
OPENAI_API_KEY=sk-proj-...
75+
POSTGRES_DSN=postgresql://postgres...
76+
YOUTUBE_API_KEY=...
77+
```
78+
79+
Set environment variables in shell: (compatible with `bash` and `zsh`)
80+
81+
```bash
82+
set -a; for env_file in ./envs/*; do source $env_file; done; set +a
83+
```
84+
85+
Start production containers:
86+
87+
```bash
88+
docker compose up -d
89+
```
90+
91+
## Development
92+
93+
### VSCode Devcontainer
94+
95+
> [!WARNING]
96+
> Only replace the following if you plan to start debugger for FastAPI server in VSCode.
97+
98+
Replace `./compose-dev.yaml` entrypoint to allow debugging FastAPI server:
99+
100+
```yaml
101+
# ...
102+
api:
103+
# ...
104+
# entrypoint: uv run fastapi run api/main.py --root-path=/api --reload
105+
# replace above with:
106+
entrypoint: bash -c "sleep infinity"
107+
# ...
108+
```
109+
110+
```bash
111+
code --no-sandbox .
112+
```
113+
114+
Press `F1` and type `Dev Containers: Rebuild and Reopen in Container` to open containerized environment with IntelliSense and Debugger for FastAPI.
115+
116+
### Without VSCode Devcontainer
117+
118+
Run development environment with:
119+
120+
```bash
121+
docker compose -f compose-dev.yaml up -d
122+
```
123+
124+
## Refactored Markdown Files
125+
126+
The following markdown files provide additional details on other features:
127+
128+
- [`./docs/mcp.md`](./docs/mcp.md)
129+
- [`./docs/supabase.md`](./docs/supabase.md)

backend/api/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"args": [
1313
"run",
1414
"api/main.py",
15+
"--root-path=/api",
1516
"--reload"
1617
]
1718
}

backend/api/core/config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@ class Settings(BaseSettings):
1414
mcp_server_port: int = 8050
1515

1616
postgres_dsn: PostgresDsn = (
17-
"postgresql+psycopg://postgres:[email protected]:6543/postgres"
17+
"postgresql://postgres:[email protected]:6543/postgres"
1818
)
1919

2020
@computed_field
2121
@property
2222
def orm_conn_str(self) -> str:
23-
return self.postgres_dsn.encoded_string()
23+
# NOTE: Explicitly follow LangGraph AsyncPostgresSaver
24+
# and use psycopg driver for ORM
25+
return self.postgres_dsn.encoded_string().replace(
26+
"postgresql://", "postgresql+psycopg://"
27+
)
2428

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

3236

3337
settings = Settings()

backend/mcp/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ FROM ghcr.io/astral-sh/uv:python3.13-bookworm
33
WORKDIR /app
44
COPY ./backend/mcp/uv.lock ./backend/mcp/pyproject.toml .
55
RUN uv sync --frozen && rm ./uv.lock ./pyproject.toml
6-
RUN apt-get update && apt-get install -y --no-install-recommends \
7-
curl
6+
RUN apt-get update && apt-get install -y --no-install-recommends curl
87
COPY ./backend/mcp ./mcp
98
COPY ./backend/shared_mcp ./shared_mcp
109
ENV PYTHONPATH /app:$PYTHONPATH
11-
ENV PATH /app:$PATH
1210
ENTRYPOINT ["uv", "run", "mcp/main.py"]

backend/shared_mcp/tools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
mcp = FastMCP(
66
"MCP Server",
7-
host=os.environ["MCP_SERVER_HOST"],
87
port=os.environ["MCP_SERVER_PORT"],
98
)
109

community/youtube/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
docker run --rm --entrypoint sh \
4+
--volume /var/run/docker.sock:/var/run/docker.sock \
5+
--workdir /app \
6+
docker:dind \
7+
-c "
8+
git clone https://github.com/Klavis-AI/klavis.git . && \
9+
touch mcp_servers/youtube/.env && \
10+
docker build -t youtube-mcp-server -f mcp_servers/youtube/Dockerfile .
11+
"

compose-dev.yaml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ services:
22
api:
33
image: api:prod
44
build:
5-
context: .
65
dockerfile: ./backend/api/Dockerfile
76
entrypoint: uv run fastapi run api/main.py --root-path=/api --reload
87
env_file:
9-
- ./envs/shared_mcp.env
8+
- ./envs/backend.env
109
ports:
1110
- 8000:8000
1211
volumes:
@@ -17,16 +16,41 @@ services:
1716
mcp:
1817
image: mcp:prod
1918
build:
20-
context: .
2119
dockerfile: ./backend/mcp/Dockerfile
22-
env_file:
23-
- ./envs/shared_mcp.env
20+
environment:
21+
- MCP_SERVER_PORT=${MCP_SERVER_PORT}
2422
ports:
25-
- 8050:8050
23+
- ${MCP_SERVER_PORT}:${MCP_SERVER_PORT}
2624
volumes:
2725
- ./backend/mcp:/app/mcp
2826
- ./backend/shared_mcp:/app/shared_mcp
2927

28+
youtube:
29+
image: youtube-mcp-server
30+
env_file:
31+
- ./envs/youtube.env
32+
environment:
33+
- YOUTUBE_MCP_SERVER_PORT=${MCP_SERVER_PORT}
34+
ports:
35+
- 5000:${MCP_SERVER_PORT}
36+
37+
dbhub:
38+
image: bytebase/dbhub:0.3.3
39+
ports:
40+
- 8080:${MCP_SERVER_PORT}
41+
command: >
42+
--transport sse
43+
--port ${MCP_SERVER_PORT}
44+
--dsn ${POSTGRES_DSN}
45+
46+
inspector:
47+
image: inspector:prod
48+
build:
49+
dockerfile: ./inspector/Dockerfile
50+
ports:
51+
- 6274:6274
52+
- 6277:6277
53+
3054
nginx:
3155
image: nginx:1.26.3-alpine
3256
ports:

docs/mcp.md

Whitespace-only changes.

0 commit comments

Comments
 (0)