Use Casafari from the OpenAI API and the Claude API
An AI API integration with Casafari takes one request. Both the OpenAI API and the Claude API can call a remote MCP server for you: you pass Casafari's MCP server URL and a credential, and the model provider connects to it (https://platform.casafari.com/mcp, every product's tools), lists the tools, calls the ones the question needs and returns the answer. You write no tool-calling code.
Each product is its own MCP server on the Casafari API and MCP Platform (all URLs); add one entry per product the question needs. mcp.casafari.com is the legacy gateway, still answering, moving to https://platform.casafari.com/mcp/<product>.
This is the way to give your own app or agent Casafari data through the model you already use. For assistants such as Claude or ChatGPT used directly, see Connect an MCP client; for fixed requests from your own code without a model, use the REST API.
Before you start: a credential
The MCP server needs a platform credential (MCP authorization).
- A server-side agent or job (no person signing in): the simplest is a platform API key (
cf_sk_...) from the console at https://platform.casafari.com/console: it works on every product's MCP server and on REST. Or create a confidential OAuth client there and ask the token endpoint for a token bound to one server:
curl -s -X POST https://platform.casafari.com/oauth/token \
-u "$CASAFARI_CLIENT_ID:$CASAFARI_CLIENT_SECRET" \
-d grant_type=client_credentials \
--data-urlencode resource=https://platform.casafari.com/mcp The answer carries access_token and expires_in (15 minutes, no refresh token). Ask for a new one when it expires.
- On behalf of a person: run the authorization code flow with PKCE in your app and pass that person's token, so the model acts with their rights (MCP authorization).
Pass the key or token in the API's own field, shown below. Never put it in a prompt. The examples read it from CASAFARI_ACCESS_TOKEN.
OpenAI API (Responses API)
Add Casafari as a tool of type mcp. The authorization field carries the key or access token; OpenAI does not store it, so send it with every request.
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-6-astra", // any OpenAI model with MCP tool support
tools: [
{
type: "mcp",
server_label: "casafari",
server_description: "Casafari real estate data: comparables, valuations, area insights.",
server_url: "https://platform.casafari.com/mcp",
authorization: process.env.CASAFARI_ACCESS_TOKEN,
allowed_tools: ["comparables_get_comparables"],
require_approval: "never",
},
],
input: "What is a 3-bedroom flat near Avenida da Liberdade, Lisbon worth? Use comparables within 1 km.",
});
console.log(response.output_text);import os
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-6-astra", # any OpenAI model with MCP tool support
tools=[
{
"type": "mcp",
"server_label": "casafari",
"server_description": "Casafari real estate data: comparables, valuations, area insights.",
"server_url": "https://platform.casafari.com/mcp",
"authorization": os.environ["CASAFARI_ACCESS_TOKEN"],
"allowed_tools": ["comparables_get_comparables"],
"require_approval": "never",
},
],
input="What is a 3-bedroom flat near Avenida da Liberdade, Lisbon worth? Use comparables within 1 km.",
)
print(response.output_text)allowed_toolslimits the tools the model sees; leave it out to offer every tool of the server.require_approval: "never"suits read-only tools. Keep approval on for tools that change saved state (see MCP security).
ChatGPT apps and Codex
People who use ChatGPT or Codex directly do not need the API. Casafari's servers are packaged as ChatGPT apps (Claro AI by Casafari, Comparables, Area Insights and Location Lookup): add one and sign in with your Casafari platform account. The same package works in Codex. Until an app is listed in ChatGPT's directory, connect its server URL in developer mode (Connect).
For ChatGPT Business and Enterprise admins
A workspace admin can make Casafari available to everyone in the workspace as a custom connector, by URL:
- Turn on developer mode for yourself: Workspace settings → Permissions & Roles → Connected Data → Developer mode / Create custom MCP connectors. On Business only admins and owners can; on Enterprise and Edu, roles (RBAC) can give it to selected people.
- Create an app with Casafari's server URL,
https://platform.casafari.com/mcp, and choose OAuth. ChatGPT registers itself with the platform; there is no client id or secret to paste. - Test it, then publish it: Workspace settings → Apps → Drafts → Publish. It shows in everyone's Apps list marked "custom". Each person signs in with their own Casafari platform account the first time, so calls spend their organisation's tokens and follow its plan.
On Business plans a published app cannot be edited yet: to change it, create and publish it again (OpenAI's help article).
Add one connector per product: https://platform.casafari.com/mcp/comparables, https://platform.casafari.com/mcp/area-insights, https://platform.casafari.com/mcp/locations and https://platform.casafari.com/mcp/claro. Every tool only reads data. Casafari's tools never ask for a person's ChatGPT data.
Claude API (Messages API)
Use the MCP connector: declare the server in mcp_servers and reference it from an mcp_toolset entry in tools, with the mcp-client-2025-11-20 beta. authorization_token carries the key or access token.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const response = await client.beta.messages.create({
model: "claude-opus-5-5",
max_tokens: 16000,
betas: ["mcp-client-2025-11-20"],
mcp_servers: [
{
type: "url",
url: "https://platform.casafari.com/mcp",
name: "casafari",
authorization_token: process.env.CASAFARI_ACCESS_TOKEN,
},
],
tools: [{ type: "mcp_toolset", mcp_server_name: "casafari" }],
messages: [{ role: "user", content: "What is a 3-bedroom flat near Avenida da Liberdade, Lisbon worth? Use comparables within 1 km." }],
});
for (const block of response.content) {
if (block.type === "text") console.log(block.text);
}import os
import anthropic
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-opus-5-5",
max_tokens=16000,
betas=["mcp-client-2025-11-20"],
mcp_servers=[
{
"type": "url",
"url": "https://platform.casafari.com/mcp",
"name": "casafari",
"authorization_token": os.environ["CASAFARI_ACCESS_TOKEN"],
}
],
tools=[{"type": "mcp_toolset", "mcp_server_name": "casafari"}],
messages=[{"role": "user", "content": "What is a 3-bedroom flat near Avenida da Liberdade, Lisbon worth? Use comparables within 1 km."}],
)
for block in response.content:
if block.type == "text":
print(block.text)To offer only some tools, turn the rest off in the toolset: {"type": "mcp_toolset", "mcp_server_name": "casafari", "default_config": {"enabled": false}, "configs": {"comparables_get_comparables": {"enabled": true}}}.
Agent frameworks
Most agent frameworks include an MCP client. Point it at Casafari's server, https://platform.casafari.com/mcp (Streamable HTTP), and give it the key or token, or let it run the OAuth flow; the tool reference lists every tool and its inputs.
An API for AI agents, two ways
- Through a model (this page): the model decides which Casafari tools to call. Best when the questions vary.
- Directly (REST API: the platform's
https://platform.casafari.com/v1/<product>with the same API key, or the existinghttps://api.casafari.comfor its clients): your code makes fixed requests. Best for the same job every time, bulk work, or apps without a model. MCP vs REST API shows which data each offers.