@talonic/mcp 0.1.73 → 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/server.js CHANGED
@@ -1293,7 +1293,7 @@ var DESCRIPTION6 = [
1293
1293
  "NOT FOR: full text (use talonic_to_markdown) \xB7 extracted fields (use talonic_extract).",
1294
1294
  "BY NAME: if the user names a file, call talonic_search first to get its document_id, then call this.",
1295
1295
  "ARGS: document_id.",
1296
- "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."
1296
+ "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."
1297
1297
  ].join("\n");
1298
1298
  var inputSchema6 = {
1299
1299
  document_id: z.string().min(1).describe(
@@ -1627,7 +1627,7 @@ var DESCRIPTION10 = [
1627
1627
  "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.",
1628
1628
  "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).",
1629
1629
  "ARGS: filename (with extension).",
1630
- "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."
1630
+ "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."
1631
1631
  ].join("\n");
1632
1632
  var inputSchema9 = {
1633
1633
  filename: z.string().min(1).describe(
@@ -1692,6 +1692,159 @@ function registerRequestUpload(server, getToken, baseUrl) {
1692
1692
  async (args) => handleRequestUpload(getToken, baseUrl, args)
1693
1693
  );
1694
1694
  }
1695
+ var DEFAULT_BASE = "https://api.talonic.com";
1696
+ var RANGES = ["7d", "30d", "90d"];
1697
+ async function growthGet(getToken, baseUrl, path, params) {
1698
+ try {
1699
+ const qs = new URLSearchParams();
1700
+ for (const [k, v] of Object.entries(params)) if (v !== void 0 && v !== "") qs.set(k, v);
1701
+ const url = `${baseUrl ?? DEFAULT_BASE}/v1/growth/${path}${qs.size ? `?${qs}` : ""}`;
1702
+ const res = await fetch(url, {
1703
+ headers: { Authorization: `Bearer ${getToken()}`, Accept: "application/json" }
1704
+ });
1705
+ if (res.status === 403) {
1706
+ return toolError(
1707
+ new Error(
1708
+ "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)."
1709
+ )
1710
+ );
1711
+ }
1712
+ if (!res.ok) {
1713
+ const body = await res.text().catch(() => "");
1714
+ return toolError(
1715
+ new Error(`Talonic API error: HTTP ${res.status}${body ? ` \u2014 ${body}` : ""}`)
1716
+ );
1717
+ }
1718
+ return jsonOk(await res.json());
1719
+ } catch (err) {
1720
+ return toolError(err);
1721
+ }
1722
+ }
1723
+ async function probeGrowthAccess(token, baseUrl) {
1724
+ try {
1725
+ const res = await fetch(`${baseUrl ?? DEFAULT_BASE}/v1/growth/access`, {
1726
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
1727
+ signal: AbortSignal.timeout(5e3)
1728
+ });
1729
+ return res.ok;
1730
+ } catch {
1731
+ return false;
1732
+ }
1733
+ }
1734
+ var rangeArg = z.enum(RANGES).optional().describe("Trailing window (default 30d).");
1735
+ var FUNNEL_DESCRIPTION = [
1736
+ "Read Talonic's agentic product funnel: WAEW (weekly active extracting workspaces \u2014 the North Star),",
1737
+ "time-to-first-extraction p50/p90 + 24h activation rate, W2/W4 creation-cohort retention, and",
1738
+ "acquisition by surface (claude_ai, cursor, raw_api, ...).",
1739
+ "",
1740
+ "USE WHEN: asked about WAEW, activation, retention, or which surfaces drive extractions.",
1741
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1742
+ "ARGS: range (optional: 7d | 30d | 90d, default 30d).",
1743
+ "RETURNS: { configured, rangeDays, waew, ttfe, retention[], bySurface[] } \u2014 configured:false means PostHog is unwired, not zero usage."
1744
+ ].join("\n");
1745
+ var FUNNELS_DESCRIPTION = [
1746
+ "Read Talonic's website conversion funnels: Platform registration (Visit \u2192 Sign-up click \u2192 Account created \u2192 Activated)",
1747
+ "and Sales call booking (Visit \u2192 Book-demo click \u2192 Contact page \u2192 Demo booked).",
1748
+ "",
1749
+ "USE WHEN: asked about signups, activation counts, demo bookings, or website conversion.",
1750
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1751
+ "ARGS: range (optional: 7d | 30d | 90d, default 30d).",
1752
+ "RETURNS: { rangeDays, funnels[] } \u2014 each stage carries { count, pending }; pending:true means that stage's source is not wired yet, not zero."
1753
+ ].join("\n");
1754
+ var TRAFFIC_DESCRIPTION = [
1755
+ "Read talonic.com traffic: visitors, pageviews, top pages, and referrers split into AI assistants",
1756
+ "(ChatGPT, Claude, Perplexity, ...) vs other domains.",
1757
+ "",
1758
+ "USE WHEN: asked about website traffic, top pages, or how many visitors AI assistants refer.",
1759
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1760
+ "ARGS: range (optional: 7d | 30d | 90d, default 30d).",
1761
+ "RETURNS: { configured, visitors, pageviews, topPages[], topReferrers[], aiReferrers[] }."
1762
+ ].join("\n");
1763
+ var TOOLS_USAGE_DESCRIPTION = [
1764
+ "Read anonymous visitor behavior on the free tools at talonic.com/tools: views, attempt/success/bounce",
1765
+ "rates, dwell, CTA clicks, per-tool leaderboard, and country/device/acquisition splits.",
1766
+ "",
1767
+ "USE WHEN: asked how the free tools perform, which tools convert, or where tool visitors come from.",
1768
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1769
+ "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).",
1770
+ "RETURNS: the Tools Usage dashboard payload: totals, rates, tools[] leaderboard, breakdowns, trend. Rates are ratios of independent counts, not per-visitor funnels."
1771
+ ].join("\n");
1772
+ var toolsUsageInput = {
1773
+ range: z.enum(["today", "7d", "30d", "90d", "all"]).optional().describe("Window (default 30d)."),
1774
+ tool: z.string().optional().describe("Restrict to one tool slug (e.g. 'pdf-to-csv')."),
1775
+ category: z.string().optional().describe("Restrict to a tool category."),
1776
+ country: z.string().optional().describe("Restrict to a visitor country (ISO code, e.g. 'DE')."),
1777
+ device: z.string().optional().describe("Restrict to a device type: desktop, mobile, or tablet."),
1778
+ source: z.string().optional().describe("Restrict to an acquisition source (UTM value or referrer host)."),
1779
+ funnel_stage: z.enum(["attempted", "succeeded", "downloaded", "cta"]).optional().describe("Keep only tools with at least one event at this funnel stage.")
1780
+ };
1781
+ async function handleGrowthFunnel(getToken, baseUrl, args) {
1782
+ return growthGet(getToken, baseUrl, "funnel", { range: args.range });
1783
+ }
1784
+ async function handleGrowthFunnels(getToken, baseUrl, args) {
1785
+ return growthGet(getToken, baseUrl, "funnels", { range: args.range });
1786
+ }
1787
+ async function handleGrowthTraffic(getToken, baseUrl, args) {
1788
+ return growthGet(getToken, baseUrl, "traffic", { range: args.range });
1789
+ }
1790
+ async function handleGrowthToolsUsage(getToken, baseUrl, args) {
1791
+ return growthGet(getToken, baseUrl, "tools-usage", {
1792
+ range: args.range,
1793
+ tool: args.tool,
1794
+ category: args.category,
1795
+ country: args.country,
1796
+ device: args.device,
1797
+ source: args.source,
1798
+ funnelStage: args.funnel_stage
1799
+ });
1800
+ }
1801
+ var READ_ONLY = {
1802
+ readOnlyHint: true,
1803
+ destructiveHint: false,
1804
+ openWorldHint: false
1805
+ };
1806
+ function registerGrowthTools(server, getToken, baseUrl) {
1807
+ server.registerTool(
1808
+ "talonic_growth_funnel",
1809
+ {
1810
+ title: "Growth: Product Funnel",
1811
+ description: FUNNEL_DESCRIPTION,
1812
+ inputSchema: { range: rangeArg },
1813
+ annotations: { title: "Growth: Product Funnel", ...READ_ONLY }
1814
+ },
1815
+ async (args) => handleGrowthFunnel(getToken, baseUrl, args)
1816
+ );
1817
+ server.registerTool(
1818
+ "talonic_growth_funnels",
1819
+ {
1820
+ title: "Growth: Conversion Funnels",
1821
+ description: FUNNELS_DESCRIPTION,
1822
+ inputSchema: { range: rangeArg },
1823
+ annotations: { title: "Growth: Conversion Funnels", ...READ_ONLY }
1824
+ },
1825
+ async (args) => handleGrowthFunnels(getToken, baseUrl, args)
1826
+ );
1827
+ server.registerTool(
1828
+ "talonic_growth_traffic",
1829
+ {
1830
+ title: "Growth: Website Traffic",
1831
+ description: TRAFFIC_DESCRIPTION,
1832
+ inputSchema: { range: rangeArg },
1833
+ annotations: { title: "Growth: Website Traffic", ...READ_ONLY }
1834
+ },
1835
+ async (args) => handleGrowthTraffic(getToken, baseUrl, args)
1836
+ );
1837
+ server.registerTool(
1838
+ "talonic_growth_tools_usage",
1839
+ {
1840
+ title: "Growth: Free-Tools Usage",
1841
+ description: TOOLS_USAGE_DESCRIPTION,
1842
+ inputSchema: toolsUsageInput,
1843
+ annotations: { title: "Growth: Free-Tools Usage", ...READ_ONLY }
1844
+ },
1845
+ async (args) => handleGrowthToolsUsage(getToken, baseUrl, args)
1846
+ );
1847
+ }
1695
1848
  var DESCRIPTION11 = [
1696
1849
  "Get the OCR-converted markdown text of a document.",
1697
1850
  "",
@@ -1799,7 +1952,7 @@ function registerToMarkdown(server, getTalonic) {
1799
1952
 
1800
1953
  // package.json
1801
1954
  var package_default = {
1802
- version: "0.1.73"};
1955
+ version: "0.1.74"};
1803
1956
 
1804
1957
  // src/version.ts
1805
1958
  var VERSION = package_default.version;
@@ -1914,6 +2067,9 @@ function createServer(options) {
1914
2067
  registerGetPricing(server, getTalonic);
1915
2068
  registerGetUsage(server, getTalonic);
1916
2069
  registerRequestUpload(server, getToken, baseUrl);
2070
+ if (options.includeGrowthTools) {
2071
+ registerGrowthTools(server, getToken, baseUrl);
2072
+ }
1917
2073
  registerSchemasResource(server, getTalonic);
1918
2074
  registerWebhooksResource(server, getToken, baseUrl);
1919
2075
  registerWidgets(server);
@@ -1966,7 +2122,8 @@ async function main(argv = process.argv.slice(2), env = process.env, out = (line
1966
2122
  return 1;
1967
2123
  }
1968
2124
  const baseUrl = env["TALONIC_BASE_URL"];
1969
- const server = createServer({ apiKey, ...baseUrl ? { baseUrl } : {} });
2125
+ const includeGrowthTools = await probeGrowthAccess(apiKey, baseUrl);
2126
+ const server = createServer({ apiKey, ...baseUrl ? { baseUrl } : {}, includeGrowthTools });
1970
2127
  const transport = new StdioServerTransport();
1971
2128
  await server.connect(transport);
1972
2129
  return 0;