Skip to content

Conversation

@ryoppippi
Copy link
Member

@ryoppippi ryoppippi commented Dec 10, 2025

Summary

Add toAnthropic() conversion methods to enable seamless integration with Anthropic's Claude API, allowing StackOne tools to be used directly with Claude models.

What Changed

  • Add @anthropic-ai/sdk as optional peer dependency
  • Implement BaseTool.toAnthropic() method for single tool conversion
  • Implement Tools.toAnthropic() method for collection conversion
  • Add comprehensive tests for both methods
  • Add example demonstrating Anthropic Claude integration

Usage

import Anthropic from '@anthropic-ai/sdk';
import { StackOneToolSet } from '@stackone/ai';

const toolset = new StackOneToolSet({ accountId: 'your-account-id' });
const tools = await toolset.fetchTools({ actions: ['hris_get_*'] });

// Convert to Anthropic format
const anthropicTools = tools.toAnthropic();

// Use with Anthropic client
const anthropic = new Anthropic();
const response = await anthropic.messages.create({
  model: 'claude-haiku-4-5-20241022',
  max_tokens: 1024,
  tools: anthropicTools,
  messages: [{ role: 'user', content: 'Get employee details...' }],
});

Closes #207


Summary by cubic

Add toAnthropic() converters to export StackOne tools to Anthropic’s Tool format, enabling direct use with Claude’s messages API. Includes an example and tests; adds @anthropic-ai/sdk as an optional peer dependency.

  • New Features

    • BaseTool.toAnthropic() converts a single tool to Anthropic Tool format (name, description, input_schema).
    • Tools.toAnthropic() converts a collection of tools.
    • Added example and tests to demonstrate and verify Claude tool-use integration.
  • Dependencies

    • Added @anthropic-ai/sdk ^0.52.0 as an optional peer dependency.

Written for commit b4cc8f9. Summary will update automatically on new commits.

Add @anthropic-ai/sdk ^0.52.0 to the peer dependencies catalog and
package.json to enable Anthropic Claude integration. The dependency
is marked as optional so users only need to install it when they
intend to use the toAnthropic() conversion methods.
Implement toAnthropic() conversion methods on both BaseTool and Tools
classes to enable seamless integration with the Anthropic Claude SDK.

The method converts StackOne tools to the Anthropic Tool format with:
- name: tool identifier
- description: tool description for Claude
- input_schema: JSON Schema with type, properties, and required fields

Uses the official Tool type from @anthropic-ai/sdk/resources for type
safety and API compatibility.

Relates to #207
Add comprehensive tests for both BaseTool.toAnthropic() and
Tools.toAnthropic() methods to verify correct conversion to
Anthropic's Tool format.

Tests verify:
- Tool name and description are correctly mapped
- input_schema.type is set to 'object'
- Properties are correctly transferred
- Array conversion for Tools collection works properly

Relates to #207
Add anthropic-integration.ts demonstrating how to use StackOne tools
with Anthropic's Claude API. The example shows:

- Initialising StackOneToolSet with account configuration
- Fetching HRIS tools via MCP
- Converting tools to Anthropic format using toAnthropic()
- Creating messages with tool calls using claude-haiku-4-5-20241022
- Verifying tool_use blocks in the response

Also adds @anthropic-ai/sdk as a dev dependency in the examples
package.json.

Closes #207
Copilot AI review requested due to automatic review settings December 10, 2025 17:35
@ryoppippi ryoppippi requested a review from a team as a code owner December 10, 2025 17:35
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@208

commit: b4cc8f9

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds seamless integration with Anthropic's Claude API by implementing toAnthropic() conversion methods for StackOne tools. The implementation follows the same patterns established for OpenAI integration, with type-safe, optional peer dependency handling.

Key Changes

  • Added toAnthropic() methods to BaseTool and Tools classes for converting tool definitions to Anthropic's format
  • Added @anthropic-ai/sdk as an optional peer dependency with type-only imports
  • Comprehensive test coverage for both single tool and collection conversions

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/tool.ts Implements toAnthropic() methods on BaseTool and Tools classes, converting tool schemas to Anthropic's input_schema format
src/tool.test.ts Adds comprehensive test coverage for both BaseTool.toAnthropic() and Tools.toAnthropic() methods
pnpm-workspace.yaml Adds @anthropic-ai/sdk v0.52.0 to peer dependency catalog
pnpm-lock.yaml Updates lock file with Anthropic SDK dependency resolution
package.json Adds @anthropic-ai/sdk as optional peer dependency following existing pattern
examples/package.json Adds @anthropic-ai/sdk to examples for demonstration purposes
examples/anthropic-integration.ts Provides working example of using StackOne tools with Claude API
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Create a message with tool calls
const response = await anthropic.messages.create({
model: 'claude-haiku-4-5-20241022',
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model name claude-haiku-4-5-20241022 appears to be incorrect. Based on Anthropic's model naming conventions, this should likely be claude-3-5-haiku-20241022 (Claude 3.5 Haiku from October 2024). There is no publicly documented Claude 4 or Claude 4.5 model as of the knowledge cutoff.

Suggested change
model: 'claude-haiku-4-5-20241022',
model: 'claude-3-5-haiku-20241022',

Copilot uses AI. Check for mistakes.
@glebedel
Copy link
Contributor

@ryoppippi conflict on this one

Resolved conflicts by keeping both Anthropic and OpenAI Responses API methods:
- Added toAnthropic() alongside existing toOpenAIResponses()
- Both BaseTool and Tools classes now support both conversion formats
- All tests passing (306 tests)

Changes from main:
- Reorganised .claude/ structure (skills → rules)
- Added OpenAI Responses API support with strict mode
- Enhanced MSW handlers organisation
- Updated oxlint configuration
@ryoppippi
Copy link
Member Author

@glebedel fixed!

@ryoppippi ryoppippi requested a review from glebedel December 12, 2025 10:41
Copy link
Contributor

@glebedel glebedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glebedel glebedel merged commit 08e7ae0 into main Dec 12, 2025
10 checks passed
@glebedel glebedel deleted the feat/anthropic-integration branch December 12, 2025 12:40
This was referenced Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

anthropic tool call integration

3 participants