@gainable.dev/mcp-server 0.1.3 → 0.1.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.
@@ -28,7 +28,9 @@ export class GainableHttpRunner extends StreamableHttpRunner {
28
28
  const agent = await db.collection('agents').findOne({ appId: this.baseConfig.appName, uid: agentUid }, { projection: { scopes: 1 } });
29
29
  if (!agent?.scopes || agent.scopes.length === 0)
30
30
  return undefined;
31
- return agent.scopes;
31
+ // Normalize scopes: strip app prefix if present (e.g. "my-app_deals" → "deals")
32
+ const appPrefix = `${this.baseConfig.appName}_`;
33
+ return agent.scopes.map((s) => s.startsWith(appPrefix) ? s.slice(appPrefix.length) : s);
32
34
  }
33
35
  async createServerForRequest({ request, serverOptions, sessionOptions, }) {
34
36
  const agentId = extractAgentId(request);
@@ -36,19 +38,22 @@ export class GainableHttpRunner extends StreamableHttpRunner {
36
38
  if (agentId) {
37
39
  agentCollections = await this.getAgentScopes(agentId);
38
40
  }
39
- console.log(`[MCP Session] agent=${agentId ?? '(none)'} | scoped=${agentCollections ? 'yes' : 'no'}`);
41
+ console.log(`[MCP Session] agent=${agentId ?? '(none)'} | scoped=${agentCollections ? 'yes' : 'no'}${agentCollections ? ` | collections=${JSON.stringify(agentCollections)}` : ''}`);
40
42
  // Build per-agent scoping config
41
43
  const agentConfig = {
42
44
  ...this.baseConfig,
43
45
  agentCollections,
44
46
  };
45
47
  // Create a per-session connection manager with agent-specific scoping
48
+ console.log('[MCP Session] Creating connection manager...');
46
49
  const connectionManager = await createScopedConnectionManagerFactory(agentConfig)({
47
50
  logger: this.logger,
48
51
  deviceId: this.deviceId,
49
52
  userConfig: this.userConfig,
50
53
  });
51
- return this.createServer({
54
+ console.log('[MCP Session] Connection manager created');
55
+ console.log('[MCP Session] Creating server...');
56
+ const server = await this.createServer({
52
57
  userConfig: this.userConfig,
53
58
  logger: undefined,
54
59
  serverOptions: {
@@ -60,6 +65,8 @@ export class GainableHttpRunner extends StreamableHttpRunner {
60
65
  connectionManager,
61
66
  },
62
67
  });
68
+ console.log('[MCP Session] Server created successfully');
69
+ return server;
63
70
  }
64
71
  }
65
72
  function extractAgentId(request) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainable.dev/mcp-server",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Scoped MCP server for Gainable in-app copilot agents — wraps mongodb-mcp-server with per-app data isolation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",