apinoa-mcp 0.1.0 → 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/README.md +3 -2
- package/dist/server.d.ts +1 -1
- package/dist/server.js +57 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,8 +63,9 @@ Every tool only reads data.
|
|
|
63
63
|
| `APINOA_API_KEY` | — | Required for every data call. |
|
|
64
64
|
| `APINOA_BASE_URL` | `https://gateway.apinoa.com` | |
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
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.
|
|
68
69
|
|
|
69
70
|
## Use as a library
|
|
70
71
|
|
package/dist/server.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
8
|
import { type CatalogEntry } from "./api.js";
|
|
9
|
-
export declare const VERSION = "0.1.
|
|
9
|
+
export declare const VERSION = "0.1.1";
|
|
10
10
|
export interface ServerOptions {
|
|
11
11
|
/** Defaults to APINOA_API_KEY. Listing platforms works without one; every data call needs it. */
|
|
12
12
|
apiKey?: string;
|
package/dist/server.js
CHANGED
|
@@ -8,7 +8,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { ApiError, callOperation, download, fetchCatalog, translateImage } from "./api.js";
|
|
10
10
|
import SNAPSHOT from "./catalog.snapshot.js";
|
|
11
|
-
export const VERSION = "0.1.
|
|
11
|
+
export const VERSION = "0.1.1";
|
|
12
12
|
/** Operations whose answer is a file, not data: reachable through the API and the SDKs, not as tool text. */
|
|
13
13
|
const FILE_OPERATIONS = new Set(["tiktok/media"]);
|
|
14
14
|
const TOOLS = [
|
|
@@ -85,12 +85,63 @@ function describePlatform(e, operation) {
|
|
|
85
85
|
const price = cost ? (cost.base === cost.max ? ` [${cost.base} unit${cost.base === 1 ? "" : "s"}]` : ` [${cost.base}–${cost.max} units]`) : "";
|
|
86
86
|
return `- ${e.id}${price}: ${props.map((p) => (required.has(p) ? `${p}*` : p)).join(", ") || "(no parameters)"}`;
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
/**
|
|
89
|
+
* A social post's media lists every rendition of each file (sizes, bitrates): on Threads that is three
|
|
90
|
+
* quarters of a search answer. The model needs one, so each media keeps its main url, thumbnail and size,
|
|
91
|
+
* and its `variants` are left out. Only media's: a product's `variants` (sizes, colours) are data.
|
|
92
|
+
*/
|
|
93
|
+
function withoutRenditions(data) {
|
|
94
|
+
if (Array.isArray(data))
|
|
95
|
+
return data.map(withoutRenditions);
|
|
96
|
+
if (data === null || typeof data !== "object")
|
|
97
|
+
return data;
|
|
98
|
+
const out = {};
|
|
99
|
+
for (const [k, v] of Object.entries(data)) {
|
|
100
|
+
out[k] =
|
|
101
|
+
k === "media" && Array.isArray(v)
|
|
102
|
+
? v.map((m) => {
|
|
103
|
+
if (m === null || typeof m !== "object")
|
|
104
|
+
return m;
|
|
105
|
+
const { variants: _renditions, ...rest } = m;
|
|
106
|
+
return withoutRenditions(rest);
|
|
107
|
+
})
|
|
108
|
+
: withoutRenditions(v);
|
|
92
109
|
}
|
|
93
|
-
return
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
function result(raw, maxChars) {
|
|
113
|
+
const data = withoutRenditions(raw);
|
|
114
|
+
const text = JSON.stringify(data);
|
|
115
|
+
if (text.length <= maxChars)
|
|
116
|
+
return { content: [{ type: "text", text }] };
|
|
117
|
+
// Too large: keep whole items, so the answer stays valid JSON — as many as fit, then say what is missing.
|
|
118
|
+
const items = data?.items;
|
|
119
|
+
if (Array.isArray(items) && items.length > 1) {
|
|
120
|
+
const page = (n) => JSON.stringify({ ...data, items: items.slice(0, n) });
|
|
121
|
+
let lo = 1;
|
|
122
|
+
let hi = items.length - 1;
|
|
123
|
+
while (lo < hi) {
|
|
124
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
125
|
+
if (page(mid).length <= maxChars)
|
|
126
|
+
lo = mid;
|
|
127
|
+
else
|
|
128
|
+
hi = mid - 1;
|
|
129
|
+
}
|
|
130
|
+
if (page(lo).length <= maxChars) {
|
|
131
|
+
return {
|
|
132
|
+
content: [
|
|
133
|
+
{ type: "text", text: page(lo) },
|
|
134
|
+
{
|
|
135
|
+
type: "text",
|
|
136
|
+
text: `Showing ${lo} of the ${items.length} items on this page: the whole page is ${text.length} characters, over the ${maxChars} limit. For the other ${items.length - lo}, ask again with a smaller params.limit where the platform takes one, or a narrower query.`,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
content: [{ type: "text", text: `${text.slice(0, maxChars)}\n…[cut at ${maxChars} of ${text.length} characters; ask for fewer items (params.limit) or a narrower query]` }],
|
|
144
|
+
};
|
|
94
145
|
}
|
|
95
146
|
function failure(e) {
|
|
96
147
|
const text = e instanceof ApiError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apinoa-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP server for apinoa: marketplace, social and image-translation data as tools for Claude, Cursor and any MCP client.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://apinoa.com/docs",
|