Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cloro",
"displayName": "cloro",
"version": "0.7.0",
"version": "0.9.0",
"description": "Query ChatGPT, Gemini, Google AI Mode, Bing AI Mode, Google Search, Google News and Bing Search as agent tools, with country and state-level geo-targeting.",
"author": {
"name": "cloro",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: npm run build

# The build is only useful if the server still speaks MCP. Run a real
# initialize + tools/list handshake over stdio and assert the ten tools
# initialize + tools/list handshake over stdio and assert the twelve tools
# are registered, so a broken tool module fails here rather than in a
# client.
- name: Smoke test the MCP handshake
Expand All @@ -48,8 +48,8 @@ jobs:
.find((m) => m.id === 2)?.result?.tools;
if (!tools) throw new Error("no tools/list response");
console.log(`${tools.length} tools: ${tools.map((t) => t.name).join(", ")}`);
if (tools.length !== 10) {
throw new Error(`expected 10 tools, got ${tools.length}`);
if (tools.length !== 12) {
throw new Error(`expected 12 tools, got ${tools.length}`);
}
});
'
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ OAuth is off unless you set `CLERK_ISSUER`. The hosted server sets it to `https:
| `scrape_bing` | [`POST /v1/monitor/bing`](https://cloro.dev/docs/api-reference/endpoint/monitor-bing) |
| `scrape_google_news` | [`POST /v1/monitor/google/news`](https://cloro.dev/docs/api-reference/endpoint/monitor-google-news) |
| `resolve_google_redirect` | [`POST /v1/monitor/google/goto`](https://cloro.dev/docs/api-reference/endpoint/google/resolve-goto) |
| `get_google_product` | [`POST /v1/monitor/google/product`](https://cloro.dev/docs/api-reference/endpoint/google/product) |
| `list_countries` | [`GET /v1/countries`](https://cloro.dev/docs/api-reference/endpoint/countries) |
| `list_states` | [`GET /v1/states`](https://cloro.dev/docs/api-reference/endpoint/states) |
| `get_credits` | [`GET /v1/credits`](https://cloro.dev/docs/api-reference/endpoint/get-credits) |

The assistant tools take a `prompt` and a `country` (ISO 3166-1 alpha-2), plus an optional `state` for US state-level targeting. The Google tools take `gl` for the result geography and an optional `hl` for the interface language; `country` still works as a deprecated alias for `gl`. `scrape_google_ai_mode` targets sub-country with `location` or `uule` rather than `state`. `scrape_google` runs either from a `query` plus `gl`, or from a complete `google.com/search` URL that carries the query and pagination itself, and accepts `include.aioverview` for Google's AI Overview. `scrape_bing` takes a `query` and a `country`, which picks Bing's market, plus an optional `pages` and `first`. It has no `state` or `device` option, and accepts `include.aioverview` for Bing's AI Overview. Every tool takes an optional `include` object for heavier payload fields; leave it unset for the leanest response.

A Google result `link` can come back empty, or as a `google.com/goto` URL, with a `redirectLink` beside it. Pass the `redirectLink` to `resolve_google_redirect` to get the destination.

A shopping card or inline product from `scrape_google` or `scrape_google_ai_mode` can carry a `productResultToken`. Pass it to `get_google_product` within 5 minutes of that scrape to get the full product: offers, images, specifications and reviews.

There is no Grok tool. Grok is discontinued: grok.com shows a sign-up wall to logged-out visitors, and the cloro API rejects Grok calls with a `400` (`MODEL_UNAVAILABLE`).

There are no Copilot or Perplexity tools. Both are discontinued: they block access for logged-out sessions, and the cloro API rejects their calls with a `400` (`MODEL_UNAVAILABLE`). These calls cost no credits.
Expand All @@ -92,7 +96,7 @@ No. `mcp.cloro.dev` is hosted and is the path most people should take. This repo

### Does it cost credits?

Yes. The scrape tools call the sync API, so each call costs the API rate plus a 2-credit sync surcharge. For example, a ChatGPT call costs 7 credits (5 + 2). Each tool description states its cost, and each result returns the credits charged and remaining. `resolve_google_redirect` costs 1 credit, with no surcharge. `list_countries` and `list_states` read fixed reference lists and charge nothing. See [pricing](https://cloro.dev/pricing/).
Yes. The scrape tools call the sync API, so each call costs the API rate plus a 2-credit sync surcharge. For example, a ChatGPT call costs 7 credits (5 + 2). Each tool description states its cost, and each result returns the credits charged and remaining. `get_google_product` costs 1 credit plus the surcharge, and only when the product is returned. `resolve_google_redirect`, `get_credits`, `list_countries` and `list_states` charge nothing. See [pricing](https://cloro.dev/pricing/).

### Why is my API key in the URL?

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloro/mcp-server",
"version": "0.7.0",
"version": "0.9.0",
"description": "MCP server for the cloro API. Query ChatGPT, Gemini, Google AI Mode, Bing AI Mode, Google Search, Google News and Bing Search as agent tools.",
"license": "MIT",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion server.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "dev.cloro/cloro",
"title": "cloro",
"description": "Scrape AI answer engines, Google Search/News and Bing Search with country and state geo-targeting.",
"version": "0.7.0",
"version": "0.9.0",
"websiteUrl": "https://cloro.dev/docs/integrations/mcp",
"repository": {
"url": "https://github.com/cloro-dev/mcp-server",
Expand Down
1 change: 1 addition & 0 deletions src/schemas/chatgpt.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ALL_COUNTRY_CODES } from "./all-countries";
import { getAvailableCountries } from "./utils";

const CHATGPT_BLOCKED_COUNTRIES: string[] = [
"BY", // Belarus
"CN", // China
"HK", // Hong Kong
"IR", // Iran
Expand Down
5 changes: 5 additions & 0 deletions src/schemas/google-product.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { z } from "zod";

export const googleProductSchema = z.strictObject({
productResultToken: z.string().trim().min(1).max(512),
});
7 changes: 5 additions & 2 deletions src/schemas/google-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* the location encoding — so the worker needs no knowledge of `url` mode to
* serve the request.
*
* The supported set is closed: `q`, `gl`, `hl`, `uule`, `start`, `tbs`, `safe`
* (plus `num`, read as depth). Params outside it are dropped rather than
* The supported set is closed: `q`, `gl`, `hl`, `uule`, `start`, `tbs`, `safe`,
* `udm` (plus `num`, read as depth). Params outside it are dropped rather than
* forwarded, so the queue message stays a typed contract the worker can rely
* on instead of an arbitrary bag whose keys nothing validates.
*
Expand Down Expand Up @@ -61,6 +61,8 @@ export type GoogleUrlParsed = {
tbs: string | null;
/** `safe` — SafeSearch setting, passed through untouched. */
safe: string | null;
/** `udm` — the results tab. Only 14, the Web tab, is read. */
udm: 14 | null;
};

export type GoogleUrlParseResult =
Expand Down Expand Up @@ -161,5 +163,6 @@ export const parseGoogleSearchUrl = (raw: string): GoogleUrlParseResult => {
),
tbs: readTrimmed(url.searchParams, "tbs"),
safe: readTrimmed(url.searchParams, "safe"),
udm: readTrimmed(url.searchParams, "udm") === "14" ? 14 : null,
};
};
17 changes: 17 additions & 0 deletions src/schemas/google.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export const googleSchema = z
// "caller sent pages" from "caller sent nothing". The default is applied in
// the transform, so parsed output is unchanged for structured requests.
pages: z.number().positive().max(10).optional(),
// Google's `udm`, the results tab to search. 14 is the Web tab, the only
// one served besides the default.
udm: z.literal(14).optional(),
include: z
.object({
html: z.boolean(),
Expand All @@ -59,6 +62,14 @@ export const googleSchema = z
z
.object({
markdown: z.boolean(),
/**
* Store the HTML page with the AI Overview opened ("Show more"
* clicked). By default the page shows it as a browser does
* after load: Google opens some itself and leaves others
* collapsed. Desktop only: on phones "Show more" opens AI Mode.
* The parsed `aioverview` is the full answer either way.
*/
expand: z.boolean(),
})
.partial(),
]),
Expand All @@ -78,6 +89,9 @@ export const googleSchema = z
})
.partial()
.optional(),
// Temporary (ENG-1238): asks for the datacenter worker fleet. Only cloro's
// own organization is routed there.
datacenter: z.boolean().optional(),
})
.refine((data) => !(data.location && data.uule), {
message: "Cannot set both location and uule; provide only one",
Expand Down Expand Up @@ -230,5 +244,8 @@ export const googleSchema = z
startOffset: parsed.startOffset as number | undefined,
tbs: parsed.tbs ?? undefined,
safe: parsed.safe ?? undefined,
// The body's `udm` and the URL's can each only be 14, so they cannot
// disagree the way `hl` / `gl` can.
udm: data.udm ?? parsed.udm ?? undefined,
};
});
1 change: 1 addition & 0 deletions src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from "./gemini.schema";
export * from "./google.schema";
export * from "./google-news.schema";
export * from "./google-goto.schema";
export * from "./google-product.schema";
export * from "./grok.schema";
export * from "./perplexity.schema";
export * from "./country.schema";
Expand Down
26 changes: 21 additions & 5 deletions src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ import { buildServer } from "./server";

import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";

// Free reads of cloro's own data: no credit cost, no live engine.
const isReferenceTool = (name: string): boolean =>
name.startsWith("list_") || name === "get_credits";

const EXPECTED_TOOLS = [
"scrape_chatgpt",
"scrape_gemini",
"scrape_google_ai_mode",
"scrape_bing_aimode",
"scrape_google_ai_mode",
"scrape_google",
"scrape_bing",
"scrape_google_news",
"resolve_google_redirect",
"get_google_product",
"list_countries",
"list_states",
"get_credits",
];

type ToolSchema = {
Expand Down Expand Up @@ -82,8 +88,8 @@ describe("cloro MCP server", () => {
expect(tool.annotations?.readOnlyHint, tool.name).toBe(true);
expect(tool.annotations?.destructiveHint, tool.name).toBe(false);
// Monitor tools hit live external engines and re-charge on every
// call; reference lookups read fixed lists and are free to repeat.
const isReference = tool.name.startsWith("list_");
// call; reference lookups read cloro's own data and are free to repeat.
const isReference = isReferenceTool(tool.name);
expect(tool.annotations?.openWorldHint, tool.name).toBe(!isReference);
expect(tool.annotations?.idempotentHint, tool.name).toBe(
isReference ? true : undefined,
Expand All @@ -103,7 +109,7 @@ describe("cloro MCP server", () => {
// conform, so only the tools with a fixed response shape declare one.
it("declares an outputSchema only on the reference tools", () => {
for (const tool of tools) {
const isReference = tool.name.startsWith("list_");
const isReference = isReferenceTool(tool.name);
expect(Boolean(tool.outputSchema), tool.name).toBe(isReference);
}
});
Expand Down Expand Up @@ -153,6 +159,16 @@ describe("cloro MCP server", () => {
expect(tool.inputSchema.required ?? []).toEqual([]);
});

it("keeps the internal datacenter flag off scrape_google", () => {
const tool = tools.find((t) => t.name === "scrape_google")!;
expect(tool.inputSchema.properties).not.toHaveProperty("datacenter");
});

it("offers udm on scrape_google, with 14 as its only value", () => {
const tool = tools.find((t) => t.name === "scrape_google")!;
expect(tool.inputSchema.properties?.udm).toMatchObject({ const: 14 });
});

it("advertises scrape_google's public include flags", () => {
const tool = tools.find((t) => t.name === "scrape_google")!;
const includeProps = tool.inputSchema.properties?.include?.properties;
Expand Down Expand Up @@ -435,7 +451,7 @@ describe("cloro MCP server", () => {
it("states the credit cost in every monitor tool description", async () => {
const { tools: listed } = await client.listTools();
for (const tool of listed) {
if (tool.name.startsWith("list_")) continue;
if (isReferenceTool(tool.name)) continue;
expect(tool.description, tool.name).toMatch(/Costs \d+ credits?/);
}
});
Expand Down
8 changes: 5 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ import { registerReferenceTools } from "./tools/reference-tools";
*/
const INSTRUCTIONS = `cloro scrapes AI answer engines (ChatGPT, Gemini, Google AI Mode, Bing AI Mode), Google Search and News, and Bing Search, geo-targeted by country.

Costs: every scrape tool calls the sync API and costs its base credits, plus any add-ons, plus a 2-credit sync surcharge. Each tool description states its cost. Each result carries credits.charged and credits.remaining. list_countries and list_states are free. resolve_google_redirect costs 1 credit and has no surcharge.
Costs: every scrape tool calls the sync API and costs its base credits, plus any add-ons, plus a 2-credit sync surcharge. Each tool description states its cost. Each result carries credits.charged and credits.remaining. list_countries, list_states, get_credits and resolve_google_redirect are free. get_google_product costs 1 credit plus the sync surcharge.

Large or long-running jobs: these tools wait for the answer, up to about 5 minutes per call. For many prompts, or for scheduled runs, use the async API (POST /v1/async/task and /v1/async/task/batch, https://cloro.dev/docs) directly instead. It has no sync surcharge and returns results by webhook or polling.

Empty links: a Google result link can come back empty, missing, or as a google.com/goto URL, with a redirectLink beside it. Pass that redirectLink to resolve_google_redirect to get the destination. Do not open a /goto URL yourself.`;
Empty links: a Google result link can come back empty, missing, or as a google.com/goto URL, with a redirectLink beside it. Pass that redirectLink to resolve_google_redirect to get the destination. Do not open a /goto URL yourself.

Product details: a Google or AI Mode shopping card or inline product can carry a productResultToken. Pass it to get_google_product within 5 minutes of the scrape that returned it. A 410 means the token expired; run the scrape again for a new token.`;

export function buildServer(apiKey: string): McpServer {
const server = new McpServer(
{
name: "cloro",
version: "0.7.0",
version: "0.9.0",
},
{ instructions: INSTRUCTIONS },
);
Expand Down
Loading
Loading