Skip to content

feat: add Anthropic Claude integration - #208

Merged
glebedel merged 9 commits into
mainfrom
feat/anthropic-integration
Dec 12, 2025
Merged

feat: add Anthropic Claude integration#208
glebedel merged 9 commits into
mainfrom
feat/anthropic-integration

Conversation

@ryoppippi

@ryoppippiryoppippi commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

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

importAnthropicfrom'@anthropic-ai/sdk';import{StackOneToolSet}from'@stackone/ai';consttoolset=newStackOneToolSet({accountId: 'your-account-id'});consttools=awaittoolset.fetchTools({actions: ['hris_get_*']});// Convert to Anthropic formatconstanthropicTools=tools.toAnthropic();// Use with Anthropic clientconstanthropic=newAnthropic();constresponse=awaitanthropic.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
CopilotAI review requested due to automatic review settings December 10, 2025 17:35
@ryoppippi
ryoppippi requested a review from a team as a code ownerDecember 10, 2025 17:35
@pkg-pr-new

pkg-pr-newBot commented Dec 10, 2025

Copy link
Copy Markdown

Open in StackBlitz

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

commit: b4cc8f9

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
src/tool.tsImplements toAnthropic() methods on BaseTool and Tools classes, converting tool schemas to Anthropic's input_schema format
src/tool.test.tsAdds comprehensive test coverage for both BaseTool.toAnthropic() and Tools.toAnthropic() methods
pnpm-workspace.yamlAdds @anthropic-ai/sdk v0.52.0 to peer dependency catalog
pnpm-lock.yamlUpdates lock file with Anthropic SDK dependency resolution
package.jsonAdds @anthropic-ai/sdk as optional peer dependency following existing pattern
examples/package.jsonAdds @anthropic-ai/sdk to examples for demonstration purposes
examples/anthropic-integration.tsProvides 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',

CopilotAIDec 10, 2025

Copy link

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.
Comment threadexamples/anthropic-integration.ts Outdated
Comment threadexamples/anthropic-integration.ts Outdated
@glebedel

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

@glebedel fixed!

@glebedelglebedel left a comment

Copy link
Copy Markdown
Contributor

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 mainDec 12, 2025
10 checks passed
@glebedel
glebedel deleted the feat/anthropic-integration branch December 12, 2025 12:40
@github-actionsgithub-actionsBot mentioned this pull request Dec 12, 2025
This was referenced Dec 13, 2025
Sign up for freeto 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

@ryoppippi@glebedel