@sinch/mcp
Version:
Sinch MCP server
52 lines • 2.02 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
const list_tools_1 = require("../list-tools");
const toolsTestCases_1 = require("../toolsTestCases");
const configuration_1 = require("../configuration");
const transformToAnthropicFormat = (tools) => {
return tools.map((t) => ({
name: t.name,
description: t.description,
input_schema: t.inputSchema,
}));
};
const targetModel = process.env.TARGET_MODEL || 'claude-3-7-sonnet-latest';
describe(`Tool invocation tests - Anthropic - ${targetModel}`, () => {
let tools;
let anthropic;
beforeAll(async () => {
tools = transformToAnthropicFormat(await (0, list_tools_1.listTools)());
anthropic = new sdk_1.default({
apiKey: process.env.ANTHROPIC_API_KEY,
});
});
it.each(toolsTestCases_1.toolTestCases)('should handle prompt "%s"', async ({ prompt, expectedToolName, expectedArguments }) => {
const response = await anthropic.messages.create({
model: targetModel,
max_tokens: configuration_1.MAX_TOKENS,
messages: [
{ role: 'user', content: prompt }
],
tools,
temperature: configuration_1.TEMPERATURE,
tool_choice: {
type: 'auto',
},
});
const toolCall = response.content.find((obj) => obj.type === "tool_use");
if (!expectedToolName) {
expect(toolCall).toBeUndefined();
return;
}
expect(toolCall).toBeDefined();
expect(toolCall.name).toEqual(expectedToolName);
if (expectedArguments) {
expect(toolCall.input).toEqual(expectedArguments);
}
}, configuration_1.TIMEOUT);
});
//# sourceMappingURL=anthropic.int.test.js.map