---
title: For developers (SDKs)
description: Use Hostino MCP from your own code with the Vercel AI SDK, OpenAI, the Anthropic API and the official MCP SDKs
sidebar:
  order: 16
  badge:
    text: Alpha
    variant: success
---

If you are building your own app or agent, you can call Hostino tools directly from code.

| Item | Value |
|---|---|
| URL | `https://mcp.hostino.ai/mcp` |
| Transport | Streamable HTTP |
| Authentication | `Authorization: Bearer <access_token>` |
| Token lifetime | access one hour; refresh fourteen days |

## Getting a token

You have three options:

1. **API token (simplest)**: at [auth.hostino.ai/app](https://auth.hostino.ai/app) → "API tokens" create an `hst_pat_…` token with the permissions and lifetime you need and use it directly in place of `access_token` ([details](/en/ai-mcp/authentication/#api-tokens-personal-access-tokens)).
2. **Device Flow** (simplest for scripts, CI and testing): run the commands in [Quick start, method 2](/en/api/getting-started/) and request the scopes you need, for example `services:read domains:read dns:read offline_access`. Pass the `access_token` to your code and use the `refresh_token` to get a fresh one every hour.
3. **OAuth inside your app**: client-side SDKs (AI SDK, MCP SDK, OpenAI Agents JS) run the whole OAuth flow themselves with an `authProvider`: automatic registration (DCR), PKCE and refresh.

:::caution
The "hosted" tools in OpenAI Responses and Anthropic Messages do not do OAuth themselves; your app must obtain the token and send it with every request. Treat the token like a password and request only the scopes you need.
:::

## Vercel AI SDK

```ts
// npm i ai @ai-sdk/mcp
import { createMCPClient } from '@ai-sdk/mcp';
import { generateText, stepCountIs } from 'ai';

const mcp = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://mcp.hostino.ai/mcp',
    headers: { Authorization: `Bearer ${process.env.HOSTINO_TOKEN}` },
    // or: authProvider (an MCP SDK OAuthClientProvider) for automatic OAuth
  },
});

try {
  const { text } = await generateText({
    model: 'anthropic/claude-sonnet-5.5',
    tools: await mcp.tools(),
    stopWhen: stepCountIs(5),
    prompt: 'List the services that are due in less than 30 days',
  });
  console.log(text);
} finally {
  await mcp.close();
}
```

In older versions (AI SDK 5) the function is `experimental_createMCPClient` from the `ai` package.

## OpenAI Responses API

```python
from openai import OpenAI

client = OpenAI()
resp = client.responses.create(
    model="gpt-5",
    tools=[{
        "type": "mcp",
        "server_label": "hostino",
        "server_url": "https://mcp.hostino.ai/mcp",
        "authorization": HOSTINO_TOKEN,       # the token itself, without "Bearer "
        "require_approval": "always",
        "allowed_tools": ["list_services", "list_domains"],
    }],
    input="Which of my domains expire soon?",
)
print(resp.output_text)
```

With `require_approval: "always"`, each call returns an `mcp_approval_request` that you approve with an `mcp_approval_response` (together with `previous_response_id`). Use `allowed_tools` to limit access to read-only tools.

## OpenAI Agents SDK

```python
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async with MCPServerStreamableHttp(
    name="Hostino",
    params={"url": "https://mcp.hostino.ai/mcp",
            "headers": {"Authorization": f"Bearer {token}"}},
    cache_tools_list=True,
) as server:
    agent = Agent(name="Assistant", mcp_servers=[server])
    result = await Runner.run(agent, "List my services")
    print(result.final_output)
```

## Anthropic Messages API (MCP connector)

```python
import anthropic

client = anthropic.Anthropic()
response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=1000,
    messages=[{"role": "user", "content": "List my Hostino services"}],
    mcp_servers=[{"type": "url", "url": "https://mcp.hostino.ai/mcp",
                  "name": "hostino", "authorization_token": token}],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "hostino"}],
    betas=["mcp-client-2025-11-20"],
)
```

To limit it to a few tools: `{"type": "mcp_toolset", "mcp_server_name": "hostino", "default_config": {"enabled": false}, "configs": {"list_services": {"enabled": true}}}`.

## Official MCP SDKs

### TypeScript

```ts
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';

const client = new Client({ name: 'my-app', version: '1.0.0' });
await client.connect(new StreamableHTTPClientTransport(new URL('https://mcp.hostino.ai/mcp'), {
  requestInit: { headers: { Authorization: `Bearer ${token}` } },
  // or: authProvider for automatic OAuth
}));
const { tools } = await client.listTools();
const res = await client.callTool({ name: 'list_domains', arguments: {} });
```

### Python

```python
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

headers = {"Authorization": f"Bearer {token}"}
async with streamablehttp_client("https://mcp.hostino.ai/mcp", headers=headers) as (read, write, _):
    async with ClientSession(read, write) as s:
        await s.initialize()
        tools = await s.list_tools()
        res = await s.call_tool("list_services", {})
```

For automatic OAuth in Python, use `mcp.client.auth.OAuthClientProvider`.

## Notes

- Each tool needs a specific scope (listed in [Remote MCP](/en/ai-mcp/remote-mcp/) and [Authentication](/en/ai-mcp/authentication/)). If the token lacks the scope, the tool returns a "Missing permission" error.
- **Purchases and payments from code still need the account owner's confirmation**: `request_order` returns an approval link, and in-chat confirmation needs a phrase that the user types themselves.
- If you only need data and no language model, the [API](/en/api/introduction/) with the same token is simpler.
- Every tool call is recorded in the panel → API / MCP → "Usage log" (app/token, tool, result, duration and `request_id`). When you contact support about an error, send the `request_id` ([details](/en/ai-mcp/troubleshooting/#usage-log-and-request-id)).
- To see new capabilities, read the [changelog feed](/en/ai-mcp/changelog/) (`GET https://api.hostino.ai/v1/changelog` or the `changelog_list` tool).
