@insforge/mcp 1.2.7 → 1.2.9

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.
@@ -41,17 +41,40 @@ ${JSON.stringify(data, null, 2)}`;
41
41
 
42
42
  // src/shared/usage-tracker.ts
43
43
  import fetch from "node-fetch";
44
+ var PLATFORM_API_BASE = "https://api.insforge.dev";
45
+ function parseAppKey(apiBaseUrl) {
46
+ try {
47
+ const url = new URL(apiBaseUrl);
48
+ const match = url.hostname.match(/^([^.]+)\.[^.]+\.insforge\.app$/);
49
+ return match ? match[1] : null;
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
44
54
  var UsageTracker = class {
45
55
  apiBaseUrl;
46
56
  apiKey;
47
- constructor(apiBaseUrl, apiKey) {
57
+ agentConnectedReported = false;
58
+ projectId;
59
+ accessToken;
60
+ isRemote;
61
+ constructor(apiBaseUrl, apiKey, options) {
48
62
  this.apiBaseUrl = apiBaseUrl;
49
63
  this.apiKey = apiKey;
64
+ this.projectId = options?.projectId;
65
+ this.accessToken = options?.accessToken;
66
+ this.isRemote = options?.isRemote ?? false;
50
67
  }
51
68
  async trackUsage(toolName, success = true) {
52
69
  if (!this.apiKey) {
53
70
  return;
54
71
  }
72
+ if (!this.agentConnectedReported) {
73
+ this.agentConnectedReported = true;
74
+ this.reportAgentConnected().catch((error) => {
75
+ console.error("Failed to report agent-connected:", error);
76
+ });
77
+ }
55
78
  try {
56
79
  const payload = {
57
80
  tool_name: toolName,
@@ -70,6 +93,27 @@ var UsageTracker = class {
70
93
  console.error("Failed to track usage:", error);
71
94
  }
72
95
  }
96
+ async reportAgentConnected() {
97
+ const body = {};
98
+ const headers = { "Content-Type": "application/json" };
99
+ if (this.isRemote && this.projectId && this.projectId !== "legacy") {
100
+ body.project_id = this.projectId;
101
+ if (this.accessToken) {
102
+ headers["Authorization"] = `Bearer ${this.accessToken}`;
103
+ }
104
+ } else {
105
+ const appKey = parseAppKey(this.apiBaseUrl);
106
+ if (!appKey) {
107
+ return;
108
+ }
109
+ body.app_key = appKey;
110
+ }
111
+ await fetch(`${PLATFORM_API_BASE}/tracking/v1/agent-connected`, {
112
+ method: "POST",
113
+ headers,
114
+ body: JSON.stringify(body)
115
+ });
116
+ }
73
117
  };
74
118
 
75
119
  // src/shared/tools/docs.ts
@@ -2873,7 +2917,11 @@ async function registerInsforgeTools(server, config = {}) {
2873
2917
  const GLOBAL_API_KEY = config.apiKey || process.env.API_KEY || "";
2874
2918
  const API_BASE_URL = config.apiBaseUrl || process.env.API_BASE_URL || "http://localhost:7130";
2875
2919
  const isRemote = config.mode === "remote";
2876
- const usageTracker = new UsageTracker(API_BASE_URL, GLOBAL_API_KEY);
2920
+ const usageTracker = new UsageTracker(API_BASE_URL, GLOBAL_API_KEY, {
2921
+ projectId: config.projectId,
2922
+ accessToken: config.accessToken,
2923
+ isRemote
2924
+ });
2877
2925
  let backendVersion;
2878
2926
  try {
2879
2927
  backendVersion = await fetchBackendVersion(API_BASE_URL);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  registerInsforgeTools
4
- } from "./chunk-Z3FXBI3Z.js";
4
+ } from "./chunk-YH7HSQYJ.js";
5
5
 
6
6
  // src/http/server.ts
7
7
  import "dotenv/config";
@@ -98,7 +98,9 @@ var SessionManager = class {
98
98
  const toolsConfig = await registerInsforgeTools(server, {
99
99
  apiKey: sessionData.apiKey,
100
100
  apiBaseUrl: sessionData.apiBaseUrl,
101
- mode: "remote"
101
+ mode: "remote",
102
+ projectId: sessionData.projectId,
103
+ accessToken: sessionData.oauthTokenHash
102
104
  });
103
105
  await server.connect(transport);
104
106
  const fullSessionData = {
@@ -186,7 +188,9 @@ var SessionManager = class {
186
188
  await registerInsforgeTools(server, {
187
189
  apiKey: sessionData.apiKey,
188
190
  apiBaseUrl: sessionData.apiBaseUrl,
189
- mode: "remote"
191
+ mode: "remote",
192
+ projectId: sessionData.projectId,
193
+ accessToken: sessionData.oauthTokenHash
190
194
  });
191
195
  await server.connect(transport);
192
196
  this.runtimeSessions.set(sessionId, { server, transport, transportType: "streamable" });
@@ -210,7 +214,9 @@ var SessionManager = class {
210
214
  const toolsConfig = await registerInsforgeTools(server, {
211
215
  apiKey: sessionData.apiKey,
212
216
  apiBaseUrl: sessionData.apiBaseUrl,
213
- mode: "remote"
217
+ mode: "remote",
218
+ projectId: sessionData.projectId,
219
+ accessToken: sessionData.oauthTokenHash
214
220
  });
215
221
  await server.connect(transport);
216
222
  const fullSessionData = {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  registerInsforgeTools
4
- } from "./chunk-Z3FXBI3Z.js";
4
+ } from "./chunk-YH7HSQYJ.js";
5
5
 
6
6
  // src/stdio/index.ts
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@insforge/mcp",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "MCP (Model Context Protocol) server for Insforge backend-as-a-service",
5
5
  "mcpName": "io.github.InsForge/insforge-mcp",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "bin": {
9
+ "mcp": "./dist/index.js",
9
10
  "insforge-mcp": "./dist/index.js",
10
- "insforge-mcp-server": "./dist/http/server.js"
11
+ "insforge-mcp-server": "./dist/http-server.js"
11
12
  },
12
13
  "scripts": {
13
14
  "dev:stdio": "tsx watch src/stdio/index.ts",
@@ -44,7 +45,7 @@
44
45
  "server.json"
45
46
  ],
46
47
  "dependencies": {
47
- "@insforge/shared-schemas": "1.1.46",
48
+ "@insforge/shared-schemas": "1.1.47",
48
49
  "@modelcontextprotocol/sdk": "^1.27.1",
49
50
  "archiver": "^7.0.1",
50
51
  "commander": "^14.0.0",
@@ -77,6 +78,7 @@
77
78
  "tsx": "^4.7.0",
78
79
  "typescript": "^5.3.3",
79
80
  "typescript-eslint": "^8.57.1",
81
+ "vite": "^8.0.3",
80
82
  "vitest": "^4.1.0"
81
83
  }
82
84
  }