@tenpo/mcp 0.6.2 → 0.7.0

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -586,11 +586,41 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
586
586
  const a = args;
587
587
  if (!a.query)
588
588
  throw new Error("query required");
589
- const result = await tenpoFetch("/api/v1/think", {
589
+ // First call /think with keyword classification (fast, ~100ms)
590
+ const firstResult = await tenpoFetch("/api/v1/think", {
590
591
  method: "POST",
591
592
  body: { query: a.query },
592
593
  });
593
- return formatToolResult(result);
594
+ // If classifier confidence is low AND host supports sampling,
595
+ // ask host LLM to re-classify and re-call /think with the hint.
596
+ // This is the MCP-sampling integration ("A"): host LLM does the
597
+ // ambiguous-case classification, Tenpo orchestrates the rest.
598
+ const pack = firstResult.pack;
599
+ const conf = pack?.classified?.confidence ?? 1;
600
+ if (conf < 0.7 && CLIENT_SUPPORTS_SAMPLING !== false) {
601
+ try {
602
+ const taxonomy = [
603
+ "Pick ONE domain that best matches the query:",
604
+ "store_health, inventory, marketing_ads, marketing_email, customer, supplier, finance, payouts_tax,",
605
+ "fraud_risk, fulfillment, returns_refund, support, seo_content, social_content, competitor,",
606
+ "discounts_promo, pricing, operations, integration, investigation, execution, data_query, onboarding, general",
607
+ ].join("\n");
608
+ const samplingResult = await tryClassifyIntentViaSampling(a.query, taxonomy);
609
+ if (samplingResult) {
610
+ const m = samplingResult.match(/"intent"\s*:\s*"([^"]+)"/);
611
+ const sampledDomain = m?.[1];
612
+ if (sampledDomain) {
613
+ const refined = await tenpoFetch("/api/v1/think", {
614
+ method: "POST",
615
+ body: { query: a.query, domain_hint: sampledDomain, classified_via: "host_llm_sampling" },
616
+ });
617
+ return formatToolResult(refined);
618
+ }
619
+ }
620
+ }
621
+ catch { /* sampling unavailable — return first result */ }
622
+ }
623
+ return formatToolResult(firstResult);
594
624
  }
595
625
  case "tenpo_route": {
596
626
  const result = await tenpoFetch("/api/v1/route", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenpo/mcp",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Tenpo — the operator that runs alongside your store. Connects to 45+ commerce platforms (Shopify, Klaviyo, Meta Ads, GA4, Stripe…) and gives any AI host (Claude Desktop, Cursor, Claude Code, ChatGPT) deterministic answers about your sales, ads, email, inventory, suppliers, customers, finance, and competitors. Free tier, no card required.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://tenpo.ai",