LangChain

GTM Tools' LangChain and LangGraph integration

Getting started

LangChain is the most widely used framework for building LLM-powered agents. GTM Tools plugs in through langchain-mcp-adapters, the official adapter that turns any MCP server’s tools into standard LangChain tools. One connection gives a LangGraph agent buying-signal detection, LinkedIn company and people lookup, SMTP-verified email finding, and Reddit engagement, with real tool schemas the model can bind to.

There’s no langchain-gtm-tools package to install. The adapter reads our tool schemas live from the MCP server, so the tool list is always current.

Use cases

  • Signal-gated prospecting graph: a node runs detect_signal, a conditional edge drops accounts where nothing fired, and only survivors reach the expensive LinkedIn nodes.
  • Enrichment tool for an existing agent: bind get_email and get_linkedin_profile_url to an agent that already handles your CRM.
  • Research subgraph: let the model choose between cheap SERP-only employee search and the full search depending on what the task needs.
  • Human-in-the-loop outreach: draft with LangGraph’s interrupt, then send through send_linkedin_message only after approval.

Prerequisites

  1. A GTM Tools API key, from get_api_key or gtm-tools admin login. See Get an API key.
  2. Python 3.10+ and a LangChain-compatible model provider (an OPENAI_API_KEY or ANTHROPIC_API_KEY).

Setup

Install the adapter alongside LangGraph and your model provider:

$pip install langchain-mcp-adapters langgraph "langchain[openai]"

Set your keys:

$export GTM_TOOLS_API_KEY="sk_your_api_key"
$export OPENAI_API_KEY="sk-..."

Quickstart

Build a ReAct agent with the full toolkit in a few lines:

Python
1import asyncio
2import os
3
4from langchain_openai import ChatOpenAI
5from langgraph.prebuilt import create_react_agent
6
7from langchain_mcp_adapters.client import MultiServerMCPClient
8
9client = MultiServerMCPClient(
10 {
11 "gtm-tools": {
12 "transport": "streamable_http",
13 "url": "https://api.gtm-tools.sh/mcp",
14 "headers": {
15 "Authorization": f"Bearer {os.environ['GTM_TOOLS_API_KEY']}"
16 },
17 }
18 }
19)
20
21
22async def main():
23 agent = create_react_agent(
24 ChatOpenAI(model="gpt-4o-mini"),
25 tools=await client.get_tools(),
26 )
27 result = await agent.ainvoke(
28 {"messages": [("user", "Is gymshark.com showing any buying signals?")]}
29 )
30 print(result["messages"][-1].content)
31
32
33asyncio.run(main())

You can also pull a single tool in if you don’t need the whole toolkit:

Python
1tools = {t.name: t for t in await client.get_tools()}
2
3signals = await tools["detect_signal"].ainvoke({"domain": "gymshark.com"})
4email = await tools["get_email"].ainvoke(
5 {"name": "Ben Francis", "domain": "gymshark.com"}
6)

Available tools

The adapter discovers the tool catalog from the server at connection time, so there is no fixed inventory to copy into your code. The server exposes 63 tools: 8 billing, 19 LinkedIn, 21 Reddit, 1 email, 13 signals, and 1 geocoding.

See the MCP tool catalogue for names and parameter shapes, and Pricing for the token cost of each. get_token_balance returns the live cost table at runtime.

Narrow the tool set

Feeding all 63 tools to the model wastes context and invites wrong picks, so narrow to the workflow you are building:

1KEEP = {
2 "detect_signal",
3 "get_linkedin_company_url",
4 "list_linkedin_company_employees",
5 "get_email",
6}
7
8tools = [t for t in await client.get_tools() if t.name in KEEP]

Filter after loading, since the adapter fetches the whole catalog in one call.

Handling errors in a graph

Tool failures surface as exceptions from ainvoke, and the message carries the HTTP status. Two worth handling explicitly:

  • 402 Insufficient tokens: stop the run rather than retrying. Top up with buy_tokens or enable set_auto_reload.
  • A 200 result with status: "try_again_later" and retry_after_seconds: a provider was busy. Sleep that long before one retry; each attempt is charged.

The full table is in the Error Reference.