Skip to main content

Anthropic SDK

Connect UNIZO MCP to Anthropic's Claude SDK with native tool calling support.

Overview

The Anthropic Python SDK provides direct integration with Claude models and supports MCP (Model Context Protocol) through its tool calling capabilities. This guide shows how to connect UNIZO MCP server to Claude using the official Anthropic SDK with the MCP client library.

Prerequisites

Before setting up the MCP integration, you'll need:

  • Unizo API Key: Used for authentication (found in the Unizo Console)
  • Python 3.10+: Required for async support and MCP client
  • Anthropic API Key: For accessing Claude models

Installation

uv add anthropic mcp python-dotenv

Or using pip:

pip install anthropic mcp python-dotenv

Authentication

Step 1: Generate a Service Key

Use your Unizo API key to generate a service key for MCP authentication:

curl --location 'https://api.unizo.ai/api/v1/serviceKeys' \
--header "apiKey: {unizo_api_key}" \
--header "Content-Type: application/json" \
--data '{
"name": "MCP Ticketing Integration",
"subOrganization": {
"name": "{YOUR_CUSTOMER_NAME}",
"externalKey": "{YOUR_CUSTOMER_UNIQUE_IDENTIFIER}"
},
"integration": {
"target": {
"categorySelectors": [
{
"type": "TICKETING"
}
]
}
}
}'

Required Parameters:

ParameterDescription
apiKeyYour Unizo API key (found in the Unizo Console)
nameDescriptive name for the integration (e.g., "MCP Ticketing Integration")
subOrganization.nameYour organization name (e.g., "Acme Inc")
subOrganization.externalKeyUnique identifier (UUID format recommended)

Response:

{
"state": "ACTIVE",
"displayId": "{UNIZO_SERVICE_KEY}",
...
}

Important: Save the displayId from the response - this is your service key for authenticating with the MCP server.

Step 2: Configure Environment Variables

Create a .env file in your project root:

UNIZO_SERVICE_KEY=your_service_key_from_displayId
ANTHROPIC_API_KEY=your_anthropic_api_key

Quick Start

Connect to UNIZO MCP and use Claude with tool calling:

import os
import asyncio
from anthropic import Anthropic
from mcp.client.streamable_http import streamablehttp_client
from mcp import ClientSession
from dotenv import load_dotenv

load_dotenv()

async def main():
# Connect to Unizo MCP server
async with streamablehttp_client(
url="https://api.unizo.ai/mcp",
headers={
"servicekey": os.getenv('UNIZO_SERVICE_KEY'),
"x-mcp-scopes": "ticketing"
}
) as (read, write, get_session_id):
async with ClientSession(read, write) as session:
await session.initialize()

# Get available tools from MCP server
tools_response = await session.list_tools()
tools = [{
"name": t.name,
"description": t.description,
"input_schema": t.inputSchema
} for t in tools_response.tools]

# Create Anthropic client and send message
client = Anthropic()
messages = [{"role": "user", "content": "List all open tickets"}]

response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=4096,
tools=tools,
messages=messages
)

# Handle tool calls from Claude
if response.stop_reason == "tool_use":
for block in response.content:
if block.type == "tool_use":
result = await session.call_tool(
block.name,
arguments=block.input
)
print(result.content[0].text)

asyncio.run(main())

Headers:

HeaderDescription
servicekeyYour Unizo service key (from the authentication step)
x-mcp-scopesComma-separated scopes (ticketing, vms, or both)

Troubleshooting

Service key authentication failed

  • Verify your service key is correct in the .env file
  • Ensure the service key is ACTIVE (check API response)

Scope not authorized

  • Confirm your service key was generated with the correct category selector
  • For multiple scopes, ensure all required categories are included in the service key generation

Connection timeout

  • Check your internet connection
  • Verify the MCP server URL: https://api.unizo.ai/mcp

Tool calls not working

  • Ensure you're properly converting MCP tools to Anthropic tool format
  • Verify the input_schema is correctly mapped from inputSchema