arcade-mcp/examples/langgraph-ts
Sergio Serrano 3a45d5fec0
Add LangGraph-TS example (#356)
This PR adds a new example showcasing how to integrate Arcade tools with
LangGraph.js to create a ReAct agent. The example is based on the
[LangChain React Agent
JS](https://github.com/langchain-ai/react-agent-js/tree/main)
repository.
2025-04-09 21:08:18 -03:00
..
src Add LangGraph-TS example (#356) 2025-04-09 21:08:18 -03:00
.gitignore Add LangGraph-TS example (#356) 2025-04-09 21:08:18 -03:00
langgraph.json Add LangGraph-TS example (#356) 2025-04-09 21:08:18 -03:00
package.json Add LangGraph-TS example (#356) 2025-04-09 21:08:18 -03:00
README.md Add LangGraph-TS example (#356) 2025-04-09 21:08:18 -03:00
studio.png Add LangGraph-TS example (#356) 2025-04-09 21:08:18 -03:00

Arcade LangGraph.js Agent

This project is based on the LangChain React Agent JS repository.

LangGraph Studio

This template showcases a LangGraph.js agent integrated with Arcade tools, designed for LangGraph Studio. The agent uses the ReAct pattern to execute API calls and access various tools through the Arcade API.

What it does

The Arcade LangGraph agent:

  1. Takes a user query as input
  2. Reasons about the query and decides on an action using Arcade tools
  3. Executes the chosen action through the Arcade API
  4. Observes the result of the action
  5. Repeats steps 2-4 until it can provide a final answer

This approach creates a flexible agent that can interact with multiple services like Google, GitHub, and other external tools through Arcade's unified API.

Getting Started

  1. Clone this repository

  2. Create a .env file:

    cp .env.example .env
    
  3. Add your API keys to the .env file:

    OPENAI_API_KEY=your-openai-api-key
    ARCADE_API_KEY=your-arcade-api-key
    ARCADE_BASE_URL=https://api.arcade.dev
    
  4. Install dependencies:

    pnpm install
    
  5. Run the development server:

    pnpm dev
    

How it works

The core logic is defined in src/graph.ts

  1. Loads Arcade tools for multiple toolkits (e.g., Google, GitHub)
  2. Creates a model with the tools bound to it
  3. Routes messages between tool calls and model reasoning
  4. Compiles everything into a graph you can invoke and deploy

Project Structure

  • src/graph.ts - Main graph implementation showing how to create and use a LangGraph agent with Arcade tools
  • src/arcade.ts - Utility functions for integrating Arcade with LangGraph and converting Arcade tools to LangChain tools
  • src/configuration.ts - Configurable parameters for the agent
  • src/prompts.ts - Default prompts used by the agent
  • src/utils.ts - Helper functions for loading models

Customization

To use different Arcade toolkits or queries:

  1. Modify the toolkits array in getArcadeTools() in src/graph.ts to include the desired toolkits (e.g., ["google", "github", "notion"])
  2. Change the default model in src/configuration.ts
  3. Update the system prompt in src/prompts.ts

Currently supported Arcade toolkits:

  • GitHub
  • Google
  • Notion
  • Reddit
  • X
  • And more

You can check out our Integrations documentation for more information on how to integrate with other tools.

You can also create your own custom tools and integrate them with LangGraph. Check out our Custom Tools documentation for more information.

Development

While iterating on your graph, you can edit past state and rerun your app from past states to debug specific nodes. Local changes will be automatically applied via hot reload.

You can create an entirely new thread, clearing previous history, using the + button in the top right of the LangGraph Studio interface.

Authorization Flow

The integration handles authorization requirements for Arcade tools:

  • When a tool requires authentication, an authorization URL is generated
  • This URL can be presented to the user to complete the authorization process

Prerequisites

  • Node.js (v18+)
  • pnpm
  • Arcade account with API key
  • OpenAI API key or other compatible LLM