Connect Klazify to Python with MCP
A Python pipeline that enriches signups needs more than a company name: it needs a repeatable way to classify each website and decide what to do when a result is missing. This guide shows how to connect a Python MCP client to Klazify, inspect the available tool inputs, and use returned categories to enrich a record or route it for review.
Why use Klazify for domain classification in Python?
MCP gives a Python application a tool-oriented way to request domain intelligence. Klazify’s categorization analyzes website content and can return hierarchical categories alongside IAB taxonomy mappings. That is useful when a signup supplies only a website and your product needs to assign the lead to an internal segment.
Klazify can analyze content across languages and return current classifications rather than relying solely on a static metadata lookup. A content-based result can provide more context than a domain name alone, especially when a company’s name does not reveal what it sells. Results still need review and a refresh strategy: a site can change, become unreachable, or contain more than one topic.
For advertising and filtering, hierarchical categories give teams a common starting point for policy decisions. For CRM enrichment, company information and logo data can add context to a lead record. These are different decisions: a category is evidence about content, not proof that a site is safe, compliant, or an appropriate customer.
The documented MCP tools are klazify.categorize, klazify.domain_company, and klazify.domain_logo. Each tool call counts as one API request, so request only the data your workflow needs. For example, classify a domain first and request a logo separately only if the downstream application will display it.
Connect a Python client to the MCP host
The MCP host is https://mcp.klazify.com/mcp. Start by checking connectivity, then use an MCP client to initialize a session and discover the tools. A plain GET request is a diagnostic, not a classification request:
curl -i -X GET https://mcp.klazify.com/mcp
The documented response to GET on this path is HTTP 405. That response does not mean the MCP service is unavailable; it means this GET request is not a tool invocation. Use the MCP client protocol rather than treating the host as a conventional categorization URL.
Discover the input and call categorization
Install the Python MCP package with python -m pip install mcp. The following example opens a session, prints the input schema exposed for klazify.categorize, and asks you to enter a JSON argument object that matches it. This avoids guessing the tool’s argument names.
import asyncio
import json
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
MCP_URL = "https://mcp.klazify.com/mcp"
TOOL_NAME = "klazify.categorize"
async def main():
async with streamable_http_client(MCP_URL) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
available = await session.list_tools()
tool = next(
(item for item in available.tools if item.name == TOOL_NAME),
None,
)
if tool is None:
raise RuntimeError("Categorization tool is not available")
print("Tool input schema:")
print(json.dumps(tool.inputSchema, indent=2))
arguments = json.loads(input("Enter tool arguments as JSON: "))
result = await session.call_tool(TOOL_NAME, arguments=arguments)
if getattr(result, "isError", False):
raise RuntimeError(str(result))
for item in result.content:
text = getattr(item, "text", None)
if not text:
continue
print("Tool response:")
print(text)
try:
payload = json.loads(text)
except json.JSONDecodeError:
continue
if not isinstance(payload, dict):
continue
domain = payload.get("domain") or {}
for category in domain.get("categories") or []:
print(
"Category:",
category.get("name"),
"confidence:",
category.get("confidence"),
)
if __name__ == "__main__":
asyncio.run(main())
Run the script, read the printed schema, and enter the domain or URL using the argument structure it describes. The code prints the tool’s response and reads categories if the returned JSON has the shape shown in the example below. If the tool returns a different structure, inspect its content and adapt the extraction step rather than assuming that every MCP tool returns the full example response.
Consult the Documentation for current access and authentication instructions before deploying the client. In production, take arguments from a validated queue or application input instead of an interactive prompt, and keep credentials out of source code and logs.
Read the categorization response
The following is the provided Klazify response example. It illustrates the fields a domain-enrichment pipeline may encounter; it should not be treated as a guarantee that each MCP tool returns every field shown.
{
"domain": {
"categories": [
{
"confidence": 0.92,
"name": "/Computers & Electronics/Consumer Electronics",
"IAB-632-596": "Consumer Electronics/Technology & Computing/Consumer Electronics"
},
{
"confidence": 0.89,
"name": "/Internet & Telecom/Mobile & Wireless/Mobile Phones"
}
],
"social_media": null,
"logo_url": "https://klazify.s3.amazonaws.com/2110787991611585019600ed5fb1d1300.04730104.png"
},
"success": true,
"objects": {
"company": {
"url": "https://www.apple.com/",
"name": "Apple",
"city": "Cupertino",
"stateCode": "CA",
"countryCode": "US",
"employeesRange": "100K+",
"revenue": 274515000000,
"raised": null,
"tags": [
"E-commerce",
"Consumer Electronics",
"Mobile",
"B2C"
],
"tech": [
"omniture_adobe_analytics",
"atlassian_confluence",
"successfactors",
"apache_apex",
"talend",
"oracle_peoplesoft",
"salesforce",
"stripe",
"dell_boomi_atomsphere",
"gigya",
"sage_50cloud",
"quickbooks",
"webmethods",
"apache_tomcat",
"alteryx",
"tibco_rendezvous",
"atlassian_jira",
"..."
]
}
},
"domain_registration_data": {
"domain_age_date": "1987-02-19",
"domain_age_days_ago": "13026",
"domain_expiration_date": "2030-02-20",
"domain_expiration_days_left": "123"
},
"similar_domains": [
"bestbuy.com",
"icloud.com",
"microsoft.com",
"macrumors.com",
"google.com",
"samsung.com",
"twitter.com",
"hp.com",
"bhphotovideo.com",
"dell.com"
]
}
Check success before treating this response as a completed enrichment. Then iterate through domain.categories: each entry has a category name and confidence, and an entry may also contain an IAB mapping. The sample shows two classifications, so a pipeline should not silently discard all but the first.
For a CRM record, objects.company.name and location fields can provide context, while domain.logo_url can support a visual display. Treat null values, such as the sample’s social_media, as missing data rather than empty strings or negative findings. The example also includes registration data and similar domains, but those fields should not be assumed to be output from the three MCP tools.
For an ad-placement audit, preserve both the original category and any returned IAB value. Map them to your own policy labels in a separate step, so a later change in your policy does not require rewriting the source response. For filtering, route uncertain or missing classifications to an explicit fallback instead of interpreting them as permission to allow or block.
Operate the integration at scale
Queue, cache, and refresh
Normalize incoming domains consistently before using them as cache keys, and retain the original input for troubleshooting. Cache the classification per domain when your decision is domain-level. If you classify individual URLs for page-level decisions, keep those results separate: one domain can contain pages about different subjects.
Use a queue and bounded worker concurrency for large imports rather than launching an unbounded call for every row. Check the current plan and service documentation for rate limits, then handle throttling and transient failures with controlled retries and backoff. Each MCP tool invocation counts as one API request, even when the calls belong to the same enrichment job.
Choose a cache lifetime based on how quickly the underlying site and your policy decisions need to change. Store when you retrieved the result, and schedule refreshes rather than treating an old category as permanent. Cache unsuccessful or unknown outcomes separately and for a shorter period if you plan to retry them.
Handle unknowns and map categories
New, unreachable, or insufficiently described domains may not yield the result your pipeline expects. Keep an explicit unknown state, record the reason available to your application, and send the item for retry or review. A failed or unreachable call is not billed, but it still needs operational handling so that the queue does not retry indefinitely.
Maintain a versioned mapping from returned category names or IAB values to your internal taxonomy. Decide how to handle multiple matches and missing mappings before enabling automated decisions. Confidence can help prioritize review, but select thresholds based on your own evaluation rather than assuming a score guarantees correctness.
Measure cache hits, tool-call volume, failures, unknown results, and end-to-end latency in your own environment. Keep raw responses where your data policies permit, alongside the mapping version used for each decision. That makes it possible to explain why a lead was enriched or a placement was flagged when either the site or your policy changes.
FAQ
Can I call the MCP host with a browser or plain GET?
A GET to /mcp returns 405. Use an MCP client to initialize a session and invoke a documented tool; the curl request above is only a connectivity diagnostic.
Can Claude or ChatGPT use the integration?
Claude uses mcp-remote. ChatGPT uses the OpenAI-compatible proxy at /v1/chat/completions. Their connection setup differs from the direct Python MCP session shown here.
Which tool should I call for an enrichment job?
Use klazify.categorize for categorization, klazify.domain_company for company information, and klazify.domain_logo for logo data. Discover each tool’s input schema and call only what the workflow requires.
What does a tool call cost?
Each tool call counts as one API request. The Starter plan is $39.99 per month with a 7-day trial, and failed or unreachable calls are not billed. Check current plan details before sizing a production workload.
Ready to test the workflow? Register for a free account, review the connection instructions, and start with a small set of domains before adding the client to your production queue.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free