Skip to content

Commit 94a1228

Browse files
authored
Merge pull request #8 from NicholasGoh/feat/fastapi-mcp-langgraph-template
Feat/fastapi mcp langgraph template
2 parents eeed56d + d88fefd commit 94a1228

22 files changed

+284
-538
lines changed

docs/tutorial-basics/_category_.json renamed to docs/getting-started/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"label": "Tutorial - Basics",
2+
"label": "Getting Started",
33
"position": 2,
44
"link": {
55
"type": "generated-index",
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
import ReactPlayer from 'react-player'
6+
7+
# Model Context Protocol
8+
9+
[![MCP Client](https://img.shields.io/github/stars/modelcontextprotocol/python-sdk?logo=modelcontextprotocol&label=MCP-Client)](https://github.com/modelcontextprotocol/python-sdk) [![MCP Server](https://img.shields.io/github/stars/modelcontextprotocol/servers?logo=modelcontextprotocol&label=MCP-Servers)](https://github.com/modelcontextprotocol/servers)
10+
11+
:::info
12+
13+
> MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.
14+
15+
:::
16+
17+
Learn more [here](https://modelcontextprotocol.io/introduction).
18+
19+
## Video Demo
20+
21+
<ReactPlayer playing controls url='/vid/fastapi-mcp-langgraph-template/mcps.mp4' />
22+
23+
## Key Features
24+
25+
> MCP helps you build agents and complex workflows on top of LLMs. LLMs frequently need to integrate with data and tools, and MCP provides:
26+
> - A growing list of pre-built integrations that your LLM can directly plug into
27+
> - The flexibility to switch between LLM providers and vendors
28+
> - Best practices for securing your data within your infrastructure
29+
30+
## Inspector
31+
32+
Explore community and your custom MCP servers via Inspector at [http://localhost:6274](http://localhost:6274) in [Development](./quick-start#development).
33+
34+
Left Sidebar:
35+
36+
- Select SSE `Transport Type`
37+
- Input `http://<mcp server>:<MCP_SERVER_PORT>/sse` in `URL`
38+
- Click `Connect`
39+
40+
Explore the following tabs in the Top Navbar:
41+
42+
- `Resources`
43+
- `Prompts`
44+
- `Tools`
45+
46+
## Community MCP Servers
47+
48+
Before building your own custom MCP servers, explore the growing list of hundreds of [community MCP servers](https://github.com/modelcontextprotocol/servers). With integrations spanning databases, cloud services, and web resources, the perfect fit might already exist.
49+
50+
### DBHub
51+
52+
Learn more [here](https://github.com/bytebase/dbhub). Explore more in [Inspector](#inspector).
53+
54+
Easily plug in this MCP into LLM to allow LLM to:
55+
56+
- Perform read-only SQL query validation for secure operations
57+
- Enable deterministic introspection of DB
58+
- List schemas
59+
- List tables in schemas
60+
- Retrieve table structures
61+
- Enrich user queries deterministically
62+
- Ground DB related queries with DB schemas
63+
- Provide SQL templates for translating natural language to SQL
64+
65+
### Youtube
66+
67+
Learn more [here](https://github.com/Klavis-AI/klavis/tree/main/mcp_servers/youtube). Explore more in [Inspector](#inspector).
68+
69+
Instead of building logic to:
70+
71+
- Scrape YouTube content
72+
- Adapt outputs for LLM compatibility
73+
- Validate tool invocation by the LLM
74+
- Chain these steps to fetch transcripts from URLs
75+
76+
Simply plug in this MCP to enable LLM to:
77+
78+
- Fetch transcripts from any YouTube URL on demand
79+
80+
## Custom MCP
81+
82+
Should you require a custom MCP server, a template is provided [here](https://github.com/NicholasGoh/fastapi-mcp-langgraph-template/blob/main/backend/shared_mcp/tools.py) for you to reference in development.
83+
84+
```python title="./backend/shared_mcp/tools.py"
85+
import os
86+
87+
from mcp.server.fastmcp import FastMCP
88+
89+
mcp = FastMCP(
90+
"MCP Server",
91+
port=os.environ["MCP_SERVER_PORT"],
92+
)
93+
94+
95+
@mcp.tool()
96+
def add(a: int, b: int) -> int:
97+
"""Add two numbers"""
98+
return a + b
99+
100+
101+
@mcp.resource("greeting://{name}")
102+
def get_greeting(name: str) -> str:
103+
"""Get a personalized greeting"""
104+
return f"Hello, {name}!"
105+
```

docs/getting-started/quick-start.mdx

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
import ReactPlayer from 'react-player'
6+
7+
# Quick Start
8+
9+
Build community youtube MCP image with:
10+
11+
```bash
12+
./community/youtube/build.sh
13+
```
14+
15+
:::tip
16+
17+
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.
18+
19+
:::
20+
21+
Then build the other images with:
22+
23+
```bash
24+
docker compose -f compose-dev.yaml build
25+
```
26+
27+
Copy environment file:
28+
29+
```bash
30+
cp .env.sample .env
31+
```
32+
33+
Add your following API keys and value to the respective file: `./envs/backend.env`, `./envs/youtube.env` and `.env`.
34+
35+
```bash
36+
OPENAI_API_KEY=sk-proj-...
37+
POSTGRES_DSN=postgresql://postgres...
38+
YOUTUBE_API_KEY=...
39+
```
40+
41+
Set environment variables in shell: (compatible with `bash` and `zsh`)
42+
43+
```bash
44+
set -a; for env_file in ./envs/*; do source $env_file; done; set +a
45+
```
46+
47+
Start production containers:
48+
49+
```bash
50+
docker compose up -d
51+
```
52+
53+
<ReactPlayer playing controls url='/vid/fastapi-mcp-langgraph-template/api.mp4' />
54+
55+
## Development
56+
57+
First, set environment variables as per above.
58+
59+
### VSCode Devcontainer
60+
61+
<ReactPlayer playing controls url='/vid/fastapi-mcp-langgraph-template/vscode.mp4' />
62+
63+
<br/>
64+
65+
:::warning
66+
67+
Only replace the following if you plan to start debugger for FastAPI server in VSCode.
68+
69+
:::
70+
71+
Replace `./compose-dev.yaml` entrypoint to allow debugging FastAPI server:
72+
73+
```yaml title="./compose-dev.yaml"
74+
api:
75+
image: api:prod
76+
build:
77+
dockerfile: ./backend/api/Dockerfile
78+
# highlight-next-line
79+
entrypoint: bash -c "sleep infinity"
80+
env_file:
81+
- ./envs/backend.env
82+
```
83+
84+
Then:
85+
86+
```bash
87+
code --no-sandbox .
88+
```
89+
90+
Press `F1` and type `Dev Containers: Rebuild and Reopen in Container` to open containerized environment with IntelliSense and Debugger for FastAPI.
91+
92+
### Without VSCode Devcontainer
93+
94+
Run development environment with:
95+
96+
```bash
97+
docker compose -f compose-dev.yaml up -d
98+
```
99+
100+
## Debugging
101+
102+
Sometimes in development, nginx reverse proxy needs to reload its config to route services properly.
103+
104+
```bash
105+
docker compose -f compose-dev.yaml exec nginx sh -c "nginx -s reload"
106+
```

docs/getting-started/supabase.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
import ReactPlayer from 'react-player'
6+
7+
# Supabase
8+
9+
[![Supabase](https://img.shields.io/github/stars/supabase/supabase?logo=supabase&label=Supabase)](https://github.com/supabase/supabase)
10+
11+
The start of the video shows how you can get your `POSTGRES_DSN` URL.
12+
13+
## Video Demo
14+
15+
<ReactPlayer playing controls url='/vid/fastapi-mcp-langgraph-template/supabase.mp4' />
16+
17+
## Features
18+
19+
Visit [here](https://supabase.com/) for a full list of features and learn more.
20+
21+
- Postgres Relational Database
22+
- Authentication
23+
- User Sign up and Login
24+
- Row and Column Security
25+
- Data APIs
26+
- Auto Generated from Table Schema
27+
- Self Host for free
28+
- Free Cloud usage for rapid prototyping

docs/intro.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

docs/intro.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
sidebar_position: 1
3+
title: Introduction
4+
---
5+
6+
# Introduction
7+
8+
A modern template for agentic orchestration — built for rapid iteration and scalable deployment using highly customizable, community-supported tools like MCP, LangGraph, and more.
9+
10+
Visit the [Github](https://github.com/NicholasGoh/fastapi-mcp-langgraph-template)
11+
12+
## Core Features
13+
14+
[![MCP Client](https://img.shields.io/github/stars/modelcontextprotocol/python-sdk?logo=modelcontextprotocol&label=MCP-Client)](https://github.com/modelcontextprotocol/python-sdk) is an open protocol that standardizes how apps provide context to LLMs.
15+
- Seamlessly integrates LLM with growing list of community integrations found here [![MCP Server](https://img.shields.io/github/stars/modelcontextprotocol/servers?logo=modelcontextprotocol&label=MCP-Servers)](https://github.com/modelcontextprotocol/servers)
16+
- No LLM provider lock in
17+
18+
[![LangGraph](https://img.shields.io/github/stars/langchain-ai/langgraph?logo=langgraph&label=LangGraph)](https://github.com/langchain-ai/langgraph) for Customizable Agentic Orchestration
19+
- Native streaming for UX in complex Agentic Workflows
20+
- Native persisted chat history and state management
21+
22+
### Technology Stack and Features
23+
24+
- [![FastAPI](https://img.shields.io/github/stars/fastapi/fastapi?logo=fastapi&label=fastapi)](https://github.com/fastapi/fastapi) for Python backend API
25+
- [![SQLModel](https://img.shields.io/github/stars/fastapi/sqlmodel?logo=sqlmodel&label=SQLModel)](https://github.com/fastapi/sqlmodel) for Python SQL database interactions (ORM + Validation).
26+
- Wrapper of [![SQLAlchemy](https://img.shields.io/github/stars/sqlalchemy/sqlalchemy?logo=sqlalchemy&label=SQLAlchemy)](https://github.com/sqlalchemy/sqlalchemy)
27+
- [![Pydantic](https://img.shields.io/github/stars/pydantic/pydantic?logo=pydantic&label=Pydantic)](https://github.com/pydantic/pydantic) for Data Validation and Settings Management.
28+
- [![Supabase](https://img.shields.io/github/stars/supabase/supabase?logo=supabase&label=Supabase)](https://github.com/supabase/supabase) for DB RBAC
29+
- [![PostgreSQL](https://img.shields.io/github/stars/postgres/postgres?logo=postgresql&label=Postgres)](https://github.com/postgres/postgres) Relational DB
30+
- [![PGVector](https://img.shields.io/github/stars/pgvector/pgvector?logo=postgresql&label=PGVector)](https://github.com/pgvector/pgvector) Vector Store
31+
- [![Nginx](https://img.shields.io/github/stars/nginx/nginx?logo=nginx&label=Nginx)](https://github.com/nginx/nginx) Reverse Proxy
32+
- [![Compose](https://img.shields.io/github/stars/docker/compose?logo=docker&label=Compose)](https://github.com/docker/compose) for development and production.
33+
34+
### Planned Features
35+
36+
- [![LangFuse](https://img.shields.io/github/stars/langfuse/langfuse?logo=langfuse&label=LangFuse)](https://github.com/langfuse/langfuse) for LLM Observability and LLM Metrics
37+
- [![Prometheus](https://img.shields.io/github/stars/prometheus/prometheus?logo=prometheus&label=Prometheus)](https://github.com/prometheus/prometheus) for scraping Metrics
38+
- [![Grafana](https://img.shields.io/github/stars/prometheus/prometheus?logo=grafana&label=Grafana)](https://github.com/grafana/grafana) for visualizing Metrics
39+
- [![Auth0](https://img.shields.io/badge/Auth0-white?logo=auth0)](https://auth0.com/docs) SaaS for JWT authentication
40+
- CI/CD via Github Actions
41+
- :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)
42+
- Provision with [![Terraform](https://img.shields.io/github/stars/hashicorp/terraform?logo=terraform&label=Terraform)](https://github.com/hashicorp/terraform) IaC
43+
- Push built images to ECR and Dockerhub

docs/tutorial-basics/congratulations.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/tutorial-basics/create-a-blog-post.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)