Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 1.52 KB

File metadata and controls

35 lines (22 loc) · 1.52 KB

LangGraph ToolNode example

This repository-source example turns a decorated TypeMCP tool into a standard LangChain tool and passes it to LangGraph's ToolNode. TypeMCP supplies the tool declaration and adapter only; the application retains ownership of graph topology, models, authorization, persistence, and deployment.

Published package example: @theorvane/type-mcp@0.3.0 provides @theorvane/type-mcp/langchain. It creates tools only; applications own their LangGraph graph, model, state, and policy.

Build from a checkout

From the repository root:

npm ci
npm run example:langgraph-tools

The example uses its own lockfile and a local file:../.. dependency. It does not start a listener, call an LLM, require an API key, or perform an external request.

Composition boundary

src/catalog-tools.ts declares a find-product tool. src/server.ts performs the only integration step:

const tools = await createLangChainTools(CatalogTools);
const toolNode = new ToolNode([...tools]);

ToolNode requires a mutable array, so the readonly adapter result is copied at the consumer boundary. Add toolNode to your own StateGraph and decide routing, confirmation, authorization, state/checkpointing, and model behavior there.

Smoke test

npm test -- --run test/langgraph-tool-node.test.ts

The test builds this exact example and invokes ToolNode with an in-memory AIMessage tool call. It proves the output is a LangChain ToolMessage; it uses neither a network listener nor a model.