apinoa-mcp 0.2.9 → 0.2.10

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 CHANGED
@@ -72,6 +72,7 @@ Requires Node.js 20 or later. The package installs [Deno](https://deno.com), whi
72
72
  | `search_docs` | Finds the operations for a task: how to call each, every parameter, the cost, and the fields it returns. Free |
73
73
  | `execute` | Runs TypeScript the model writes against the API, and returns only what the code returns or prints |
74
74
  | `translate_image` | Replaces the text in an image with a translation; returns the image |
75
+ | `read_image_text` | Reads the text in an image (OCR): every region with its text, confidence and position |
75
76
 
76
77
  Instead of one tool call per API call, the model writes a short program. Fanning out over 50 accounts,
77
78
  following pages, filtering and averaging happen in the code, and only the answer comes back into the
package/dist/api.d.ts CHANGED
@@ -45,6 +45,8 @@ export declare function translateImage(o: ApiOptions, image: Uint8Array, content
45
45
  bytes: Uint8Array;
46
46
  regions?: number;
47
47
  }>;
48
+ /** OCR: raw bytes in, every text region as JSON out. */
49
+ export declare function readImageText(o: ApiOptions, image: Uint8Array, contentType: string, language?: string): Promise<unknown>;
48
50
  /** Download an image a tool was pointed at. */
49
51
  export declare function download(o: ApiOptions, url: string, maxBytes?: number): Promise<{
50
52
  bytes: Uint8Array;
package/dist/api.js CHANGED
@@ -79,6 +79,11 @@ export async function translateImage(o, image, contentType, query) {
79
79
  const regions = Number(res.headers.get("x-apinoa-regions-count"));
80
80
  return { contentType: type || "image/jpeg", bytes: new Uint8Array(await res.arrayBuffer()), ...(Number.isFinite(regions) ? { regions } : {}) };
81
81
  }
82
+ /** OCR: raw bytes in, every text region as JSON out. */
83
+ export async function readImageText(o, image, contentType, language) {
84
+ const q = toQuery({ language }).toString();
85
+ return unwrap(await send(o, `/v1/ocr${q ? `?${q}` : ""}`, { method: "POST", headers: { "content-type": contentType }, body: image }));
86
+ }
82
87
  /** Download an image a tool was pointed at. */
83
88
  export async function download(o, url, maxBytes = 20 * 1024 * 1024) {
84
89
  if (!/^https?:\/\//i.test(url))
package/dist/legacy.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
6
  import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
7
7
  import { type ApiOptions, type CatalogEntry } from "./api.js";
8
+ export declare function result(raw: unknown, maxChars: number): CallToolResult;
8
9
  export declare function failure(e: unknown): CallToolResult;
9
10
  /** Registers the 0.1 tools on `server`. */
10
11
  export declare function registerLegacyTools(server: McpServer, api: ApiOptions, catalog: CatalogEntry[], maxChars: number): void;
package/dist/legacy.js CHANGED
@@ -100,7 +100,7 @@ function withoutRenditions(data) {
100
100
  }
101
101
  return out;
102
102
  }
103
- function result(raw, maxChars) {
103
+ export function result(raw, maxChars) {
104
104
  const data = withoutRenditions(raw);
105
105
  const text = JSON.stringify(data);
106
106
  if (text.length <= maxChars)
package/dist/server.js CHANGED
@@ -13,11 +13,11 @@
13
13
  import { createRequire } from "node:module";
14
14
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
15
15
  import { z } from "zod";
16
- import { fetchCatalog, translateImage, download } from "./api.js";
16
+ import { fetchCatalog, translateImage, readImageText, download } from "./api.js";
17
17
  import SNAPSHOT from "./catalog.snapshot.js";
18
18
  import { declarations, operations, overview, sandboxOperations, searchDocs } from "./code/docs.js";
19
19
  import { Sandbox, denoRuns, findDeno } from "./code/sandbox.js";
20
- import { failure, registerLegacyTools } from "./legacy.js";
20
+ import { failure, registerLegacyTools, result } from "./legacy.js";
21
21
  // The published package's own version (dist/ and src/ both sit one level below package.json), so a release
22
22
  // cannot announce the previous one.
23
23
  export const VERSION = createRequire(import.meta.url)("../package.json").version;
@@ -53,7 +53,7 @@ export async function createApinoaServer(options = {}) {
53
53
  ? " Find the operations and fields with search_docs, then call them from TypeScript in execute: fan out, page, filter and aggregate in the code, and return only the result."
54
54
  : " Products: search_products, get_product, get_product_reviews, list_categories, browse_category. Social: get_social_profile, list_social_posts, get_social_post, get_social_comments. " +
55
55
  "Search results and AI answers: call_apinoa with a platform (google, bing, naver, chatgpt, gemini…) and its operation (search, answer…); list_platforms lists every operation and its parameters. " +
56
- "translate_image translates the text in a product photo."),
56
+ "translate_image translates the text in a product photo; read_image_text reads it (OCR)."),
57
57
  });
58
58
  const readOnly = { readOnlyHint: true, openWorldHint: true };
59
59
  if (mode === "tools")
@@ -92,6 +92,29 @@ export async function createApinoaServer(options = {}) {
92
92
  return failure(e);
93
93
  }
94
94
  });
95
+ server.registerTool("read_image_text", {
96
+ title: "Read the text in an image (OCR)",
97
+ description: "OCR: read the text in an image. Give the image as a URL. Returns every text region with its text, confidence, " +
98
+ "bounding box and polygon. Reads Chinese (Simplified and Traditional), Japanese, English and other Latin-script " +
99
+ "text. One credit per image; an image whose long side is 2.5 times its short side or more is read in sections, one credit each.",
100
+ inputSchema: {
101
+ image_url: z.string().url().describe("An http(s) URL of a JPEG, PNG or WebP image."),
102
+ language: z
103
+ .enum(["auto", "zh-CN", "zh-TW", "ja", "en"])
104
+ .optional()
105
+ .describe("auto (default) returns all the text; another value returns only the text in that language."),
106
+ },
107
+ annotations: { title: "Read the text in an image", ...readOnly },
108
+ _meta: { "anthropic/maxResultSizeChars": maxChars + 2000 },
109
+ }, async (args) => {
110
+ try {
111
+ const img = await download(api, args.image_url);
112
+ return result(await readImageText(api, img.bytes, img.contentType, args.language), maxChars);
113
+ }
114
+ catch (e) {
115
+ return failure(e);
116
+ }
117
+ });
95
118
  return server;
96
119
  }
97
120
  /** Display names for the sources the server introduces itself with; an id without one is shown as it is. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apinoa-mcp",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "mcpName": "io.github.apinoahq/apinoa-mcp",
5
5
  "description": "MCP server for apinoa: marketplace products, social posts, search results and AI answers (Amazon, TikTok, Google, ChatGPT and more) for Claude Code, Codex, Cursor and any MCP client. Code mode: the model writes TypeScript against a typed client, run in a sandbox.",
6
6
  "license": "MIT",