@adport/mcp 0.9.0 → 0.11.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.
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  assembleRuntime,
4
4
  runStdioServer
5
- } from "./chunk-DPHTHY2E.js";
5
+ } from "./chunk-HPKW6X2B.js";
6
6
 
7
7
  // src/bin.ts
8
8
  var includeRawTools = process.argv.includes("--raw-api-tools");
@@ -3,7 +3,7 @@ import { McpServer } from "@modelcontextprotocol/server";
3
3
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
4
4
  import { z } from "zod";
5
5
  import { registerAppResource, registerAppTool, RESOURCE_MIME_TYPE } from "@modelcontextprotocol/ext-apps/server";
6
- import { AdportError, CredentialStore, createContext, selectRuntimeCatalog, nextPageArguments } from "@adport/core";
6
+ import { AdportError, CredentialStore, createContext, selectRuntimeCatalog, nextPageArguments, writeOutput } from "@adport/core";
7
7
  import { createGa4Module, createGscModule } from "@adport/provider-analytics";
8
8
  import { createGtmModule } from "@adport/provider-gtm";
9
9
  import { createGoogleModule } from "@adport/provider-google";
@@ -17,11 +17,12 @@ import { createSpotifyModule } from "@adport/provider-spotify";
17
17
  import { createPinterestModule } from "@adport/provider-pinterest";
18
18
  import { createLinkedInModule } from "@adport/provider-linkedin";
19
19
  import { createXModule } from "@adport/provider-x";
20
+ import { createOpenAIModule } from "@adport/provider-openai";
20
21
 
21
22
  // package.json
22
23
  var package_default = {
23
24
  name: "@adport/mcp",
24
- version: "0.9.0",
25
+ version: "0.11.0",
25
26
  description: "adport MCP server \u2014 the open control plane for paid media",
26
27
  license: "Apache-2.0",
27
28
  type: "module",
@@ -58,16 +59,17 @@ var package_default = {
58
59
  "@adport/provider-snapchat": "workspace:*",
59
60
  "@adport/provider-spotify": "workspace:*",
60
61
  "@adport/provider-tiktok": "workspace:*",
62
+ "@adport/provider-openai": "workspace:*",
61
63
  "@adport/provider-x": "workspace:*",
62
64
  "@modelcontextprotocol/ext-apps": "^2.0.4",
63
- zod: "^4.4.3",
65
+ zod: "^4.6.7",
64
66
  "@modelcontextprotocol/server": "^2.4.0",
65
67
  "@adport/provider-gtm": "workspace:*",
66
68
  "@adport/provider-analytics": "workspace:*"
67
69
  },
68
70
  devDependencies: {
69
71
  "@types/jsdom": "^21.1.7",
70
- "@types/node": "^26.1.2",
72
+ "@types/node": "^26.6.6",
71
73
  jsdom: "26.1.0",
72
74
  tsup: "^8.3.0",
73
75
  typescript: "^5.8.0",
@@ -220,6 +222,8 @@ var MEDIA_LIBRARY_UI = String.raw`
220
222
  const response=await callTool('media_list',args,60000),value=resultData(response);
221
223
  if(response?.isError || value.error || !Array.isArray(value.creatives) || value._adport?.tool!=='media_list' || mediaLibraryProject(value,value._adport)!==library.project) throw new Error('The next page could not be confirmed. Try Load more again.');
222
224
  if(mediaLibrary!==library) return;
225
+ // A host can deliver a nested page again after the bridge has resolved.
226
+ rememberHostResult(JSON.stringify(value));
223
227
  library.seen.add(args.cursor);
224
228
  const byId=new Map(arr(library.data.creatives).map(item=>[item.id,item]));
225
229
  for(const item of value.creatives) byId.set(item.id,item);
@@ -910,7 +914,8 @@ var PROVIDER_LOGOS = {
910
914
  "x": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" role="img" viewBox="0 0 24 24" color="#fff" style="color:#fff" height="1em" width="1em"><path d="M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z"></path></svg>',
911
915
  "pinterest": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" role="img" viewBox="0 0 24 24" color="#fff" style="color:#fff" height="1em" width="1em"><path d="M12.017 0C5.396 0 .029 5.367.029 11.987c0 5.079 3.158 9.417 7.618 11.162-.105-.949-.199-2.403.041-3.439.219-.937 1.406-5.957 1.406-5.957s-.359-.72-.359-1.781c0-1.663.967-2.911 2.168-2.911 1.024 0 1.518.769 1.518 1.688 0 1.029-.653 2.567-.992 3.992-.285 1.193.6 2.165 1.775 2.165 2.128 0 3.768-2.245 3.768-5.487 0-2.861-2.063-4.869-5.008-4.869-3.41 0-5.409 2.562-5.409 5.199 0 1.033.394 2.143.889 2.741.099.12.112.225.085.345-.09.375-.293 1.199-.334 1.363-.053.225-.172.271-.401.165-1.495-.69-2.433-2.878-2.433-4.646 0-3.776 2.748-7.252 7.92-7.252 4.158 0 7.392 2.967 7.392 6.923 0 4.135-2.607 7.462-6.233 7.462-1.214 0-2.354-.629-2.758-1.379l-.749 2.848c-.269 1.045-1.004 2.352-1.498 3.146 1.123.345 2.306.535 3.55.535 6.607 0 11.985-5.365 11.985-11.987C23.97 5.39 18.592.026 11.985.026L12.017 0z"></path></svg>',
912
916
  "spotify": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" role="img" viewBox="0 0 24 24" color="#111" style="color:#111" height="1em" width="1em"><path d="M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z"></path></svg>',
913
- "linkedin": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 448 512" color="#fff" style="color:#fff" height="1em" width="1em"><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"></path></svg>'
917
+ "linkedin": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 448 512" color="#fff" style="color:#fff" height="1em" width="1em"><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"></path></svg>',
918
+ "openai": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" role="img" viewBox="0 0 24 24" color="#fff" style="color:#fff" height="1em" width="1em"><path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"></path></svg>'
914
919
  };
915
920
 
916
921
  // src/operation-reconciliation-ui.ts
@@ -1462,7 +1467,8 @@ var REPORT_CHART_SCRIPT = String.raw`
1462
1467
  `;
1463
1468
 
1464
1469
  // src/ui.ts
1465
- var ADPORT_UI_URI = "ui://adport/insight-card-v30.html";
1470
+ var ADPORT_UI_URI = "ui://adport/insight-card-v31.html";
1471
+ var ADPORT_SUMMARY_UI_URI = "ui://adport/summary-card-v30.html";
1466
1472
  var ADPORT_UI_DOMAIN = "https://app.adport.dev";
1467
1473
  var ADPORT_UI_RESOURCE_DOMAINS = [
1468
1474
  ADPORT_UI_DOMAIN,
@@ -1499,6 +1505,7 @@ var providerNames = {
1499
1505
  pinterest: "Pinterest Ads",
1500
1506
  linkedin: "LinkedIn Ads",
1501
1507
  x: "X Ads",
1508
+ openai: "OpenAI Ads",
1502
1509
  mock: "Demo",
1503
1510
  demo: "Synthetic demo"
1504
1511
  };
@@ -1618,7 +1625,7 @@ var ADPORT_UI_HTML = String.raw`<!doctype html>
1618
1625
  .identity { display:flex; align-items:center; gap:10px; min-width:0 }
1619
1626
  .logo { display:grid; place-items:center; flex:0 0 auto; width:29px; height:29px; padding:6px; border:1px solid var(--line); border-radius:9px; color:var(--ink); background:var(--paper); font-weight:800; font-size:10px }
1620
1627
  .logo svg { display:block; width:100%; height:100% }
1621
- .logo.reddit { background:#ff4500 }.logo.linkedin { background:#0a66c2 }.logo.spotify { background:#1db954 }.logo.pinterest { background:#e60023 }.logo.x { background:#111 }.logo.snapchat { background:#fffc00;color:#111 }
1628
+ .logo.reddit { background:#ff4500 }.logo.linkedin { background:#0a66c2 }.logo.spotify { background:#1db954 }.logo.pinterest { background:#e60023 }.logo.x { background:#111 }.logo.openai { background:#000 }.logo.snapchat { background:#fffc00;color:#111 }
1622
1629
  .identity-copy { min-width:0 }
1623
1630
  .identity-copy b, .identity-copy span { display:block; overflow:hidden; white-space:nowrap; text-overflow:ellipsis }
1624
1631
  .identity-copy b { font-size:12px }.identity-copy span { margin-top:3px; color:var(--muted); font-size:10px }
@@ -1733,7 +1740,7 @@ ${TREND_UI_STYLES}
1733
1740
  const noticeText=(value,fallback)=>typeof value==='string'?value:typeof value?.message==='string'?value.message:typeof value?.reason==='string'?value.reason:fallback;
1734
1741
  const notices = data => [...arr(data.errors).map(error=>(error?.provider || 'Provider')+': '+noticeText(error,'Read failed')), ...arr(data.warnings).map(warning=>noticeText(warning,'Some metadata is unavailable')), ...arr(data.notes).filter(note=>typeof note==='string'), ...(typeof data.note==='string'?[data.note]:[]), ...(data.truncated ? ['Partial result: row limit reached. Totals and charts cover returned rows only.'] : [])].map(text => '<p class="notice">'+esc(text)+'</p>').join('');
1735
1742
  const providerName = (id, names) => names?.[id] || String(id || 'Provider');
1736
- const initials = (id) => ({snapchat:'S',spotify:'S',pinterest:'P',linkedin:'in',x:'X'}[id] || String(id || '?').slice(0,2).toUpperCase());
1743
+ const initials = (id) => ({snapchat:'S',spotify:'S',pinterest:'P',linkedin:'in',x:'X',openai:'AI'}[id] || String(id || '?').slice(0,2).toUpperCase());
1737
1744
  const providerSvg = ${JSON.stringify(PROVIDER_LOGOS)};
1738
1745
  const logo = (id) => '<span class="logo '+esc(id)+'" aria-hidden="true">'+(providerSvg[id] || esc(initials(id)))+'</span>';
1739
1746
  let syntheticResult = false;
@@ -1837,6 +1844,10 @@ ${PROVIDER_GALLERY_UI}
1837
1844
  if (meta.view === 'insights') return renderInsights(data,meta);
1838
1845
  return renderData(data,meta);
1839
1846
  }
1847
+ function rememberHostResult(fingerprint) {
1848
+ hostResults.add(fingerprint);
1849
+ if (hostResults.size>16) hostResults.delete(hostResults.values().next().value);
1850
+ }
1840
1851
  function acceptResult(result,local=false) {
1841
1852
  if (!result || typeof result !== 'object') return;
1842
1853
  const incoming=resultData(result);
@@ -1846,7 +1857,7 @@ ${PROVIDER_GALLERY_UI}
1846
1857
  // Host state updates can echo an old tool result after a local edit/apply.
1847
1858
  if (!local && state.hasLocalResult && hostResults.has(fingerprint)) return;
1848
1859
  if (local) state.hasLocalResult=true;
1849
- else {hostResults.add(fingerprint);if (hostResults.size>16) hostResults.delete(hostResults.values().next().value);}
1860
+ else rememberHostResult(fingerprint);
1850
1861
  clearTimeout(resultWait);
1851
1862
  // ChatGPT can deliver the same result through both supported bridges.
1852
1863
  // Do not reset an open disclosure when the second copy arrives.
@@ -1918,8 +1929,8 @@ ${PROVIDER_GALLERY_UI}
1918
1929
  </html>`;
1919
1930
 
1920
1931
  // src/index.ts
1921
- var PROVIDER_IDS = ["ga4", "gsc", "gtm", "google", "meta", "tiktok", "apple", "microsoft", "reddit", "snapchat", "spotify", "pinterest", "linkedin", "x"];
1922
- var ADPORT_UI_RESOURCE_URIS = [ADPORT_UI_URI, "ui://adport/insight-card-v29.html", "ui://adport/insight-card-v28.html", "ui://adport/insight-card-v27.html", "ui://adport/insight-card-v26.html", "ui://adport/insight-card-v25.html", "ui://adport/insight-card-v24.html", "ui://adport/insight-card-v23.html", "ui://adport/insight-card-v22.html", "ui://adport/insight-card-v21.html", "ui://adport/insight-card-v20.html", "ui://adport/insight-card-v19.html", "ui://adport/insight-card-v18.html", "ui://adport/insight-card-v17.html", "ui://adport/insight-card-v16.html", "ui://adport/insight-card-v15.html", "ui://adport/insight-card-v14.html", "ui://adport/insight-card-v13.html", "ui://adport/insight-card-v12.html", "ui://adport/insight-card-v11.html", "ui://adport/insight-card-v10.html", "ui://adport/insight-card-v9.html", "ui://adport/insight-card-v8.html", "ui://adport/insight-card-v7.html", "ui://adport/insight-card-v6.html", "ui://adport/insight-card-v5.html", "ui://adport/insight-card-v4.html", "ui://adport/insight-card-v3.html", "ui://adport/insight-card-v2.html"];
1932
+ var PROVIDER_IDS = ["ga4", "gsc", "gtm", "google", "meta", "tiktok", "apple", "microsoft", "reddit", "snapchat", "spotify", "pinterest", "linkedin", "x", "openai"];
1933
+ var ADPORT_UI_RESOURCE_URIS = [ADPORT_UI_URI, "ui://adport/insight-card-v30.html", "ui://adport/insight-card-v29.html", "ui://adport/insight-card-v28.html", "ui://adport/insight-card-v27.html", "ui://adport/insight-card-v26.html", "ui://adport/insight-card-v25.html", "ui://adport/insight-card-v24.html", "ui://adport/insight-card-v23.html", "ui://adport/insight-card-v22.html", "ui://adport/insight-card-v21.html", "ui://adport/insight-card-v20.html", "ui://adport/insight-card-v19.html", "ui://adport/insight-card-v18.html", "ui://adport/insight-card-v17.html", "ui://adport/insight-card-v16.html", "ui://adport/insight-card-v15.html", "ui://adport/insight-card-v14.html", "ui://adport/insight-card-v13.html", "ui://adport/insight-card-v12.html", "ui://adport/insight-card-v11.html", "ui://adport/insight-card-v10.html", "ui://adport/insight-card-v9.html", "ui://adport/insight-card-v8.html", "ui://adport/insight-card-v7.html", "ui://adport/insight-card-v6.html", "ui://adport/insight-card-v5.html", "ui://adport/insight-card-v4.html", "ui://adport/insight-card-v3.html", "ui://adport/insight-card-v2.html", ADPORT_SUMMARY_UI_URI];
1923
1934
  var DEFAULT_MCP_ICONS = [{
1924
1935
  src: "https://app.adport.dev/icon.svg?brand=orange-dot-v2",
1925
1936
  mimeType: "image/svg+xml",
@@ -1930,7 +1941,7 @@ async function assembleRuntime(options = {}) {
1930
1941
  const modules = [];
1931
1942
  const includeMock = options.includeMock ?? process.env.ADPORT_DEMO === "true";
1932
1943
  if (!includeMock) {
1933
- for (const factory of [createGa4Module, createGscModule, createGtmModule, createGoogleModule, createMetaModule, createTikTokModule, createAppleModule, createMicrosoftModule, createRedditModule, createSnapchatModule, createSpotifyModule, createPinterestModule, createLinkedInModule, createXModule]) {
1944
+ for (const factory of [createGa4Module, createGscModule, createGtmModule, createGoogleModule, createMetaModule, createTikTokModule, createAppleModule, createMicrosoftModule, createRedditModule, createSnapchatModule, createSpotifyModule, createPinterestModule, createLinkedInModule, createXModule, createOpenAIModule]) {
1934
1945
  const module = await factory(store);
1935
1946
  if (module) modules.push(module);
1936
1947
  }
@@ -1944,18 +1955,43 @@ function createMcpUiServer({ name = "adport", version = package_default.version,
1944
1955
  return server;
1945
1956
  }
1946
1957
  function registerUiResources(server, uiDomain, uiResourceDomains, uiConnectDomains) {
1947
- const resourceMeta = {
1948
- ui: { ...uiDomain ? { domain: uiDomain } : {}, prefersBorder: false, csp: { connectDomains: [...uiConnectDomains], resourceDomains: [...uiResourceDomains] } },
1949
- ...uiDomain?.startsWith("https://") ? { "openai/widgetDomain": uiDomain } : {}
1950
- };
1951
- for (const uri of ADPORT_UI_RESOURCE_URIS) registerAppResource(
1952
- server,
1953
- uri === ADPORT_UI_URI ? "Adport insight card" : "Adport insight card (previous URI)",
1954
- uri,
1955
- { description: "Responsive Adport accounts, performance, planning estimates, creatives, recommendations, and guarded-change view.", _meta: resourceMeta },
1956
- async () => ({ contents: [{ uri, mimeType: RESOURCE_MIME_TYPE, text: ADPORT_UI_HTML, _meta: resourceMeta }] })
1957
- );
1958
+ const summaryDomains = uiResourceDomains.filter((domain) => domain === ADPORT_UI_DOMAIN || uiConnectDomains.includes(domain));
1959
+ for (const uri of ADPORT_UI_RESOURCE_URIS) {
1960
+ const summary = uri === ADPORT_SUMMARY_UI_URI;
1961
+ const resourceMeta = {
1962
+ ui: {
1963
+ ...uiDomain ? { domain: uiDomain } : {},
1964
+ prefersBorder: false,
1965
+ csp: { connectDomains: summary ? [] : [...uiConnectDomains], resourceDomains: summary ? summaryDomains : [...uiResourceDomains] }
1966
+ },
1967
+ ...uiDomain?.startsWith("https://") ? { "openai/widgetDomain": uiDomain } : {}
1968
+ };
1969
+ const title = uri === ADPORT_UI_URI ? "Adport insight card" : "Adport insight card (previous URI)";
1970
+ registerAppResource(
1971
+ server,
1972
+ summary ? "Adport summary card" : title,
1973
+ uri,
1974
+ { description: summary ? "Adport results." : "Adport cards and creative previews.", _meta: resourceMeta },
1975
+ async () => ({ contents: [{ uri, mimeType: RESOURCE_MIME_TYPE, text: ADPORT_UI_HTML, _meta: resourceMeta }] })
1976
+ );
1977
+ }
1958
1978
  }
1979
+ var hostedWriteOutput = z.looseObject({
1980
+ status: writeOutput.shape.status,
1981
+ applied: writeOutput.shape.applied,
1982
+ preview: z.looseObject(writeOutput.shape.preview.pick({ summary: true, serverValidated: true }).shape),
1983
+ pending_operation_id: z.string().optional(),
1984
+ expires_at: writeOutput.shape.expires_at.describe("Preview expiration."),
1985
+ result: z.looseObject({}).optional()
1986
+ });
1987
+ var explicitHostedTitle = /* @__PURE__ */ new Set([
1988
+ "meta_create_campaign",
1989
+ "google_create_performance_max_campaign"
1990
+ ]);
1991
+ var explicitHostedUiVisibility = /* @__PURE__ */ new Set([
1992
+ ...explicitHostedTitle,
1993
+ "linkedin_get_sponsored_post"
1994
+ ]);
1959
1995
  function createMcpServer({ runtime, catalog = { profile: "full", providers: null }, includeRawTools = false, instructions, name = "adport", version = package_default.version, icons = DEFAULT_MCP_ICONS, scopes, scopeDenials, notConnectedMessage, productionOnly = false, uiDomain = ADPORT_UI_DOMAIN, uiResourceDomains = ADPORT_UI_RESOURCE_DOMAINS, uiConnectDomains = [] }) {
1960
1996
  if (productionOnly && (runtime.dataSource === "synthetic" || runtime.ctx.providers.list().some((provider) => !PROVIDER_IDS.includes(provider.id)) || runtime.registry.list().some((tool) => /^(demo|mock|synthetic)(_|$)/.test(tool.name) || /^(demo|mock|synthetic)$/.test(tool.namespace)))) {
1961
1997
  throw new AdportError("POLICY_VIOLATION", "Demo tools and synthetic runtimes are not available on the production connector.");
@@ -1971,19 +2007,22 @@ function createMcpServer({ runtime, catalog = { profile: "full", providers: null
1971
2007
  const scopeDenial = scopes && !scopes.includes(requiredScope) ? scopeDenials?.[requiredScope] : void 0;
1972
2008
  if (scopes && !scopes.includes(requiredScope) && !scopeDenial) continue;
1973
2009
  const view = tool.presentation ?? viewForTool(tool.name, tool.annotations.readOnly ?? false);
1974
- const labels = view ? toolInvocationLabels(view) : void 0;
2010
+ const resourceUri = productionOnly && view !== "creatives" ? ADPORT_SUMMARY_UI_URI : ADPORT_UI_URI;
1975
2011
  const canRefresh = (view === "creatives" || view === "records") && tool.annotations.readOnly;
1976
2012
  const canPage = canRefresh && tool.pagination !== void 0;
1977
2013
  const wrapOutput = !!tool.output && !(tool.output instanceof z.ZodObject);
1978
- const objectOutput = tool.output ? tool.output instanceof z.ZodObject ? tool.output : z.object({ value: tool.output }) : void 0;
2014
+ const output = productionOnly && tool.output === writeOutput ? hostedWriteOutput : tool.output;
2015
+ const objectOutput = output ? output instanceof z.ZodObject ? output : z.object({ value: output }) : void 0;
2016
+ const definition = productionOnly ? tool.hosted ?? tool : tool;
2017
+ const title = toolTitle(tool.name);
1979
2018
  const config = {
1980
- title: toolTitle(tool.name),
1981
- description: scopeDenial ? `${tool.description}
2019
+ ...!productionOnly || explicitHostedTitle.has(tool.name) ? { title } : {},
2020
+ description: scopeDenial ? `${definition.description}
1982
2021
 
1983
- Unavailable on the current plan: ${scopeDenial.message}` : tool.description,
1984
- inputSchema: tool.input,
2022
+ Unavailable on the current plan: ${scopeDenial.message}` : definition.description,
2023
+ inputSchema: definition.input,
1985
2024
  ...objectOutput ? { outputSchema: objectOutput.extend({
1986
- ...view ? { _adport: z.object({
2025
+ ...view ? { _adport: productionOnly ? z.looseObject({}) : z.object({
1987
2026
  tool: z.literal(tool.name),
1988
2027
  view: z.literal(view),
1989
2028
  providerNames: z.record(z.string(), z.string()),
@@ -1999,12 +2038,15 @@ Unavailable on the current plan: ${scopeDenial.message}` : tool.description,
1999
2038
  ...runtime.dataSource === "synthetic" ? { data_source: z.literal("synthetic") } : {}
2000
2039
  }) } : {},
2001
2040
  annotations: {
2002
- title: toolTitle(tool.name),
2041
+ title,
2003
2042
  readOnlyHint: tool.annotations.readOnly ?? false,
2004
2043
  destructiveHint: tool.annotations.destructive ?? false,
2005
2044
  openWorldHint: tool.annotations.openWorld ?? false
2006
2045
  },
2007
- _meta: { "adport/catalog": tool.catalog ?? {}, ...tool.fileInputs?.length ? { "openai/fileParams": [...tool.fileInputs] } : {} }
2046
+ _meta: {
2047
+ ...!productionOnly ? { "adport/catalog": tool.catalog ?? {} } : {},
2048
+ ...tool.fileInputs?.length ? { "openai/fileParams": [...tool.fileInputs] } : {}
2049
+ }
2008
2050
  };
2009
2051
  const callback = async (args) => {
2010
2052
  const descriptor = {
@@ -2038,7 +2080,7 @@ Unavailable on the current plan: ${scopeDenial.message}` : tool.description,
2038
2080
  const rawObject = rawResult && typeof rawResult === "object" && !Array.isArray(rawResult) ? rawResult : {};
2039
2081
  const nestedResult = rawObject.result && typeof rawObject.result === "object" && !Array.isArray(rawObject.result) ? rawObject.result : {};
2040
2082
  const pending = rawObject.pending_operation_id ?? nestedResult.pending_operation_id;
2041
- const privateArguments = tool.sensitiveInputs?.some((path) => {
2083
+ const privateArguments = [...tool.sensitiveInputs ?? [], ...tool.fileInputs ?? []].some((path) => {
2042
2084
  let current = args;
2043
2085
  for (const key of path.split(".")) {
2044
2086
  if (!current || typeof current !== "object" || !Object.hasOwn(current, key)) return false;
@@ -2070,15 +2112,18 @@ Unavailable on the current plan: ${scopeDenial.message}` : tool.description,
2070
2112
  }
2071
2113
  };
2072
2114
  if (view) {
2115
+ const labels = toolInvocationLabels(view);
2073
2116
  registerAppTool(server, tool.name, {
2074
2117
  ...config,
2075
2118
  _meta: {
2076
2119
  ...config._meta,
2077
- ui: { resourceUri: ADPORT_UI_URI, visibility: ["model", "app"] },
2120
+ ui: !productionOnly || explicitHostedUiVisibility.has(tool.name) ? { resourceUri, visibility: ["model", "app"] } : { resourceUri },
2078
2121
  "openai/widgetAccessible": true,
2079
- "openai/outputTemplate": ADPORT_UI_URI,
2080
- "openai/toolInvocation/invoking": labels.invoking,
2081
- "openai/toolInvocation/invoked": labels.invoked
2122
+ "openai/outputTemplate": resourceUri,
2123
+ ...!productionOnly ? {
2124
+ "openai/toolInvocation/invoking": labels.invoking,
2125
+ "openai/toolInvocation/invoked": labels.invoked
2126
+ } : {}
2082
2127
  }
2083
2128
  }, callback);
2084
2129
  } else {
@@ -2104,4 +2149,4 @@ export {
2104
2149
  createMcpServer,
2105
2150
  runStdioServer
2106
2151
  };
2107
- //# sourceMappingURL=chunk-DPHTHY2E.js.map
2152
+ //# sourceMappingURL=chunk-HPKW6X2B.js.map