LangGraph
Give a LangGraph agent its own calendar. The toolkit’s LangChain adapter returns Chronary’s tools as LangChain StructuredTools, and LangGraph takes them as they are: bind them to the model and hand them to a ToolNode.
Install
Section titled “Install”npm install @chronary/toolkit @chronary/sdk @langchain/core @langchain/langgraph# plus a model integration, e.g. @langchain/openainpm install @langchain/openaiAuthenticate
Section titled “Authenticate”Create an API key in the console and set it as CHRONARY_API_KEY. An Organization key (chr_sk_) or an Agent key (chr_ak_) both work. See Authentication.
Pick the tools
Section titled “Pick the tools”new ChronaryToolkit({ apiKey }).getTools() returns all 65 tools. Pass tools to give the agent only the ones it needs. Fewer tools means a shorter prompt and fewer wrong picks:
import { ChronaryToolkit } from '@chronary/toolkit/langchain';
const tools = new ChronaryToolkit({ apiKey: process.env.CHRONARY_API_KEY!, tools: ['list_agents', 'list_calendars', 'get_availability', 'create_event', 'list_events'],}).getTools();Full agent
Section titled “Full agent”The agent books on the first agent and its first calendar, so the account needs an agent with at least one calendar. A new account has none: create them in the console first.
A two-node graph: the agent node calls the model, the tools node runs the tool calls, and toolsCondition loops back until the model answers in text.
import { ChatOpenAI } from '@langchain/openai';import { HumanMessage, SystemMessage } from '@langchain/core/messages';import { END, MessagesAnnotation, START, StateGraph } from '@langchain/langgraph';import { ToolNode, toolsCondition } from '@langchain/langgraph/prebuilt';import { ChronaryToolkit } from '@chronary/toolkit/langchain';
const tools = new ChronaryToolkit({ apiKey: process.env.CHRONARY_API_KEY!, tools: ['list_agents', 'list_calendars', 'get_availability', 'create_event', 'list_events'],}).getTools();
const model = new ChatOpenAI({ model: 'gpt-4o' }).bindTools(tools);
const graph = new StateGraph(MessagesAnnotation) .addNode('agent', async (state) => ({ messages: [await model.invoke(state.messages)] })) .addNode('tools', new ToolNode(tools)) .addEdge(START, 'agent') .addConditionalEdges('agent', toolsCondition, ['tools', END]) .addEdge('tools', 'agent') .compile();
const today = new Date().toISOString().slice(0, 10);
const result = await graph.invoke({ messages: [ // The model has no clock: tell it today's date so "tomorrow" is right. new SystemMessage(`Today is ${today} (UTC). Use the first agent and its first calendar.`), new HumanMessage( 'Find a free 30-minute slot tomorrow afternoon (UTC), book "Project sync" in it, then list tomorrow’s events.', ), ],});
console.log(result.messages.at(-1)?.text);Each tool returns its result as a JSON string. A failed call (an API error, or input the tool’s rules refuse) returns a JSON error object such as {"error":"validation_error","message":"..."} instead of throwing, so the model can read it and try again.
Runnable example
Section titled “Runnable example”langgraph-scheduler is this agent as a complete project: it checks availability, books a meeting and lists tomorrow’s events.
Next steps
Section titled “Next steps”- All frameworks
- MCP Tools Reference: the full 65-tool surface
- Multi-agent scheduling guide