@topolo/mcp 0.9.5 → 0.9.7

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 +83 -24
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -301,7 +301,9 @@ var APPLICATIONS = {
301
301
  "domains": [
302
302
  "bugfix.topolo.app"
303
303
  ],
304
- "routes": [],
304
+ "routes": [
305
+ "bugfix.topolo.app"
306
+ ],
305
307
  "appId": "bugfix"
306
308
  }
307
309
  ]
@@ -417,7 +419,9 @@ var APPLICATIONS = {
417
419
  "domains": [
418
420
  "capacity.topolo.app"
419
421
  ],
420
- "routes": [],
422
+ "routes": [
423
+ "capacity.topolo.app"
424
+ ],
421
425
  "appId": "capacity"
422
426
  }
423
427
  ]
@@ -1159,7 +1163,9 @@ var APPLICATIONS = {
1159
1163
  "domains": [
1160
1164
  "observability-watch.topolo.app"
1161
1165
  ],
1162
- "routes": [],
1166
+ "routes": [
1167
+ "observability-watch.topolo.app"
1168
+ ],
1163
1169
  "appId": "observability_watch"
1164
1170
  }
1165
1171
  ]
@@ -4654,21 +4660,50 @@ async function resolveMcpCredential(environment, selector = process.env.TOPOLO_C
4654
4660
  }
4655
4661
 
4656
4662
  // src/index.ts
4657
- async function main() {
4658
- const environment = normalizeEnvironment(process.env.TOPOLO_ENV);
4659
- const resolvedCredential = await resolveMcpCredential(environment);
4663
+ import { realpathSync } from "fs";
4664
+ import { fileURLToPath as fileURLToPath2 } from "url";
4665
+ import { resolve } from "path";
4666
+ function readStdioEnvironment() {
4667
+ return process.env.TOPOLO_ENV;
4668
+ }
4669
+ function createStdioTransport() {
4670
+ return new StdioServerTransport();
4671
+ }
4672
+ function writeStdioError(message) {
4673
+ process.stderr.write(message);
4674
+ }
4675
+ function exitStdioProcess(code) {
4676
+ return process.exit(code);
4677
+ }
4678
+ var DEFAULT_DEPENDENCIES2 = {
4679
+ normalizeEnvironment,
4680
+ environmentValue: readStdioEnvironment,
4681
+ resolveCredential: resolveMcpCredential,
4682
+ readConfig,
4683
+ profileForEnvironment,
4684
+ resolveAgentName,
4685
+ resolveServiceUrls,
4686
+ createTopolo,
4687
+ buildServer,
4688
+ createTransport: createStdioTransport,
4689
+ advertisedToolNames,
4690
+ writeStderr: writeStdioError,
4691
+ exit: exitStdioProcess
4692
+ };
4693
+ async function runStdioMcp(dependencies = DEFAULT_DEPENDENCIES2) {
4694
+ const environment = dependencies.normalizeEnvironment(dependencies.environmentValue());
4695
+ const resolvedCredential = await dependencies.resolveCredential(environment);
4660
4696
  const credential = resolvedCredential.credential;
4661
4697
  if (!credential) {
4662
- process.stderr.write(
4663
- "TopoloMCP: no Topolo credential. Run `topolo auth login`, or set TOPOLO_API_KEY / TOPOLO_ACCESS_TOKEN.\n"
4698
+ throw new TopoloMcpPublicError(
4699
+ "no Topolo credential. Run `topolo auth login`, or set TOPOLO_API_KEY / TOPOLO_ACCESS_TOKEN."
4664
4700
  );
4665
- process.exit(1);
4666
4701
  }
4667
- const config = await readConfig();
4668
- const profile = profileForEnvironment(config, environment);
4669
- const agentName = resolveAgentName(profile.agentName);
4670
- const serviceUrls = resolveServiceUrls(profile.serviceUrls, environment);
4671
- const topolo = createTopolo({
4702
+ const config = await dependencies.readConfig();
4703
+ const profile = dependencies.profileForEnvironment(config, environment);
4704
+ const agentName = dependencies.resolveAgentName(profile.agentName);
4705
+ const serviceUrls = dependencies.resolveServiceUrls(profile.serviceUrls, environment);
4706
+ const topolo = dependencies.createTopolo({
4672
4707
  credential,
4673
4708
  agent: {
4674
4709
  clientName: "topolo-mcp",
@@ -4681,11 +4716,11 @@ async function main() {
4681
4716
  ...resolvedCredential.refreshCredential ? { refreshCredential: resolvedCredential.refreshCredential } : {}
4682
4717
  });
4683
4718
  const scopes = await loadScopes(topolo);
4684
- const server = buildServer(topolo, scopes);
4685
- const transport = new StdioServerTransport();
4719
+ const server = dependencies.buildServer(topolo, scopes);
4720
+ const transport = dependencies.createTransport();
4686
4721
  await server.connect(transport);
4687
- const toolNames = await advertisedToolNames(topolo, scopes);
4688
- process.stderr.write(
4722
+ const toolNames = await dependencies.advertisedToolNames(topolo, scopes);
4723
+ dependencies.writeStderr(
4689
4724
  `TopoloMCP v${MCP_VERSION} connected (${environment}${resolvedCredential.contextKey ? `, ${resolvedCredential.contextKey}` : ""}). Tools available: ${toolNames.join(", ") || "(none)"}
4690
4725
  `
4691
4726
  );
@@ -4701,14 +4736,38 @@ async function loadScopes(topolo) {
4701
4736
  };
4702
4737
  } catch (err) {
4703
4738
  if (err instanceof TopoloAuthError) {
4704
- process.stderr.write("TopoloMCP: credential rejected.\n");
4705
- process.exit(1);
4739
+ throw new TopoloMcpPublicError("credential rejected.");
4706
4740
  }
4707
4741
  throw err;
4708
4742
  }
4709
4743
  }
4710
- main().catch((err) => {
4711
- process.stderr.write(`TopoloMCP fatal: ${publicMcpErrorMessage(err, "Unexpected startup failure.")}
4744
+ function terminateStdioMcp(error, dependencies = DEFAULT_DEPENDENCIES2) {
4745
+ const isPublic = error instanceof TopoloMcpPublicError;
4746
+ const message = publicMcpErrorMessage(error, "Unexpected startup failure.");
4747
+ dependencies.writeStderr(`TopoloMCP${isPublic ? "" : " fatal"}: ${message}
4712
4748
  `);
4713
- process.exit(1);
4714
- });
4749
+ return dependencies.exit(1);
4750
+ }
4751
+ function isDirectExecution(moduleUrl, argvEntry) {
4752
+ if (!argvEntry) {
4753
+ return false;
4754
+ }
4755
+ try {
4756
+ return realpathSync(fileURLToPath2(moduleUrl)) === realpathSync(resolve(argvEntry));
4757
+ } catch {
4758
+ return false;
4759
+ }
4760
+ }
4761
+ if (isDirectExecution(import.meta.url, process.argv[1])) {
4762
+ void runStdioMcp().catch((error) => terminateStdioMcp(error));
4763
+ }
4764
+ export {
4765
+ createStdioTransport,
4766
+ exitStdioProcess,
4767
+ isDirectExecution,
4768
+ loadScopes,
4769
+ readStdioEnvironment,
4770
+ runStdioMcp,
4771
+ terminateStdioMcp,
4772
+ writeStdioError
4773
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topolo/mcp",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
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": {
@@ -36,7 +36,7 @@
36
36
  "@modelcontextprotocol/sdk": "^1.0.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@topolo/sdk": "^0.9.5"
39
+ "@topolo/sdk": "^0.9.6"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@topolo/sdk": "file:../topolo-sdk",