Skip to content

Commit ba64913

Browse files
committed
docs(readme): add TanStack AI and Claude Agent SDK integration examples
- Add TanStack AI integration section with Zod schema example - Add Claude Agent SDK integration section with MCP server example - Remove obsolete link to deleted examples/index.ts
1 parent c69e187 commit ba64913

1 file changed

Lines changed: 94 additions & 2 deletions

File tree

README.md

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,100 @@ await generateText({
113113

114114
[View full example](examples/ai-sdk-integration.ts)
115115

116+
### TanStack AI
117+
118+
```typescript
119+
import { chat } from "@tanstack/ai";
120+
import { openai } from "@tanstack/ai-openai";
121+
import { z } from "zod";
122+
import { StackOneToolSet } from "@stackone/ai";
123+
124+
const toolset = new StackOneToolSet({
125+
baseUrl: "https://api.stackone.com",
126+
accountId: "your-account-id",
127+
});
128+
129+
const tools = await toolset.fetchTools();
130+
const employeeTool = tools.getTool("bamboohr_get_employee");
131+
132+
// TanStack AI requires Zod schemas for tool input validation
133+
const getEmployeeTool = {
134+
name: employeeTool.name,
135+
description: employeeTool.description,
136+
inputSchema: z.object({
137+
id: z.string().describe("The employee ID"),
138+
}),
139+
execute: async (args: { id: string }) => {
140+
return employeeTool.execute(args);
141+
},
142+
};
143+
144+
const adapter = openai();
145+
const stream = chat({
146+
adapter,
147+
model: "gpt-4o",
148+
messages: [{ role: "user", content: "Get employee with id: abc123" }],
149+
tools: [getEmployeeTool],
150+
});
151+
152+
for await (const chunk of stream) {
153+
// Process streaming chunks
154+
}
155+
```
156+
157+
[View full example](examples/tanstack-ai-integration.ts)
158+
159+
### Claude Agent SDK
160+
161+
```typescript
162+
import { query, tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
163+
import { z } from "zod";
164+
import { StackOneToolSet } from "@stackone/ai";
165+
166+
const toolset = new StackOneToolSet({
167+
baseUrl: "https://api.stackone.com",
168+
accountId: "your-account-id",
169+
});
170+
171+
const tools = await toolset.fetchTools();
172+
const employeeTool = tools.getTool("bamboohr_get_employee");
173+
174+
// Create a Claude Agent SDK tool from the StackOne tool
175+
const getEmployeeTool = tool(
176+
employeeTool.name,
177+
employeeTool.description,
178+
{ id: z.string().describe("The employee ID") },
179+
async (args) => {
180+
const result = await employeeTool.execute(args);
181+
return { content: [{ type: "text", text: JSON.stringify(result) }] };
182+
}
183+
);
184+
185+
// Create an MCP server with the StackOne tool
186+
const mcpServer = createSdkMcpServer({
187+
name: "stackone-tools",
188+
version: "1.0.0",
189+
tools: [getEmployeeTool],
190+
});
191+
192+
// Use with Claude Agent SDK query
193+
const result = query({
194+
prompt: "Get the employee with id: abc123",
195+
options: {
196+
model: "claude-sonnet-4-5-20250929",
197+
mcpServers: { "stackone-tools": mcpServer },
198+
tools: [], // Disable built-in tools
199+
maxTurns: 3,
200+
},
201+
});
202+
203+
for await (const message of result) {
204+
// Process streaming messages
205+
}
206+
```
207+
208+
[View full example](examples/claude-agent-sdk-integration.ts)
209+
116210
## Usage
117211

118212
```typescript
@@ -128,8 +222,6 @@ const employeeTool = tools.getTool("bamboohr_list_employees");
128222
const employees = await employeeTool.execute();
129223
```
130224

131-
[View full example](examples/index.ts)
132-
133225
### Authentication
134226

135227
Set the `STACKONE_API_KEY` environment variable:

0 commit comments

Comments
 (0)