@talonic/mcp 0.1.72 → 0.1.74
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/dist/http-server.js +172 -5
- package/dist/http-server.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +148 -3
- package/dist/index.js.map +1 -1
- package/dist/server.js +161 -4
- package/dist/server.js.map +1 -1
- package/package.json +11 -2
package/dist/http-server.js
CHANGED
|
@@ -1311,7 +1311,7 @@ var DESCRIPTION6 = [
|
|
|
1311
1311
|
"NOT FOR: full text (use talonic_to_markdown) \xB7 extracted fields (use talonic_extract).",
|
|
1312
1312
|
"BY NAME: if the user names a file, call talonic_search first to get its document_id, then call this.",
|
|
1313
1313
|
"ARGS: document_id.",
|
|
1314
|
-
"RETURNS: filename, pages, type_detected, language, and `status`. Status lifecycle: pending_upload -> queued -> extracting -> completed. Wait for `completed` before calling talonic_extract on a freshly uploaded doc. To read the document's text, call talonic_to_markdown with this id."
|
|
1314
|
+
"RETURNS: filename, pages, type_detected, language, and `status`. Status lifecycle: pending_upload -> uploading -> queued -> extracting -> completed. Wait for `completed` before calling talonic_extract on a freshly uploaded doc. Terminal failure statuses: ocr_failed, extraction_failed, error \u2014 stop polling and report the failure to the user if any of these appear. To read the document's text, call talonic_to_markdown with this id."
|
|
1315
1315
|
].join("\n");
|
|
1316
1316
|
var inputSchema6 = {
|
|
1317
1317
|
document_id: z.string().min(1).describe(
|
|
@@ -1645,7 +1645,7 @@ var DESCRIPTION10 = [
|
|
|
1645
1645
|
"USE WHEN: the user wants to upload a document and you cannot pass it directly \u2014 hosted/sandboxed clients (ChatGPT, Claude.ai) or files too large for tool-call arguments.",
|
|
1646
1646
|
"NOT FOR: a document already in the workspace (use its document_id) \xB7 a file already on a public URL (use file_url on talonic_extract).",
|
|
1647
1647
|
"ARGS: filename (with extension).",
|
|
1648
|
-
"RETURNS: upload_url, document_id, expires_at. After the user uploads, poll talonic_get_document on that document_id until status is 'completed', then call talonic_extract."
|
|
1648
|
+
"RETURNS: upload_url, document_id, expires_at. After the user uploads, poll talonic_get_document on that document_id until status is 'completed', then call talonic_extract. If status becomes ocr_failed, extraction_failed, or error, stop polling and report the failure to the user."
|
|
1649
1649
|
].join("\n");
|
|
1650
1650
|
var inputSchema9 = {
|
|
1651
1651
|
filename: z.string().min(1).describe(
|
|
@@ -1710,6 +1710,159 @@ function registerRequestUpload(server, getToken, baseUrl) {
|
|
|
1710
1710
|
async (args) => handleRequestUpload(getToken, baseUrl, args)
|
|
1711
1711
|
);
|
|
1712
1712
|
}
|
|
1713
|
+
var DEFAULT_BASE = "https://api.talonic.com";
|
|
1714
|
+
var RANGES = ["7d", "30d", "90d"];
|
|
1715
|
+
async function growthGet(getToken, baseUrl, path, params) {
|
|
1716
|
+
try {
|
|
1717
|
+
const qs = new URLSearchParams();
|
|
1718
|
+
for (const [k, v] of Object.entries(params)) if (v !== void 0 && v !== "") qs.set(k, v);
|
|
1719
|
+
const url = `${baseUrl ?? DEFAULT_BASE}/v1/growth/${path}${qs.size ? `?${qs}` : ""}`;
|
|
1720
|
+
const res = await fetch(url, {
|
|
1721
|
+
headers: { Authorization: `Bearer ${getToken()}`, Accept: "application/json" }
|
|
1722
|
+
});
|
|
1723
|
+
if (res.status === 403) {
|
|
1724
|
+
return toolError(
|
|
1725
|
+
new Error(
|
|
1726
|
+
"Talonic growth analytics require an active superadmin account. Sign in to the connector with your Talonic staff account (or use a superadmin-created API key)."
|
|
1727
|
+
)
|
|
1728
|
+
);
|
|
1729
|
+
}
|
|
1730
|
+
if (!res.ok) {
|
|
1731
|
+
const body = await res.text().catch(() => "");
|
|
1732
|
+
return toolError(
|
|
1733
|
+
new Error(`Talonic API error: HTTP ${res.status}${body ? ` \u2014 ${body}` : ""}`)
|
|
1734
|
+
);
|
|
1735
|
+
}
|
|
1736
|
+
return jsonOk(await res.json());
|
|
1737
|
+
} catch (err) {
|
|
1738
|
+
return toolError(err);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
async function probeGrowthAccess(token, baseUrl) {
|
|
1742
|
+
try {
|
|
1743
|
+
const res = await fetch(`${baseUrl ?? DEFAULT_BASE}/v1/growth/access`, {
|
|
1744
|
+
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
|
|
1745
|
+
signal: AbortSignal.timeout(5e3)
|
|
1746
|
+
});
|
|
1747
|
+
return res.ok;
|
|
1748
|
+
} catch {
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
var rangeArg = z.enum(RANGES).optional().describe("Trailing window (default 30d).");
|
|
1753
|
+
var FUNNEL_DESCRIPTION = [
|
|
1754
|
+
"Read Talonic's agentic product funnel: WAEW (weekly active extracting workspaces \u2014 the North Star),",
|
|
1755
|
+
"time-to-first-extraction p50/p90 + 24h activation rate, W2/W4 creation-cohort retention, and",
|
|
1756
|
+
"acquisition by surface (claude_ai, cursor, raw_api, ...).",
|
|
1757
|
+
"",
|
|
1758
|
+
"USE WHEN: asked about WAEW, activation, retention, or which surfaces drive extractions.",
|
|
1759
|
+
"INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
|
|
1760
|
+
"ARGS: range (optional: 7d | 30d | 90d, default 30d).",
|
|
1761
|
+
"RETURNS: { configured, rangeDays, waew, ttfe, retention[], bySurface[] } \u2014 configured:false means PostHog is unwired, not zero usage."
|
|
1762
|
+
].join("\n");
|
|
1763
|
+
var FUNNELS_DESCRIPTION = [
|
|
1764
|
+
"Read Talonic's website conversion funnels: Platform registration (Visit \u2192 Sign-up click \u2192 Account created \u2192 Activated)",
|
|
1765
|
+
"and Sales call booking (Visit \u2192 Book-demo click \u2192 Contact page \u2192 Demo booked).",
|
|
1766
|
+
"",
|
|
1767
|
+
"USE WHEN: asked about signups, activation counts, demo bookings, or website conversion.",
|
|
1768
|
+
"INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
|
|
1769
|
+
"ARGS: range (optional: 7d | 30d | 90d, default 30d).",
|
|
1770
|
+
"RETURNS: { rangeDays, funnels[] } \u2014 each stage carries { count, pending }; pending:true means that stage's source is not wired yet, not zero."
|
|
1771
|
+
].join("\n");
|
|
1772
|
+
var TRAFFIC_DESCRIPTION = [
|
|
1773
|
+
"Read talonic.com traffic: visitors, pageviews, top pages, and referrers split into AI assistants",
|
|
1774
|
+
"(ChatGPT, Claude, Perplexity, ...) vs other domains.",
|
|
1775
|
+
"",
|
|
1776
|
+
"USE WHEN: asked about website traffic, top pages, or how many visitors AI assistants refer.",
|
|
1777
|
+
"INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
|
|
1778
|
+
"ARGS: range (optional: 7d | 30d | 90d, default 30d).",
|
|
1779
|
+
"RETURNS: { configured, visitors, pageviews, topPages[], topReferrers[], aiReferrers[] }."
|
|
1780
|
+
].join("\n");
|
|
1781
|
+
var TOOLS_USAGE_DESCRIPTION = [
|
|
1782
|
+
"Read anonymous visitor behavior on the free tools at talonic.com/tools: views, attempt/success/bounce",
|
|
1783
|
+
"rates, dwell, CTA clicks, per-tool leaderboard, and country/device/acquisition splits.",
|
|
1784
|
+
"",
|
|
1785
|
+
"USE WHEN: asked how the free tools perform, which tools convert, or where tool visitors come from.",
|
|
1786
|
+
"INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
|
|
1787
|
+
"ARGS: all optional \u2014 range (today | 7d | 30d | 90d | all, default 30d), tool (slug), category, country (ISO code), device (desktop | mobile | tablet), source (utm/referrer key), funnel_stage (attempted | succeeded | downloaded | cta).",
|
|
1788
|
+
"RETURNS: the Tools Usage dashboard payload: totals, rates, tools[] leaderboard, breakdowns, trend. Rates are ratios of independent counts, not per-visitor funnels."
|
|
1789
|
+
].join("\n");
|
|
1790
|
+
var toolsUsageInput = {
|
|
1791
|
+
range: z.enum(["today", "7d", "30d", "90d", "all"]).optional().describe("Window (default 30d)."),
|
|
1792
|
+
tool: z.string().optional().describe("Restrict to one tool slug (e.g. 'pdf-to-csv')."),
|
|
1793
|
+
category: z.string().optional().describe("Restrict to a tool category."),
|
|
1794
|
+
country: z.string().optional().describe("Restrict to a visitor country (ISO code, e.g. 'DE')."),
|
|
1795
|
+
device: z.string().optional().describe("Restrict to a device type: desktop, mobile, or tablet."),
|
|
1796
|
+
source: z.string().optional().describe("Restrict to an acquisition source (UTM value or referrer host)."),
|
|
1797
|
+
funnel_stage: z.enum(["attempted", "succeeded", "downloaded", "cta"]).optional().describe("Keep only tools with at least one event at this funnel stage.")
|
|
1798
|
+
};
|
|
1799
|
+
async function handleGrowthFunnel(getToken, baseUrl, args) {
|
|
1800
|
+
return growthGet(getToken, baseUrl, "funnel", { range: args.range });
|
|
1801
|
+
}
|
|
1802
|
+
async function handleGrowthFunnels(getToken, baseUrl, args) {
|
|
1803
|
+
return growthGet(getToken, baseUrl, "funnels", { range: args.range });
|
|
1804
|
+
}
|
|
1805
|
+
async function handleGrowthTraffic(getToken, baseUrl, args) {
|
|
1806
|
+
return growthGet(getToken, baseUrl, "traffic", { range: args.range });
|
|
1807
|
+
}
|
|
1808
|
+
async function handleGrowthToolsUsage(getToken, baseUrl, args) {
|
|
1809
|
+
return growthGet(getToken, baseUrl, "tools-usage", {
|
|
1810
|
+
range: args.range,
|
|
1811
|
+
tool: args.tool,
|
|
1812
|
+
category: args.category,
|
|
1813
|
+
country: args.country,
|
|
1814
|
+
device: args.device,
|
|
1815
|
+
source: args.source,
|
|
1816
|
+
funnelStage: args.funnel_stage
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
var READ_ONLY = {
|
|
1820
|
+
readOnlyHint: true,
|
|
1821
|
+
destructiveHint: false,
|
|
1822
|
+
openWorldHint: false
|
|
1823
|
+
};
|
|
1824
|
+
function registerGrowthTools(server, getToken, baseUrl) {
|
|
1825
|
+
server.registerTool(
|
|
1826
|
+
"talonic_growth_funnel",
|
|
1827
|
+
{
|
|
1828
|
+
title: "Growth: Product Funnel",
|
|
1829
|
+
description: FUNNEL_DESCRIPTION,
|
|
1830
|
+
inputSchema: { range: rangeArg },
|
|
1831
|
+
annotations: { title: "Growth: Product Funnel", ...READ_ONLY }
|
|
1832
|
+
},
|
|
1833
|
+
async (args) => handleGrowthFunnel(getToken, baseUrl, args)
|
|
1834
|
+
);
|
|
1835
|
+
server.registerTool(
|
|
1836
|
+
"talonic_growth_funnels",
|
|
1837
|
+
{
|
|
1838
|
+
title: "Growth: Conversion Funnels",
|
|
1839
|
+
description: FUNNELS_DESCRIPTION,
|
|
1840
|
+
inputSchema: { range: rangeArg },
|
|
1841
|
+
annotations: { title: "Growth: Conversion Funnels", ...READ_ONLY }
|
|
1842
|
+
},
|
|
1843
|
+
async (args) => handleGrowthFunnels(getToken, baseUrl, args)
|
|
1844
|
+
);
|
|
1845
|
+
server.registerTool(
|
|
1846
|
+
"talonic_growth_traffic",
|
|
1847
|
+
{
|
|
1848
|
+
title: "Growth: Website Traffic",
|
|
1849
|
+
description: TRAFFIC_DESCRIPTION,
|
|
1850
|
+
inputSchema: { range: rangeArg },
|
|
1851
|
+
annotations: { title: "Growth: Website Traffic", ...READ_ONLY }
|
|
1852
|
+
},
|
|
1853
|
+
async (args) => handleGrowthTraffic(getToken, baseUrl, args)
|
|
1854
|
+
);
|
|
1855
|
+
server.registerTool(
|
|
1856
|
+
"talonic_growth_tools_usage",
|
|
1857
|
+
{
|
|
1858
|
+
title: "Growth: Free-Tools Usage",
|
|
1859
|
+
description: TOOLS_USAGE_DESCRIPTION,
|
|
1860
|
+
inputSchema: toolsUsageInput,
|
|
1861
|
+
annotations: { title: "Growth: Free-Tools Usage", ...READ_ONLY }
|
|
1862
|
+
},
|
|
1863
|
+
async (args) => handleGrowthToolsUsage(getToken, baseUrl, args)
|
|
1864
|
+
);
|
|
1865
|
+
}
|
|
1713
1866
|
var DESCRIPTION11 = [
|
|
1714
1867
|
"Get the OCR-converted markdown text of a document.",
|
|
1715
1868
|
"",
|
|
@@ -1817,7 +1970,7 @@ function registerToMarkdown(server, getTalonic) {
|
|
|
1817
1970
|
|
|
1818
1971
|
// package.json
|
|
1819
1972
|
var package_default = {
|
|
1820
|
-
version: "0.1.
|
|
1973
|
+
version: "0.1.74"};
|
|
1821
1974
|
|
|
1822
1975
|
// src/version.ts
|
|
1823
1976
|
var VERSION = package_default.version;
|
|
@@ -1932,6 +2085,9 @@ function createServer(options) {
|
|
|
1932
2085
|
registerGetPricing(server, getTalonic);
|
|
1933
2086
|
registerGetUsage(server, getTalonic);
|
|
1934
2087
|
registerRequestUpload(server, getToken, baseUrl);
|
|
2088
|
+
if (options.includeGrowthTools) {
|
|
2089
|
+
registerGrowthTools(server, getToken, baseUrl);
|
|
2090
|
+
}
|
|
1935
2091
|
registerSchemasResource(server, getTalonic);
|
|
1936
2092
|
registerWebhooksResource(server, getToken, baseUrl);
|
|
1937
2093
|
registerWidgets(server);
|
|
@@ -1965,6 +2121,16 @@ var FAVICON_BYTES = Buffer.from(FAVICON_BASE64, "base64");
|
|
|
1965
2121
|
|
|
1966
2122
|
// src/http-server.ts
|
|
1967
2123
|
var PORT = Number(process.env["PORT"] ?? 3e3);
|
|
2124
|
+
var GROWTH_PROBE_TTL_MS = 5 * 60 * 1e3;
|
|
2125
|
+
var growthProbeCache = /* @__PURE__ */ new Map();
|
|
2126
|
+
async function growthAccessCached(token, probe = probeGrowthAccess, now = Date.now) {
|
|
2127
|
+
const hit = growthProbeCache.get(token);
|
|
2128
|
+
if (hit && hit.expiresAt > now()) return hit.ok;
|
|
2129
|
+
const ok = await probe(token);
|
|
2130
|
+
if (growthProbeCache.size >= 1e3) growthProbeCache.clear();
|
|
2131
|
+
growthProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
|
|
2132
|
+
return ok;
|
|
2133
|
+
}
|
|
1968
2134
|
var RESOURCE_URL = process.env["MCP_RESOURCE_URL"] ?? "https://mcp.talonic.com";
|
|
1969
2135
|
var AUTHORIZATION_SERVER = process.env["OAUTH_AUTHORIZATION_SERVER"] ?? "https://api.talonic.com";
|
|
1970
2136
|
var APPS_CHALLENGE_TOKEN = process.env["OPENAI_APPS_CHALLENGE_TOKEN"] ?? "gnHvfQsKH6NVBNIeOWVK1vSt5QR2gsgBAIcXdSlpR_U";
|
|
@@ -2171,7 +2337,8 @@ function createRequestHandler() {
|
|
|
2171
2337
|
return;
|
|
2172
2338
|
}
|
|
2173
2339
|
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
|
|
2174
|
-
const
|
|
2340
|
+
const includeGrowthTools = await growthAccessCached(token);
|
|
2341
|
+
const mcpServer = createServer({ tokenProvider: () => token, includeGrowthTools });
|
|
2175
2342
|
res.on("close", () => {
|
|
2176
2343
|
void transport.close();
|
|
2177
2344
|
void mcpServer.close();
|
|
@@ -2198,6 +2365,6 @@ if (isDirectInvocation()) {
|
|
|
2198
2365
|
});
|
|
2199
2366
|
}
|
|
2200
2367
|
|
|
2201
|
-
export { createRequestHandler };
|
|
2368
|
+
export { createRequestHandler, growthAccessCached };
|
|
2202
2369
|
//# sourceMappingURL=http-server.js.map
|
|
2203
2370
|
//# sourceMappingURL=http-server.js.map
|