apinoa-mcp 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 apinoa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,87 @@
1
- # Temporary Holding Version
1
+ # apinoa-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An [MCP](https://modelcontextprotocol.io) server for [apinoa](https://apinoa.com). It gives Claude, Cursor
4
+ and any other MCP client live product data from Amazon, Walmart, Shopify, TikTok Shop and AliExpress,
5
+ social data from TikTok, YouTube, Instagram, Threads, X, Reddit and LinkedIn, and image translation.
6
+
7
+ Ask things like *"compare the top wool socks on Amazon and Walmart under $20"*, *"what has @nasa posted on
8
+ TikTok this week"* or *"translate the text on this product photo into Korean"*.
9
+
10
+ ## Setup
11
+
12
+ Create a key under **Dashboard > API keys** at [apinoa.com](https://apinoa.com). Calls are billed to it
13
+ at the API's normal rates; a call that fails is not billed.
14
+
15
+ **Claude Code**
16
+
17
+ ```sh
18
+ claude mcp add apinoa -e APINOA_API_KEY=your_key -- npx -y apinoa-mcp
19
+ ```
20
+
21
+ **Claude Desktop, Cursor, Windsurf and others** — add to the client's MCP configuration
22
+ (`claude_desktop_config.json`, `.cursor/mcp.json`, …):
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "apinoa": {
28
+ "command": "npx",
29
+ "args": ["-y", "apinoa-mcp"],
30
+ "env": { "APINOA_API_KEY": "your_key" }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ Requires Node.js 20 or later.
37
+
38
+ ## Tools
39
+
40
+ | Tool | What it does |
41
+ |---|---|
42
+ | `search_products` | Search a marketplace by keyword, with filters |
43
+ | `search_products_by_image` | Find products matching a photo (given as a URL) |
44
+ | `get_product` | One product in full: variants, images, specs, seller, delivery |
45
+ | `get_product_reviews` | A product's reviews, page by page |
46
+ | `list_categories` / `browse_category` | Walk a marketplace's category tree and list a category's products |
47
+ | `get_social_profile` | One account: bio, follower counts, links |
48
+ | `list_social_posts` | An account's posts, a search, a hashtag, a community — or the trending feed |
49
+ | `get_social_post` | One post |
50
+ | `get_social_comments` | A post's comments or a comment's replies |
51
+ | `translate_image` | Replace the text in an image with a translation; returns the image |
52
+ | `call_apinoa` | Any other operation: store catalogs, shipping quotes, groups, LinkedIn jobs… |
53
+ | `list_platforms` | Every platform, its operations, their parameters and costs (free) |
54
+
55
+ Each tool takes a `platform`. The platforms and the parameters each accepts are read from the live API
56
+ catalog when the server starts, so a platform added to apinoa appears without updating this package.
57
+ Every tool only reads data.
58
+
59
+ ## Options
60
+
61
+ | Variable | Default | |
62
+ |---|---|---|
63
+ | `APINOA_API_KEY` | — | Required for every data call. |
64
+ | `APINOA_BASE_URL` | `https://gateway.apinoa.com` | |
65
+
66
+ To keep the model's context usable, a post's media lists its main file and thumbnail but not every other
67
+ size of it (the SDKs and the API return all of them). An answer still over 100,000 characters keeps as many
68
+ whole items as fit, with a note saying how many were left out; ask for fewer items or a narrower query.
69
+
70
+ ## Use as a library
71
+
72
+ ```ts
73
+ import { createApinoaServer } from "apinoa-mcp";
74
+
75
+ const server = await createApinoaServer({ apiKey: process.env.APINOA_API_KEY });
76
+ // connect it to any MCP transport, e.g. Streamable HTTP
77
+ ```
78
+
79
+ ## Related
80
+
81
+ - [apinoa](https://www.npmjs.com/package/apinoa): the TypeScript SDK
82
+ - [apinoa on PyPI](https://pypi.org/project/apinoa/): the Python SDK
83
+ - [API documentation](https://apinoa.com/docs)
84
+
85
+ ## License
86
+
87
+ MIT
package/dist/api.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The few HTTP calls the tools make. Plain fetch, not the SDK: the server describes its tools from the
3
+ * live catalog, so it reaches every operation by its URL, including ones published after this package.
4
+ */
5
+ export interface ApiOptions {
6
+ apiKey?: string;
7
+ baseUrl: string;
8
+ fetch: typeof fetch;
9
+ /** Per-call timeout. Image translation under load can take minutes. */
10
+ timeoutMs: number;
11
+ }
12
+ export interface CatalogEntry {
13
+ id: string;
14
+ kind: "marketplace" | "sns";
15
+ operations: string[];
16
+ regions?: string[];
17
+ cost?: Record<string, {
18
+ base: number;
19
+ max: number;
20
+ }>;
21
+ params: Record<string, {
22
+ properties?: Record<string, {
23
+ description?: string;
24
+ type?: string;
25
+ enum?: string[];
26
+ }>;
27
+ required?: string[];
28
+ }>;
29
+ }
30
+ /** A refusal from the API, with its stable code. */
31
+ export declare class ApiError extends Error {
32
+ readonly status: number;
33
+ readonly code: string;
34
+ readonly requestId?: string | undefined;
35
+ constructor(status: number, code: string, message: string, requestId?: string | undefined);
36
+ }
37
+ /** Flatten params into a query string the way the API reads it: lists comma-joined, nothing nested. */
38
+ export declare function toQuery(params: Record<string, unknown>): URLSearchParams;
39
+ /** One operation: GET with a query string, or POST with a JSON body when an input is an object (an image). */
40
+ export declare function callOperation(o: ApiOptions, platform: string, operation: string, params: Record<string, unknown>): Promise<unknown>;
41
+ export declare function fetchCatalog(o: ApiOptions): Promise<CatalogEntry[]>;
42
+ /** Image translation: raw bytes in, a JPEG (or, with render=false, JSON) out. */
43
+ export declare function translateImage(o: ApiOptions, image: Uint8Array, contentType: string, query: Record<string, string | boolean | undefined>): Promise<{
44
+ contentType: string;
45
+ bytes: Uint8Array;
46
+ regions?: number;
47
+ }>;
48
+ /** Download an image a tool was pointed at. */
49
+ export declare function download(o: ApiOptions, url: string, maxBytes?: number): Promise<{
50
+ bytes: Uint8Array;
51
+ contentType: string;
52
+ }>;
package/dist/api.js ADDED
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The few HTTP calls the tools make. Plain fetch, not the SDK: the server describes its tools from the
3
+ * live catalog, so it reaches every operation by its URL, including ones published after this package.
4
+ */
5
+ /** A refusal from the API, with its stable code. */
6
+ export class ApiError extends Error {
7
+ status;
8
+ code;
9
+ requestId;
10
+ constructor(status, code, message, requestId) {
11
+ super(`${code}: ${message}`);
12
+ this.status = status;
13
+ this.code = code;
14
+ this.requestId = requestId;
15
+ }
16
+ }
17
+ const RETRYABLE = new Set([429, 500, 502, 503, 504]);
18
+ /** Flatten params into a query string the way the API reads it: lists comma-joined, nothing nested. */
19
+ export function toQuery(params) {
20
+ const q = new URLSearchParams();
21
+ for (const [k, v] of Object.entries(params)) {
22
+ if (v === undefined || v === null || v === "")
23
+ continue;
24
+ q.set(k, Array.isArray(v) ? v.join(",") : String(v));
25
+ }
26
+ return q;
27
+ }
28
+ const hasObject = (params) => Object.values(params).some((v) => v !== null && typeof v === "object" && !Array.isArray(v));
29
+ async function send(o, path, init, attempts = 3) {
30
+ for (let i = 0;; i++) {
31
+ const res = await o.fetch(o.baseUrl + path, {
32
+ ...init,
33
+ headers: { ...(o.apiKey ? { "x-api-key": o.apiKey } : {}), "user-agent": "apinoa-mcp", ...init.headers },
34
+ signal: AbortSignal.timeout(o.timeoutMs),
35
+ });
36
+ if (!RETRYABLE.has(res.status) || i >= attempts - 1)
37
+ return res;
38
+ const header = res.headers.get("retry-after");
39
+ const wait = header === null ? NaN : Number(header);
40
+ await new Promise((r) => setTimeout(r, Math.min(30_000, (Number.isFinite(wait) && wait >= 0 ? wait : 2 ** i) * 1000)));
41
+ }
42
+ }
43
+ async function unwrap(res) {
44
+ const text = await res.text();
45
+ let body;
46
+ try {
47
+ body = JSON.parse(text);
48
+ }
49
+ catch {
50
+ throw new ApiError(res.status, `HTTP_${res.status}`, text.slice(0, 300) || res.statusText);
51
+ }
52
+ if (!res.ok || body?.success === false) {
53
+ throw new ApiError(res.status, body?.error?.code ?? `HTTP_${res.status}`, body?.error?.message ?? res.statusText, body?.requestId);
54
+ }
55
+ return body.data;
56
+ }
57
+ /** One operation: GET with a query string, or POST with a JSON body when an input is an object (an image). */
58
+ export async function callOperation(o, platform, operation, params) {
59
+ const path = `/v1/${encodeURIComponent(platform)}/${encodeURIComponent(operation)}`;
60
+ if (hasObject(params)) {
61
+ return unwrap(await send(o, path, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(params) }));
62
+ }
63
+ const q = toQuery(params).toString();
64
+ return unwrap(await send(o, q ? `${path}?${q}` : path, { method: "GET" }));
65
+ }
66
+ export async function fetchCatalog(o) {
67
+ const data = (await unwrap(await send({ ...o, timeoutMs: Math.min(o.timeoutMs, 10_000) }, "/v1/marketplaces", { method: "GET" }, 1)));
68
+ return data.marketplaces;
69
+ }
70
+ /** Image translation: raw bytes in, a JPEG (or, with render=false, JSON) out. */
71
+ export async function translateImage(o, image, contentType, query) {
72
+ const q = toQuery(query).toString();
73
+ const res = await send(o, `/v1/image-translate/translate?${q}`, { method: "POST", headers: { "content-type": contentType }, body: image });
74
+ const type = res.headers.get("content-type") ?? "";
75
+ if (!res.ok || type.includes("json")) {
76
+ const data = await unwrap(res);
77
+ return { contentType: "application/json", bytes: new TextEncoder().encode(JSON.stringify(data)) };
78
+ }
79
+ const regions = Number(res.headers.get("x-apinoa-regions-count"));
80
+ return { contentType: type || "image/jpeg", bytes: new Uint8Array(await res.arrayBuffer()), ...(Number.isFinite(regions) ? { regions } : {}) };
81
+ }
82
+ /** Download an image a tool was pointed at. */
83
+ export async function download(o, url, maxBytes = 20 * 1024 * 1024) {
84
+ if (!/^https?:\/\//i.test(url))
85
+ throw new ApiError(400, "INVALID_IMAGE_URL", "image_url must be an http(s) URL");
86
+ const res = await o.fetch(url, { signal: AbortSignal.timeout(30_000) });
87
+ if (!res.ok)
88
+ throw new ApiError(400, "IMAGE_DOWNLOAD_FAILED", `the image URL answered ${res.status}`);
89
+ const bytes = new Uint8Array(await res.arrayBuffer());
90
+ if (bytes.byteLength > maxBytes)
91
+ throw new ApiError(413, "IMAGE_TOO_LARGE", `the image is over ${maxBytes / 1024 / 1024} MB`);
92
+ return { bytes, contentType: (res.headers.get("content-type") ?? "image/jpeg").split(";")[0].trim() };
93
+ }
@@ -0,0 +1,2 @@
1
+ declare const snapshot: unknown;
2
+ export default snapshot;