const apiKey = process.env.ANTHROPIC_API_KEY!;
const url = "https://api.anthropic.com/v1/messages";
const payload = {
model: "claude-sonnet-4-20250514",
max_tokens: 1000,
messages: [
{
role: "user",
content: "Create an invoice for john.doe@example.com for 2 hours of consulting services at the rate of $150 per hour.",
},
],
mcp_servers: [
{
type: "url",
url: "https://mcp.paypal.com/sse",
name: "example-mcp",
authorization_token: "YOUR_TOKEN",
},
],
};
(async () => {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": apiKey,
"anthropic-version": "2023-06-01",
"anthropic-beta": "mcp-client-2025-04-04",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data);
})();