LangChain
Connect Unizo MCP to LangChain using the MCP adapters package.
Overview
LangChain provides MCP integration through langchain-mcp-adapters, converting MCP tools into LangChain-compatible tools.
Prerequisites
Before setting up the MCP integration, you'll need:
- Unizo API Key: Used for authentication (found in the Unizo Console)
- Python 3.11+: Required for LangChain MCP adapters
- OpenAI API Key: For the underlying LLM (or other supported LLM provider)
Installation
pip install langchain-classic langchain-mcp-adapters langchain-openai
Or with uv:
uv add langchain-classic langchain-mcp-adapters langchain-openai
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 LangChain Integration",
"subOrganization": {
"name": "{YOUR_CUSTOMER_NAME}",
"externalKey": "{YOUR_CUSTOMER_UNIQUE_IDENTIFIER}"
},
"integration": {
"target": {
"categorySelectors": [
{
"type": "TICKETING"
}
]
}
}
}'
Required Parameters:
| Parameter | Description |
|---|---|
apiKey | Your Unizo API key (found in the Unizo Console) |
name | Descriptive name for the integration (e.g., "MCP LangChain Integration") |
subOrganization.name | Your organization name (e.g., "Acme Inc") |
subOrganization.externalKey | Unique 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:
OPENAI_API_KEY=your_openai_api_key
Quick Start
Connect to Unizo MCP and use tools in LangChain:
import os
import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_classic.agents import AgentExecutor, create_tool_calling_agent
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from dotenv import load_dotenv
load_dotenv()
async def main():
# Connect to Unizo MCP server
client = MultiServerMCPClient({
"unizo": {
"url": "https://api.unizo.ai/mcp",
"transport": "streamable_http",
"headers": {
"servicekey": os.getenv("UNIZO_SERVICE_KEY"),
"x-mcp-scopes": "TICKETING" # Comma-separated scopes (TICKETING, VMS, etc.)
}
}
})
# Get Unizo tools
tools = await client.get_tools()
# Create agent with Unizo tools
llm = ChatOpenAI(model="gpt-4o", temperature=0)
prompt = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant with access to Unizo's unified integration platform."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}")
])
agent = create_tool_calling_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools)
# Run agent
result = await agent_executor.ainvoke({"input": "List ticketing connectors"})
print(result["output"])
if __name__ == "__main__":
asyncio.run(main())
Headers
| Header | Description |
|---|---|
servicekey | Your Unizo service key (from the authentication step) |
x-mcp-scopes (optional) | Supported scopes include TICKETING, VMS, INCIDENT, SCM, PCR, COMMS, IDENTITY, OBSERVABILITY, KEY_MANAGEMENT, INFRA, EDR, STORAGE, and PLATFORM. Note: If x-mcp-scopes is not specified, all scopes are enabled by default. |