LangGraph FastAPI MCP Server Demo

LangGraph FastAPI MCP Server Demo

Turns a shopping list FastAPI app into an MCP server, enabling a LangGraph chatbot to manage shopping lists via natural language.

Category
Visit Server

README

LangGraph FastAPI MCP Server Demo

This is a sample project that turns a shopping list FastAPI app into an MCP server and connects a LangGraph based chatbot to the MCP server so that it can manage the user's shopping list via chat.

Watch the video

Technology Stack

  • FastAPI: a modern, fast (high-performance), web framework for building APIs with Python 3
  • FastAPI-MCP: an open-source library that exposes your FastAPI endpoints as Model Context Protocol (MCP) tools (with Auth)
  • MCP (Model Context Protocol): an open protocol that facilitates seamless interaction between AI models and external data sources or tools
  • LangChain: An opens-source framework that helps developers build applications powered by large language models (LLMs)
  • LangGraph: An opens-source framework by LangChain for building and managing complex AI agents using graph-based architecture
  • ChatGPT: A popular LLM provided by OpenAI
  • Gradio: A popular opens-source library for building web interfaces for machine learning models. This project uses Gradio to create a web interface for the chatbot.
  • LangSmith: An opens-source framework by LangChain for tracing and monitoring LLM applications.
  • uv: A fast opens-source Python package manager - a drop-in replacement for pip, conda and virtualenv.

Quick Start

1. Install uv

Follow the instructions here to install uv, if you haven't already.

2. Install Dependencies

uv sync

3. Set Up OpenAI API Key

Create a .env file in the project root:

# .env
OPENAI_API_KEY=your-openai-api-key-here

4. Run the FastAPI app

uv run uvicorn server.main:app --host 0.0.0.0 --port 8000 --reload

Try the FastAPI app at http://localhost:8000/docs

5. Run the Chatbot

uv run chatbot.py

The chatbot will be available at http://localhost:7860

Usage Examples

Try these example queries in the chatbot:

  • "I need to buy a watermelon",
  • "What's in my shopping list?",
  • "Let's add spaghetti and tomato sauce",
  • "I just bought the watermelon",
  • "Remove the tomato sauce",
  • "I need an extra spaghetti",

Dependencies

  • LangGraph: For creating the React agent
  • Gradio: For the chat interface
  • LangChain OpenAI: For the language model integration
  • LangChain Core: For tool definitions
  • FastAPI: For the MCP server
  • SQLAlchemy: For database operations

License

This project is open source and available under the MIT License.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured