### Example Agent Direct Response Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/docs/langfuse.md This snippet illustrates a direct agent response to a user query without invoking any external tools, showcasing a simple interaction within the chat history. ```text User: reply only no Agent: No. ``` -------------------------------- ### Example Environment Variable Configuration Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This snippet provides an example of essential environment variables required for the project, including API keys for OpenAI, PostgreSQL DSN, Langfuse credentials, and a YouTube API key. These variables are crucial for the application's functionality and external service integrations. ```bash OPENAI_API_KEY=sk-proj-... POSTGRES_DSN=postgresql://postgres... LANGFUSE_PUBLIC_KEY=pk-lf-... LANGFUSE_SECRET_KEY=sk-lf-... LANGFUSE_HOST=https://cloud.langfuse.com ENVIRONMENT=production YOUTUBE_API_KEY=... ``` -------------------------------- ### Start Development Docker Containers Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This command starts the project's services in detached mode using Docker Compose, specifically using the `compose-dev.yaml` file. It brings up all defined services for the development environment, facilitating local development and testing. ```bash docker compose -f compose-dev.yaml up -d ``` -------------------------------- ### Template Setup Architecture Diagram Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This diagram depicts the current template's architecture, showing the API Server's communication with a Custom Server and Supabase DB. It highlights that not all MCP servers are connected in this specific template setup. ```mermaid graph LR subgraph localhost A[API Server] B[DBHub Server] C[Youtube Server] D[Custom Server] end subgraph Supabase Cloud E[Supabase DB] end A<-->|Protocol|D A<-->E ``` -------------------------------- ### Define a Custom MCP Server with Tools and Resources in Python Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/docs/mcp.md This Python code demonstrates how to initialize a custom Model Context Protocol (MCP) server using the `FastMCP` library. It defines two distinct endpoints: a 'tool' named 'add' for performing basic arithmetic operations, and a 'resource' named 'get_greeting' that provides a personalized greeting based on a given name. This example illustrates how to expose custom functionalities and data resources to LLMs via the MCP. ```python import os from mcp.server.fastmcp import FastMCP mcp = FastMCP( "MCP Server", port=os.environ["MCP_SERVER_PORT"], ) @mcp.tool() def add(a: int, b: int) -> int: """Add two numbers""" return a + b @mcp.resource("greeting://{name}") def get_greeting(name: str) -> str: """Get a personalized greeting""" return f"Hello, {name}!" ``` -------------------------------- ### Start Production Docker Containers Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This command starts the project's services in detached mode using Docker Compose, based on the default production configuration. It brings up all defined services for production deployment, allowing the application to run in the background. ```bash docker compose up -d ``` -------------------------------- ### Monitoring and Observability Architecture Diagram Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This diagram outlines the planned monitoring and observability setup, showing the API Server sending metrics and logs to Grafana Cloud, and traces and events to Langfuse Cloud. This setup enables comprehensive insights into application performance and behavior. ```mermaid graph LR subgraph localhost A[API Server] end subgraph Grafana Cloud B[Grafana] end subgraph Langfuse Cloud C[Langfuse] end A -->|Metrics & Logs| B A -->|Traces & Events| C ``` -------------------------------- ### Override FastAPI Devcontainer Entrypoint for Debugging Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This YAML snippet shows how to modify the `compose-dev.yaml` file to change the `api` service's entrypoint. By setting `entrypoint: bash -c "sleep infinity"`, it allows the container to stay alive without immediately starting the FastAPI server, enabling debugging from VSCode. ```yaml api: image: api:prod build: dockerfile: ./backend/api/Dockerfile # highlight-next-line entrypoint: bash -c "sleep infinity" env_file: - ./envs/backend.env ``` -------------------------------- ### Copy Sample Environment File Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This command copies the sample environment file (`.env.sample`) to `.env`. This is a common practice to initialize local environment variables for the project, allowing users to customize configurations. ```bash cp .env.sample .env ``` -------------------------------- ### Build Community Youtube MCP Docker Image Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This bash script builds the Docker image for the community YouTube MCP server. It's designed to run within a temporary Docker-in-Docker container, which helps avoid polluting the local environment with throwaway files by cleaning up everything once the container exits. ```bash ./community/youtube/build.sh ``` -------------------------------- ### Build All Other Docker Compose Images Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This command uses Docker Compose to build all other service images defined in the `compose-dev.yaml` file. It's a standard step after building specific community images to ensure all project services are ready. ```bash docker compose -f compose-dev.yaml build ``` -------------------------------- ### Source All Environment Variables from Files Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This bash command sources all environment variable files located in the `./envs/` directory. It's compatible with `bash` and `zsh` and ensures that all necessary environment variables are loaded into the current shell session for proper application execution. ```bash set -a; for env_file in ./envs/*; do source $env_file; done; set +a ``` -------------------------------- ### Open VSCode in No-Sandbox Mode Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This command opens VSCode in the current directory with the `--no-sandbox` flag. This is often required when running VSCode within certain containerized or virtualized environments, ensuring compatibility and proper functionality. ```bash code --no-sandbox . ``` -------------------------------- ### Inspector Service Architecture Diagram Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This diagram illustrates the architecture of the Inspector service and its communication with various MCP servers (DBHub, Youtube, Custom) and external cloud services like Supabase DB and Google Cloud's Youtube API. It shows the interaction protocols between components. ```mermaid graph LR subgraph localhost A[Inspector] B[DBHub Server] C[Youtube Server] D[Custom Server] end subgraph Supabase Cloud E[Supabase DB] end subgraph Google Cloud F[Youtube API] end A<-->|Protocol|B A<-->|Protocol|C A<-->|Protocol|D B<-->E C<-->F ``` -------------------------------- ### Reverse Proxy Architecture Diagram Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This diagram illustrates the role of an Nginx Reverse Proxy in the system, mediating requests from a Web Browser to the API Server. It suggests extensibility for other self-hosted services like a Frontend or certain backend services. ```mermaid graph LR A[Web Browser] subgraph localhost B[Nginx Reverse Proxy] C[API Server] end A-->B B-->C ``` -------------------------------- ### Reload Nginx Configuration in Docker Compose Source: https://github.com/nicholasgoh/fastapi-mcp-langgraph-template/blob/main/README.md This Bash command executes inside the 'nginx' service within a 'docker compose' development environment to force a reload of its configuration. This is often necessary during development to apply new routing rules or service configurations without restarting the entire container. ```bash docker compose -f compose-dev.yaml exec nginx sh -c "nginx -s reload" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.