@topolo/mcp 0.2.4 → 0.2.5

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 +24 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/index.ts
4
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
5
 
6
- // ../../PlatformApplications/packages/topolo-sdk/dist/index.js
6
+ // ../packages/topolo-sdk/dist/index.js
7
7
  function applyAuthHeaders(headers, credential) {
8
8
  if (credential.kind === "api_key") {
9
9
  headers.set("X-Api-Key", credential.apiKey);
@@ -74,7 +74,7 @@ var SERVICES = {
74
74
  mdm: "https://topolo-mdm-api.topolo.app",
75
75
  messaging: "https://messages.topolo.app",
76
76
  nexus: "https://topolo-nexus-gateway.topolo.workers.dev",
77
- one: "https://topoloone-worker.topolo.workers.dev",
77
+ one: "https://one.topolo.app",
78
78
  pay: "https://topolo-pay.topolo.workers.dev",
79
79
  "quro.api": "https://api.ol0.me",
80
80
  "quro.redirect": "https://ol0.me",
@@ -671,7 +671,7 @@ var APPLICATIONS = {
671
671
  {
672
672
  "name": "topoloone-worker",
673
673
  "kind": "worker",
674
- "apiUrl": "https://topoloone-worker.topolo.workers.dev",
674
+ "apiUrl": "https://one.topolo.app",
675
675
  "domains": [],
676
676
  "routes": [
677
677
  "one.topolo.app/*"
@@ -1077,8 +1077,9 @@ var APPLICATION_REQUIREMENTS = [
1077
1077
  ];
1078
1078
  function applicationRequirementScopes(application) {
1079
1079
  const scopes = /* @__PURE__ */ new Set(["all"]);
1080
- const hasBrowserSurface = Boolean(application.productionUrl) || application.deployTargets.some((target) => target.kind === "pages");
1081
- const hasApiSurface = application.services.length > 0 || application.deployTargets.some((target) => Boolean(target.apiUrl));
1080
+ const deployTargets = application.deployTargets;
1081
+ const hasBrowserSurface = Boolean(application.productionUrl) || deployTargets.some((target) => target.kind === "pages");
1082
+ const hasApiSurface = application.services.length > 0 || deployTargets.some((target) => Boolean(target.apiUrl));
1082
1083
  if (hasBrowserSurface) scopes.add("browser");
1083
1084
  if (hasApiSurface) scopes.add("api");
1084
1085
  if (application.id === "cli" || application.id === "mcp" || application.id === "cloudcontrol") {
@@ -1264,10 +1265,11 @@ function statusRank(status) {
1264
1265
  }
1265
1266
  var DEFAULT_SERVICE_URLS = SERVICES;
1266
1267
  function resolveServiceUrl(service, overrides) {
1267
- const override = overrides?.[service];
1268
+ var _a;
1269
+ const override = overrides == null ? void 0 : overrides[service];
1268
1270
  if (override) return override;
1269
1271
  const envKey = `TOPOLO_SERVICE_URL_${service.replace(/\./g, "_").toUpperCase()}`;
1270
- const envValue = typeof process !== "undefined" ? process.env?.[envKey] : void 0;
1272
+ const envValue = typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a[envKey] : void 0;
1271
1273
  if (envValue) return envValue;
1272
1274
  return DEFAULT_SERVICE_URLS[service];
1273
1275
  }
@@ -1281,8 +1283,9 @@ var TopoloClient = class {
1281
1283
  fetchImpl;
1282
1284
  debug;
1283
1285
  constructor(options) {
1286
+ var _a;
1284
1287
  if (!options.credential) throw new TopoloAuthError("credential is required");
1285
- if (!options.agent?.clientName) throw new TopoloAuthError("agent.clientName is required");
1288
+ if (!((_a = options.agent) == null ? void 0 : _a.clientName)) throw new TopoloAuthError("agent.clientName is required");
1286
1289
  this.credential = options.credential;
1287
1290
  this.agent = options.agent;
1288
1291
  this.serviceUrls = options.serviceUrls;
@@ -1470,6 +1473,7 @@ var CrmModule = class {
1470
1473
  }
1471
1474
  client;
1472
1475
  async listContacts(options = {}) {
1476
+ var _a, _b, _c;
1473
1477
  const res = await this.client.request({
1474
1478
  service: "crm",
1475
1479
  path: "/api/contacts",
@@ -1479,12 +1483,12 @@ var CrmModule = class {
1479
1483
  pageSize: options.pageSize
1480
1484
  }
1481
1485
  });
1482
- const rows = Array.isArray(res?.contacts) ? res.contacts : Array.isArray(res?.data) ? res.data : [];
1486
+ const rows = Array.isArray(res == null ? void 0 : res.contacts) ? res.contacts : Array.isArray(res == null ? void 0 : res.data) ? res.data : [];
1483
1487
  return {
1484
1488
  contacts: rows.map(toSummary),
1485
- total: res?.total ?? res?.pagination?.total ?? rows.length,
1486
- page: res?.page ?? res?.pagination?.page ?? options.page ?? 1,
1487
- pageSize: res?.pageSize ?? res?.pagination?.pageSize ?? options.pageSize ?? rows.length
1489
+ total: (res == null ? void 0 : res.total) ?? ((_a = res == null ? void 0 : res.pagination) == null ? void 0 : _a.total) ?? rows.length,
1490
+ page: (res == null ? void 0 : res.page) ?? ((_b = res == null ? void 0 : res.pagination) == null ? void 0 : _b.page) ?? options.page ?? 1,
1491
+ pageSize: (res == null ? void 0 : res.pageSize) ?? ((_c = res == null ? void 0 : res.pagination) == null ? void 0 : _c.pageSize) ?? options.pageSize ?? rows.length
1488
1492
  };
1489
1493
  }
1490
1494
  async getContact(contactId) {
@@ -1557,8 +1561,11 @@ import {
1557
1561
  } from "@modelcontextprotocol/sdk/types.js";
1558
1562
 
1559
1563
  // src/gating.ts
1564
+ function hasPlatformAccess(set) {
1565
+ return (set.role === "platform_super_admin" || set.role === "platform_admin") && set.orgSlug === "admin";
1566
+ }
1560
1567
  function hasScope(set, required) {
1561
- if (set.role === "super_admin") return true;
1568
+ if (hasPlatformAccess(set)) return true;
1562
1569
  if (set.permissions.includes("*")) return true;
1563
1570
  const [servicePart, actionPart] = splitPermission(required);
1564
1571
  if (!servicePart) return set.permissions.includes(required);
@@ -1913,7 +1920,7 @@ function statusesAtOrWorse(threshold) {
1913
1920
  }
1914
1921
 
1915
1922
  // src/version.ts
1916
- var MCP_VERSION = "0.2.4";
1923
+ var MCP_VERSION = "0.2.5";
1917
1924
 
1918
1925
  // src/server.ts
1919
1926
  function buildServer(topolo, scopes, tools = TOOLS) {
@@ -2008,9 +2015,11 @@ async function main() {
2008
2015
  async function loadScopes(topolo) {
2009
2016
  try {
2010
2017
  const info = await topolo.identity.whoami();
2018
+ const userWithOrgSlug = info.user;
2011
2019
  return {
2012
2020
  permissions: info.user.permissions,
2013
- role: info.user.role
2021
+ role: info.user.role,
2022
+ orgSlug: info.organization?.slug || userWithOrgSlug.orgSlug || void 0
2014
2023
  };
2015
2024
  } catch (err) {
2016
2025
  if (err instanceof TopoloAuthError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topolo/mcp",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Model Context Protocol server for the Topolo platform. Exposes scope-gated tools that third-party agents (Claude, Codex, etc.) can call natively.",
5
5
  "type": "module",
6
6
  "bin": {