Skip to content

LangChain and LangGraph (any model)

LangChain orchestrates tools the same way whatever model runs the agent, so connecting jitprompt once works with Claude, OpenAI models, Gemini, Grok, Mistral, local models — anything LangChain supports. create_agent builds a LangGraph agent loop.

Terminal window
pip install "langchain[mcp]" # plus the integration for your model, e.g. langchain-anthropic
import asyncio
import os
from fastmcp.client import Client
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter
JITPROMPT = "https://app.jitprompt.com/mcp"
MODEL = "anthropic:claude-sonnet-5" # or "openai:gpt-5.5", "xai:grok-4.7", "ollama:…", any "provider:model" LangChain supports
SYSTEM = (
"Your operating instructions are in the jitprompt tools: call get_toc first, and "
"search_instructions before each new task. Follow what they return."
)
async def main():
# auth= takes the namespace key as a bearer token
async with MCPAdapter(Client(JITPROMPT, auth=os.environ["JITPROMPT_KEY"])) as adapter:
tools = await adapter.list_tools() # get_toc, search_instructions, get_section
agent = create_agent(MODEL, tools, system_prompt=SYSTEM)
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "Can I get a refund on my annual plan?"}]}
)
print(result["messages"][-1].content)
asyncio.run(main())

Switching models is a one-line change to MODEL (install that provider’s LangChain integration); the jitprompt connection and the system prompt stay the same.

Each API key reads one namespace. An agent that needs two sets of instructions — say, support policies and billing rules — opens two adapters and passes both tool lists to create_agent. Give each a distinct description in the system prompt so the model knows which to search.

Anything that speaks MCP over streamable HTTP can use jitprompt with the values in Other MCP clients: the URL https://app.jitprompt.com/mcp and the header Authorization: Bearer imcp_....