Skip to content

Commit 7fa9c7d

Browse files
authored
Add Typescript support for Claude/OpenAI MCP server tools (#3443)
1 parent 4f6c259 commit 7fa9c7d

29 files changed

Lines changed: 1498 additions & 90 deletions

File tree

.github/workflows/sdk-typescript.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: pnpm lint:check
5050

5151
- name: Type check
52-
run: npx tsc
52+
run: pnpm exec tsc
5353

5454
test-unit:
5555
runs-on: ubicloud-standard-4

examples/typescript/durable/workflow.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from 'zod';
1+
import { z } from 'zod/v4';
22
import { Or, SleepCondition, UserEventCondition } from '@hatchet-dev/typescript-sdk/v1/conditions';
33
import { NonDeterminismError } from '@hatchet-dev/typescript-sdk/util/errors/non-determinism-error';
44
import sleep from '@hatchet-dev/typescript-sdk/util/sleep';
@@ -254,6 +254,10 @@ const lookbackEventPayloadSchema = z.object({
254254
user_id: z.number(),
255255
});
256256

257+
const twoEventsPayloadSchema = z.object({
258+
order: z.string(),
259+
});
260+
257261
export const waitForEventLookback = hatchet.durableTask({
258262
name: 'wait-for-event-lookback',
259263
executionTimeout: '10m',
@@ -312,14 +316,14 @@ export const waitForTwoEventsSecondPushedFirst = hatchet.durableTask({
312316
const event1 = await ctx.waitForEvent(
313317
'key1',
314318
undefined,
315-
undefined,
319+
twoEventsPayloadSchema,
316320
input.scope,
317321
LOOKBACK_WINDOW
318322
);
319323
const event2 = await ctx.waitForEvent(
320324
'key2',
321325
undefined,
322-
undefined,
326+
twoEventsPayloadSchema,
323327
input.scope,
324328
LOOKBACK_WINDOW
325329
);

examples/typescript/simple/run.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { hatchet } from '../hatchet-client';
22
import { simple } from './workflow';
33
import { parent } from './workflow-with-child';
4+
import { simpleWithZod } from './zod';
45

56
async function main() {
67
// > Running a Task
@@ -15,6 +16,11 @@ async function main() {
1516
}
1617
);
1718

19+
const res3 = await simpleWithZod.run({
20+
Message: 'HeLlO WoRlD',
21+
});
22+
console.log(res3.TransformedMessage);
23+
1824
// 👀 Access the results of the Task
1925
console.log(res.TransformedMessage);
2026
}

examples/typescript/simple/zod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// > Declaring a Task
2-
import * as z from 'zod';
2+
import * as z from 'zod/v4';
33
import { hatchet } from '../hatchet-client';
44

55
const SimpleInputSchema = z.object({

sdks/typescript/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to Hatchet's TypeScript SDK will be documented in this chang
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.22.0] - 2026-04-28
9+
10+
### Added
11+
12+
- Adds `mcpTool` method to Workflow objects for integration with Claude and OpenAI agent SDKs. Requires Zod v4.
13+
- Bumps minimum Zod version to `3.25.0`. Zod schemas provided to the SDK must be Zod 4 schemas, but you can still use Zod 3 in your application
14+
code.
15+
816
## [1.21.2] - 2026-04-22
917

1018
### Added

sdks/typescript/package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hatchet-dev/typescript-sdk",
3-
"version": "1.21.2",
3+
"version": "1.22.0",
44
"description": "Background task orchestration & visibility for developers",
55
"types": "dist/index.d.ts",
66
"files": [
@@ -44,7 +44,6 @@
4444
"license": "MIT",
4545
"devDependencies": {
4646
"@eslint/js": "^10.0.1",
47-
"@tsd/typescript": "^5.9.3",
4847
"@types/jest": "^29.5.14",
4948
"@types/node": "^22.13.14",
5049
"autoprefixer": "^10.4.27",
@@ -63,6 +62,8 @@
6362
"ts-jest": "^29.4.6",
6463
"ts-node": "^10.9.2",
6564
"ts-proto": "^2.11.4",
65+
"tsconfig-paths": "^4.2.0",
66+
"tsx": "^4.21.0",
6667
"typedoc": "^0.28.17",
6768
"typedoc-plugin-markdown": "^4.10.0",
6869
"typedoc-plugin-no-inherit": "^1.6.1",
@@ -81,11 +82,16 @@
8182
"qs": "^6.14.2",
8283
"semver": "^7.7.4",
8384
"yaml": "^2.8.2",
84-
"zod": "^3.24.2",
85-
"zod-to-json-schema": "^3.24.1"
85+
"zod-to-json-schema": "^3.24.2"
86+
},
87+
"peerDependencies": {
88+
"zod": "^3.25.0 || ^4.0.0"
8689
},
8790
"optionalDependencies": {
91+
"@anthropic-ai/claude-agent-sdk": "^0.2.87",
8892
"@grpc/grpc-js": "^1.14.3",
93+
"@modelcontextprotocol/sdk": "^1.29.0",
94+
"@openai/agents": "0.8.3",
8995
"@opentelemetry/api": "^1.9.0",
9096
"@opentelemetry/core": "^2.0.0",
9197
"@opentelemetry/exporter-trace-otlp-grpc": "^0.215.0",

0 commit comments

Comments
 (0)