TypeChain - Declare LangChain Tools With Decorators, Let LangChain Run Them
The same approach as TypeMCP, moved to LangChain JS. It leaves execution semantics alone and only keeps types and schemas honest.
Using TypeMCP, I wanted the same thing on the LangChain side
The MCP servers were tidy with decorators, but wiring the same tools into a LangChain agent meant writing them out by hand again. Write a name, a description and a schema twice and the two copies diverging is a matter of time.
TypeChain lets LangChain JS tools and agents be written with @Tool(), @Agent() and @Policy() decorators.
It does not take over execution
This is the part I was careful about. TypeChain goes as far as collecting declarations and composing standard LangChain tools and agents. Model selection, credentials, approvals, retries, timeouts, persistence and audit policy all stay with the application.
Wrap execution for convenience and the layer breaks every time LangChain moves, and keeping it alive costs something every release. So execution semantics were left with LangChain.
import { toLangChainTools } from "@theorvane/type-chain/langchain";
const tools = toLangChainTools(new SearchTools());What comes back are standard LangChain tools, so they drop into existing agent code.
Using a TypeMCP server as tools
The /typemcp entrypoint composes a TypeMCP-declared server in-process as tools. It doesn't open an MCP transport, so there's no separate server to run.
Two decorator modes
Standard (Stage 3) decorators are the default. A separate /legacy entrypoint exists for CommonJS projects on experimentalDecorators. Support only one and existing projects can't adopt it; mix them in one file and both end up half-working.
Using it
Node.js 20 or later.
npm install @theorvane/type-chain