Logo Fullstack Langgraph Nextjs Agent

Fullstack Langgraph Nextjs Agent

Tổ chức
agentailor

Production-ready Next.js template for building AI agents with LangGraph.js. Features MCP integration for dynamic tool loading, human-in-the-loop tool approval, persistent conversation memory with PostgreSQL, and real-time streaming responses. Built with TypeScript, React, Prisma, and Tailwind CSS.

Nhà phát hànhagentailor
Kho mãfullstack-langgraph-nextjs-agent
Ngôn ngữTypeScript
Bản fork
30
Sao
132
Công cụ có sẵn
0
Phương thức truyền tảistdio
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Fullstack Langgraph Nextjs Agent cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    132 sao và 30 bản fork từ kho mã được liên kết.

LangGraph.js AI Agent Template

A production-ready Next.js template for building AI agents with LangGraph.js, featuring Model Context Protocol (MCP) integration, human-in-the-loop tool approval, and persistent memory.

Demo

Complete agent workflow: user input → tool approval → execution → streaming response

TypeScript Next.js LangGraph PostgreSQL Prisma


Built with this template: Cameron

Cameron is a personal finance agent that started from this template and was built in public, one tagged release per article. If you want to see where this scaffold goes once it becomes a real agent — human-in-the-loop approval on every money-moving action, self-hosted data, a full LangGraph workflow — read its source as a worked example.


Need help taking this to production?

I help teams design and optimize LangGraph-based AI agents (RAG, memory, latency, architecture).

If you're building something serious on top of this template and want hands-on help:

→ DM me on LinkedIn

Happy to jump on a short call.


Features

Dynamic Tool Loading with MCP

  • Model Context Protocol integration for dynamic tool management
  • Add tools via web UI - no code changes required
  • Support for both stdio and HTTP MCP servers
  • Tool name prefixing to prevent conflicts

Human-in-the-Loop Tool Approval

  • Interactive tool call approval before execution
  • Granular control with approve/deny/modify options
  • Optional auto-approval mode for trusted environments
  • Real-time streaming with tool execution pauses

Persistent Conversation Memory

  • LangGraph checkpointer with PostgreSQL backend
  • Full conversation history preservation
  • Thread-based organization
  • Seamless resume across sessions

Multimodal File Uploads

  • Upload images, PDFs, and text files with messages
  • S3-compatible storage (MinIO for development)
  • Automatic file processing for AI consumption
  • Production-ready with AWS S3, Cloudflare R2 support

Real-time Streaming Interface

  • Server-Sent Events (SSE) for live responses
  • Optimistic UI updates with React Query
  • Type-safe message handling
  • Error recovery and graceful degradation

Persistent Model Settings

  • Provider and model selection saved to localStorage automatically
  • Settings survive page reloads and thread navigation
  • No backend required — zero latency reads on startup

LLM Observability with Langfuse

  • End-to-end tracing of agent runs, LLM calls, tool invocations, and token usage
  • Works with Langfuse Cloud or a self-hosted instance
  • Toggle via LANGFUSE_ENABLED env var — zero overhead when disabled
  • See docs/OBSERVABILITY.md for setup instructions

Modern Tech Stack

  • Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
  • Backend: Node.js, Prisma ORM, PostgreSQL, MinIO/S3
  • AI: LangGraph.js, OpenAI/Google/Anthropic models
  • UI: shadcn/ui components, Lucide icons

Quick Start

Prerequisites

  • Node.js 18+ and pnpm
  • Docker (for PostgreSQL and MinIO)
  • OpenAI API key, Google AI API key, or Anthropic API key

1. Clone and Install

bash
git clone https://github.com/IBJunior/fullstack-langgraph-nextjs-agent.git
cd fullstack-langgraph-nextjs-agent
pnpm install

2. Environment Setup

bash
cp .env.example .env.local

Edit .env.local with your configuration:

env
# Database
DATABASE_URL="postgresql://user:password@localhost:5434/agent_db"

# AI Models (choose one or more)
OPENAI_API_KEY="sk-..."
GOOGLE_API_KEY="..."
ANTHROPIC_API_KEY="sk-ant-..."

# Optional: Default model
DEFAULT_MODEL="gpt-4o-mini"  # or "gemini-1.5-flash" or "claude-sonnet-4-5"

3. Start Services

bash
docker compose up -d  # Starts PostgreSQL and MinIO

4. Database Setup

bash
pnpm prisma:generate
pnpm prisma:migrate

5. Run Development Server

bash
pnpm dev
# Or use custom port
pnpm dev --port=3005

Visit http://localhost:3000 to start chatting with your AI agent!

Screenshots

Usage Guide

Adding MCP Servers

  1. Navigate to Settings - Click the gear icon in the sidebar
  2. Add MCP Server - Click "Add MCP Server" button
  3. Configure Server:
    • Name: Unique identifier (e.g., "filesystem")
    • Type: Choose stdio or http
    • Command: For stdio servers (e.g., npx @modelcontextprotocol/server-filesystem)
    • Args: Command arguments (e.g., ["/path/to/allow"])
    • URL: For HTTP servers

Add MCP Server MCP server configuration form with example filesystem server setup

Want to build your own MCP server? Check out create-mcp-server - scaffold production-ready MCP servers in seconds with TypeScript, multiple frameworks (MCP SDK or FastMCP), and built-in debugging tools.

Example MCP Server Configurations

Filesystem Server (stdio)

json
{
  "name": "filesystem",
  "type": "stdio",
  "command": "npx",
  "args": ["@modelcontextprotocol/server-filesystem", "/Users/yourname/Documents"]
}

HTTP API Server

json
{
  "name": "web-api",
  "type": "http",
  "url": "http://localhost:8080/mcp",
  "headers": {
    "Authorization": "Bearer your-token"
  }
}

Note: Some HTTP MCP servers require OAuth 2.0 authentication. See OAuth Documentation for details.

Tool Approval Workflow

  1. Agent Requests Tool - AI suggests using a tool
  2. Approval Prompt - Interface shows tool details and asks for approval
  3. User Decision:
    • ✅ Allow: Execute tool as requested
    • ❌ Deny: Skip tool execution
    • ✏️ Modify: Edit tool parameters before execution
  4. Continue Conversation - Agent responds with tool results

Architecture

High-Level Overview

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   Next.js UI   │◄──►│  Agent Service   │◄──►│  LangGraph.js   │
│   (React 19)   │    │  (SSE Streaming) │    │    Agent        │
└─────────────────┘    └──────────────────┘    └─────────────────┘
         │                       │                       │
         ▼                       ▼                       ▼
┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   React Query   │    │     Prisma       │    │  MCP Clients    │
│   (State Mgmt)  │    │   (Database)     │    │   (Tools)       │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                                │
                                ▼
                  ┌──────────────────────────────┐
                  │   PostgreSQL  │  MinIO/S3    │
                  │  (Persistence)│ (File Store) │
                  └──────────────────────────────┘

Core Components

Agent Builder (src/lib/agent/builder.ts)

  • Creates StateGraph with agent→tool_approval→tools flow
  • Handles tool approval interrupts
  • Manages model binding and system prompts

MCP Integration (src/lib/agent/mcp.ts)

  • Dynamic tool loading from database-stored MCP servers
  • Support for stdio and HTTP transports
  • Tool name prefixing for conflict prevention

Streaming Service (src/services/agentService.ts)

  • Server-Sent Events for real-time responses
  • Message processing and chunk aggregation
  • Tool approval workflow handling

Chat Hook (src/hooks/useChatThread.ts)

  • React Query integration for optimistic UI
  • Stream management and error handling
  • Tool approval user interface

File Storage (src/lib/storage/)

  • S3-compatible storage with MinIO (development) or AWS S3 (production)
  • File validation, upload, and content processing for AI
  • Multimodal message building with base64 conversion

For detailed architecture documentation, see docs/ARCHITECTURE.md.

API Documentation

The app serves an interactive OpenAPI 3.1 explorer at /api-docs and the raw spec at /api/openapi — generated from per-route Zod schemas. See docs/API.md for how it works and how to document new routes.

Development

Available Scripts

bash
pnpm dev                 # Start development server with Turbopack
pnpm build              # Production build
pnpm start              # Start production server
pnpm lint               # Run ESLint
pnpm format             # Format with Prettier
pnpm format:check       # Check formatting

# Database
pnpm prisma:generate    # Generate Prisma client (after schema changes)
pnpm prisma:migrate     # Create and apply migrations
pnpm prisma:studio      # Open Prisma Studio (database UI)

Agent Skills

This repo ships Agent Skills in .agents/skills/, pinned by skills-lock.json. They give any skill-aware coding agent (Claude Code and friends) the conventions for working on an agent codebase like this one:

SkillUse it when
agent-prompt-engineeringWriting or auditing the agent’s system prompt
tool-designAdding or reviewing a tool / MCP server the agent calls
agent-eval-casesDeciding what agent behavior deserves an eval case, and writing it

Agent guidance for this repo lives in AGENTS.md (with CLAUDE.md pointing to it).

Project Structure

src/
├── app/                 # Next.js App Router
│   ├── api/            # API routes (stream, upload, mcp-servers)
│   └── thread/         # Thread-specific pages
├── components/         # React components
├── hooks/              # Custom React hooks
├── lib/                # Core utilities
│   ├── agent/          # Agent-related logic
│   └── storage/        # File upload & S3 utilities
├── services/           # Business logic
└── types/              # TypeScript definitions

prisma/
├── schema.prisma       # Database schema
└── migrations/         # Database migrations

Key Files

  • Agent Configuration: src/lib/agent/builder.ts, src/lib/agent/mcp.ts
  • API Endpoints: src/app/api/agent/stream/route.ts, src/app/api/agent/upload/route.ts
  • File Storage: src/lib/storage/ (validation, upload, content processing)
  • Database Models: prisma/schema.prisma
  • Main Chat Interface: src/components/Thread.tsx, src/components/MessageInput.tsx
  • Streaming Logic: src/hooks/useChatThread.ts

Contributing

We welcome contributions! This project is designed to be a community resource for LangGraph.js development.

Getting Started

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Commit: git commit -m 'Add amazing feature'
  5. Push: git push origin feature/amazing-feature
  6. Open a Pull Request

Development Guidelines

  • Follow TypeScript strict mode
  • Use Prettier for formatting
  • Add JSDoc comments for public APIs
  • Test MCP server integrations thoroughly
  • Update documentation for new features

Learning Resources

LangGraph.js

Model Context Protocol (MCP)

Next.js & React

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments


Ready to build your next AI agent?

Get Started


If this repo helped you and you’d like guidance implementing it in production, feel free to reach out on LinkedIn.

Dùng MCP Fullstack Langgraph Nextjs Agent với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Fullstack Langgraph Nextjs Agent, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Fullstack Langgraph Nextjs Agent làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Fullstack Langgraph Nextjs Agent.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "fullstack-langgraph-nextjs-agent": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Fullstack Langgraph Nextjs Agent, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Fullstack Langgraph Nextjs Agent.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Fullstack Langgraph Nextjs Agent giúp tôi làm việc này không?
Fullstack Langgraph Nextjs Agent
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Fullstack Langgraph Nextjs Agent.

Câu hỏi thường gặp

Máy chủ MCP Fullstack Langgraph Nextjs Agent dùng để làm gì?

Fullstack Langgraph Nextjs Agent là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Fullstack Langgraph Nextjs Agent với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Fullstack Langgraph Nextjs Agent với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Fullstack Langgraph Nextjs Agent với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Fullstack Langgraph Nextjs Agent, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Fullstack Langgraph Nextjs Agent với TypingMind?

Fullstack Langgraph Nextjs Agent hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Fullstack Langgraph Nextjs Agent cung cấp những công cụ nào trong TypingMind?

Fullstack Langgraph Nextjs Agent cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Fullstack Langgraph Nextjs Agent không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Fullstack Langgraph Nextjs Agent yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇