LangGraph FastAPI MCP Server

LangGraph FastAPI MCP Server

Enables LLM-powered agents to securely communicate with and orchestrate downstream microservices via FastAPI endpoints exposed as MCP tools.

Category
Visit Server

README

LangGraph FastAPI MCP Server & Agent Platform

A robust, enterprise-grade integration framework that combines LangGraph (agentic workflows) with FastAPI MCP Servers (Model Context Protocol). This architecture enables LLM-powered agents to communicate securely and dynamically with downstream microservices via Server-Sent Events (SSE) transport.

Watch the video

Technology Stack

  • FastAPI: A modern, high-performance web framework for building APIs with Python 3.11+.
  • FastAPI-MCP: An open-source library that exposes FastAPI endpoints as Model Context Protocol (MCP) tools.
  • MCP (Model Context Protocol): An open standard that facilitates seamless interaction between LLMs and external data/tools.
  • LangChain: An open-source framework for building applications powered by large language models.
  • LangGraph: A framework for building stateful, multi-actor applications with LLMs, ideal for agentic loops.
  • Gradio: An open-source library used to build the high-fidelity web chat interface.
  • LangSmith: An observability platform for tracing, debugging, and monitoring LLM applications.
  • uv: An extremely fast Python package manager and resolver.

📊 System Architecture

The diagram below details the integration between the chatbot agent UI, the LangGraph orchestration engine, the MCP client gateway, and the FastAPI service backend.

graph TD
    User([User / Operator]) <-->|Chat Interface| Gradio[Gradio Web UI]
    Gradio <-->|Interacts with| LangGraphAgent[LangGraph ReAct Agent]
    LangGraphAgent <-->|Invokes Tools via| MCPClient[MCP Multi-Server Client]
    MCPClient <-->|SSE Transport| FastAPIMCP[FastAPI MCP Server]
    FastAPIMCP <-->|Resolves Routes| APIRoutes[FastAPI Endpoints]
    APIRoutes <-->|CRUD Operations| SQLASession[SQLAlchemy AsyncSession]
    SQLASession <-->|Reads/Writes| SQLite[(SQLite Database)]

🚀 Getting Started

1. Installation

Ensure you have uv installed.

Clone the repository and install all dependencies:

git clone https://github.com/gilish-tech/ai-shopping-assistant-mcp-server.git
cd ai-shopping-assistant-mcp-server
uv sync

2. Environment Configuration

Create a .env file in the project root:

# OpenAI Configuration
OPENAI_API_KEY=your-openai-api-key-here

# Optional: LangSmith Tracing & Observability
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
LANGCHAIN_API_KEY=your-langsmith-api-key-here
LANGCHAIN_PROJECT=langgraph-fastapi-mcp-server

3. Start the FastAPI MCP Service

Launch the FastAPI server which auto-exposes its routes as MCP tools:

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

4. Start the Agent Client

Launch the Gradio chat interface to interact with the LangGraph agent:

uv run chatbot.py

🛠️ Production Readiness & Deployment

To move this system into a production environment, follow these best practices:

  1. Database Migrations: Apply changes to the schema using Alembic:
    uv run alembic upgrade head
    
  2. Production Web Server: Run the FastAPI application using uvicorn with multiple workers or behind a reverse proxy (e.g., Nginx).
  3. Security and Auth: Implement auth middleware in FastAPI and pass tokens through the SSE connection headers for tool execution control.
  4. Persistent Memory: Replace the default in-memory SQLite checkpointer in LangGraph with a persistent store (e.g., PostgreSQL Checkpointer) for durable chat histories.

📄 License

Distributed under the MIT License. See LICENSE for details.


Maintained by gilbert (@gilish-tech).

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