Use it from code
curl, Python and TypeScript samples.
Any MCP SDK works. Every request carries the token and the server keeps no session between requests, so there is no session id to manage.
List tools
curl https://ads.drefly.pro/api/ads/mcp \
-H "Authorization: Bearer $DREFLY_ADS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' import asyncio
import os
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
URL = "https://ads.drefly.pro/api/ads/mcp"
HEADERS = {"Authorization": f"Bearer {os.environ['DREFLY_ADS_TOKEN']}"}
async def main():
async with streamablehttp_client(URL, headers=HEADERS) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
print([t.name for t in tools.tools])
asyncio.run(main())import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const transport = new StreamableHTTPClientTransport(new URL("https://ads.drefly.pro/api/ads/mcp"), {
requestInit: { headers: { Authorization: `Bearer ${process.env.DREFLY_ADS_TOKEN}` } },
});
const client = new Client({ name: "nova-ads-bot", version: "1.0.0" });
await client.connect(transport);
const { tools } = await client.listTools();
console.log(tools.map((t) => t.name));Call a tool
curl https://ads.drefly.pro/api/ads/mcp \
-H "Authorization: Bearer $DREFLY_ADS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list_placements","arguments":{}}}' import asyncio
import os
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
URL = "https://ads.drefly.pro/api/ads/mcp"
HEADERS = {"Authorization": f"Bearer {os.environ['DREFLY_ADS_TOKEN']}"}
async def main():
async with streamablehttp_client(URL, headers=HEADERS) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool("list_placements", {})
print(result.structuredContent)
asyncio.run(main())import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const transport = new StreamableHTTPClientTransport(new URL("https://ads.drefly.pro/api/ads/mcp"), {
requestInit: { headers: { Authorization: `Bearer ${process.env.DREFLY_ADS_TOKEN}` } },
});
const client = new Client({ name: "nova-ads-bot", version: "1.0.0" });
await client.connect(transport);
const result = await client.callTool({ name: "list_placements", arguments: {} });
console.log(result.structuredContent);Reading results
Successful calls return the data as JSON text in content and as an object in structuredContent. Failed calls return isError set to true with a plain message.
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [{ "type": "text", "text": "{\"pages\": [...]}" }],
"structuredContent": { "pages": ["..."] },
"isError": false
}
}Next steps
Was this page helpful?
Thanks for the feedback. Tell us what was missing