MCPcopy
hub / github.com/langchain-ai/chat-langchain

github.com/langchain-ai/chat-langchain @main sqlite

repository ↗ · DeepWiki ↗
471 symbols 1,402 edges 111 files 185 documented · 39%
README

Chat LangChain

A simple documentation assistant built with LangGraph.

LangGraph Python License

Overview

This is a documentation assistant agent that helps answer questions about LangChain, LangGraph, and LangSmith. It demonstrates how to build a production-ready agent using:

  • LangGraph - For agent orchestration and state management
  • LangChain Agents - For agent creation with middleware support
  • Guardrails - To keep conversations on-topic

The repo also includes a Next.js frontend in frontend/ for the public chat UI.

Features

  • Documentation Search - Searches official LangChain docs
  • Support KB - Searches the Pylon knowledge base for known issues
  • Link Validation - Verifies URLs before including in responses
  • Guardrails - Filters off-topic queries

Quick Start

Prerequisites

  • Python 3.11+
  • uv (recommended) or pip

Installation

# Clone the repository
git clone https://github.com/langchain-ai/chat-langchain.git
cd chat-langchain

# Install dependencies with uv
uv sync

# Or with pip
pip install -e . "langgraph-cli[inmem]"

Configuration

# Copy environment template
cp .env.example .env

# Edit .env with your API keys

Required Environment Variables

Variable Description
ANTHROPIC_API_KEY Anthropic API key (or use another provider)
MINTLIFY_API_URL Mintlify API base URL for docs search (e.g. https://api-dsc.mintlify.com/v1/search/docs.langchain.com)
MINTLIFY_API_KEY Mintlify API key for docs search
PYLON_API_KEY Pylon API key for support KB
PYLON_KB_ID Pylon knowledge base ID for support articles
USE_LOCAL_PROMPTS Optional. Set to true to use local prompt files instead of pulling Prompt Hub prompts

Running Locally

Backend

# Start LangGraph development server
uv run langgraph dev

# Or with pip
langgraph dev

Open LangGraph Studio: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024

Frontend

cd frontend
npm ci
npm run dev:local

The frontend expects the LangGraph server at http://127.0.0.1:2024 by default. If you want trace sharing from the UI, set LANGSMITH_API_KEY in frontend/.env.local.

Project Structure

├── src/
│   ├── agent/
│   │   ├── docs_graph.py      # Main docs agent
│   │   └── config.py          # Model configuration
│   ├── tools/
│   │   ├── docs_tools.py      # Documentation search
│   │   ├── pylon_tools.py     # Support KB tools
│   │   └── link_check_tools.py # URL validation
│   ├── prompts/
│   │   └── docs_agent_prompt.py
│   └── middleware/
│       ├── guardrails_middleware.py
│       └── retry_middleware.py
├── frontend/                  # Next.js public chat UI
├── langgraph.json             # LangGraph configuration
└── pyproject.toml             # Python project config

How It Works

The agent uses a docs-first research strategy:

  1. Guardrails Check - Validates the query is LangChain-related
  2. Documentation Search - Searches official docs via Mintlify
  3. Knowledge Base - Searches Pylon for known issues/solutions
  4. Link Validation - Verifies any URLs before including them
  5. Response Generation - Synthesizes a helpful answer

Deployment

LangGraph Cloud

  1. Push to GitHub
  2. Connect repository in LangSmith
  3. Configure environment variables
  4. Deploy

Resources

License

MIT

Extension points exported contracts — how you extend this code

UseClientProfileReturn (Interface)
* Return type for the useClientProfile hook.
frontend/lib/hooks/auth/use-client-profile.ts
KeyboardShortcutsDialogProps (Interface)
(no doc)
frontend/components/layout/keyboard-shortcuts-dialog.tsx
RateLimitEntry (Interface)
(no doc)
frontend/app/api/auth/guest/route.ts
UseStreamHandlerProps (Interface)
* Props for the useStreamHandler hook.
frontend/lib/hooks/chat/use-stream-handler.ts
HeaderProps (Interface)
(no doc)
frontend/components/layout/header.tsx
UseStreamHandlerReturn (Interface)
* Return type for the useStreamHandler hook.
frontend/lib/hooks/chat/use-stream-handler.ts
SidebarProps (Interface)
(no doc)
frontend/components/layout/sidebar.tsx
UseCheckpointHistoryProps (Interface)
* Props for the useCheckpointHistory hook.
frontend/lib/hooks/threads/use-checkpoint-history.ts

Core symbols most depended-on inside this repo

get
called by 114
src/tools/redis.py
error
called by 43
frontend/lib/utils/logger.ts
cn
called by 39
frontend/lib/utils/index.ts
info
called by 24
frontend/lib/utils/logger.ts
_format_search_results
called by 12
src/tools/docs_tools.py
warn
called by 10
frontend/lib/utils/logger.ts
set
called by 10
src/tools/redis.py
debug
called by 8
frontend/lib/utils/logger.ts

Shape

Function 305
Method 75
Interface 49
Class 25
Route 17

Languages

TypeScript50%
Python50%

Modules by API surface

src/api/auth.py29 symbols
tests/unit/test_check_links_async.py21 symbols
tests/unit/test_pylon_pagination.py18 symbols
tests/unit/test_broken_doc_urls.py15 symbols
src/middleware/guardrails_middleware.py15 symbols
src/tools/redis.py14 symbols
src/api/fastapi_app.py14 symbols
src/api/langsmith_routes.py13 symbols
frontend/lib/hooks/threads/use-threads.ts13 symbols
frontend/components/auth/AuthModal.tsx13 symbols
tests/unit/test_auth_hooks.py12 symbols
src/tools/docs_tools.py12 symbols

Dependencies from manifests, versioned

@hookform/resolvers3.10.0 · 1×
@langchain/langgraph-sdk0.1.9 · 1×
@radix-ui/react-accordion1.2.2 · 1×
@radix-ui/react-alert-dialog1.1.4 · 1×
@radix-ui/react-aspect-ratio1.1.1 · 1×
@radix-ui/react-avatar1.1.2 · 1×
@radix-ui/react-checkbox1.1.3 · 1×
@radix-ui/react-collapsible1.1.2 · 1×
@radix-ui/react-context-menu2.2.4 · 1×
@radix-ui/react-dialog1.1.4 · 1×
@radix-ui/react-dropdown-menu2.1.4 · 1×
@radix-ui/react-hover-card1.1.4 · 1×

For agents

$ claude mcp add chat-langchain \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact