@robosystems/mcp 0.3.9 → 0.3.11

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/README.md CHANGED
@@ -24,7 +24,7 @@ Add to your MCP servers configuration:
24
24
  "mcpServers": {
25
25
  "robosystems": {
26
26
  "command": "npx",
27
- "args": ["-y", "@robosystems/mcp"],
27
+ "args": ["-y", "@robosystems/mcp@latest"],
28
28
  "env": {
29
29
  "ROBOSYSTEMS_API_URL": "https://api.robosystems.ai",
30
30
  "ROBOSYSTEMS_API_KEY": "rfs...",
@@ -9,7 +9,7 @@ set -e
9
9
  BRANCH_TYPE=${1:-feature}
10
10
  BRANCH_NAME=${2:-}
11
11
  BASE_BRANCH=${3:-main}
12
- UPDATE_DEPS=${4:-yes}
12
+ UPDATE_DEPS=${4:-no}
13
13
 
14
14
  # Validate branch type
15
15
  if [[ "$BRANCH_TYPE" != "feature" && "$BRANCH_TYPE" != "bugfix" && "$BRANCH_TYPE" != "hotfix" && "$BRANCH_TYPE" != "chore" && "$BRANCH_TYPE" != "refactor" ]]; then
@@ -80,7 +80,9 @@ git push -u origin $FULL_BRANCH
80
80
  echo ""
81
81
  echo "🎉 Successfully created and checked out $FULL_BRANCH"
82
82
 
83
- # Update dependencies if requested (default: yes)
83
+ # Update dependencies only when explicitly requested (default: no).
84
+ # Pass "yes" as the 4th arg to refresh deps on the new branch; otherwise
85
+ # branch creation leaves the lockfile untouched.
84
86
  if [[ "$UPDATE_DEPS" == "yes" ]]; then
85
87
  echo ""
86
88
  echo "📦 Updating dependencies..."
@@ -93,7 +95,7 @@ echo "📝 Next steps:"
93
95
  echo " 1. Make your changes and commit them"
94
96
  echo " 2. Push your changes: git push"
95
97
  echo " 3. Create a PR: gh pr create --base $BASE_BRANCH --title \"Your PR title\" --body \"Your PR description\""
96
- echo " or use: npm run pr:create"
98
+ echo " or in a Claude Code session: /create-pr"
97
99
 
98
100
  # Check if we had stashed changes and auto-apply them
99
101
  if git stash list | grep -q "Auto-stash before creating branch $FULL_BRANCH"; then
package/index.js CHANGED
@@ -30,6 +30,54 @@ const __dirname = dirname(__filename)
30
30
  const packageJson = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8'))
31
31
  const PACKAGE_VERSION = packageJson.version
32
32
 
33
+ /**
34
+ * Numeric semver compare for the three core components ("1.2.3").
35
+ * Pre-release tags are ignored — good enough for a stale-version warning.
36
+ */
37
+ function _isNewerVersion(latest, current) {
38
+ const a = String(latest)
39
+ .split('.')
40
+ .map((n) => parseInt(n, 10) || 0)
41
+ const b = String(current)
42
+ .split('.')
43
+ .map((n) => parseInt(n, 10) || 0)
44
+ for (let i = 0; i < 3; i++) {
45
+ if (a[i] > b[i]) return true
46
+ if (a[i] < b[i]) return false
47
+ }
48
+ return false
49
+ }
50
+
51
+ /**
52
+ * Best-effort check for a newer published version. Runs once at startup, never
53
+ * blocks, and only logs to stderr. Surfaces the silent stale-install problem: a
54
+ * global `npm i -g @robosystems/mcp` can shadow `npx -y` and pin an old version
55
+ * without any error, so a published update never reaches the user.
56
+ */
57
+ async function checkForUpdate() {
58
+ try {
59
+ const controller = new AbortController()
60
+ const timer = setTimeout(() => controller.abort(), 2500)
61
+ const response = await fetch('https://registry.npmjs.org/@robosystems/mcp/latest', {
62
+ signal: controller.signal,
63
+ })
64
+ clearTimeout(timer)
65
+ if (!response.ok) return
66
+ const data = await response.json()
67
+ const latest = data?.version
68
+ if (latest && _isNewerVersion(latest, PACKAGE_VERSION)) {
69
+ console.error(
70
+ `⚠️ @robosystems/mcp ${latest} is available — you are running ${PACKAGE_VERSION}.`
71
+ )
72
+ console.error(' A global install can shadow `npx -y` and pin an old version. Update with:')
73
+ console.error(' npm i -g @robosystems/mcp@latest')
74
+ console.error(' or pin "@robosystems/mcp@latest" in your MCP config args.')
75
+ }
76
+ } catch {
77
+ // Best-effort only — never block or fail startup on the update check.
78
+ }
79
+ }
80
+
33
81
  /**
34
82
  * Simple SSE Connection Pool
35
83
  * Reuses connections for better performance
@@ -181,6 +229,7 @@ class RoboSystemsMCPClient {
181
229
  this.primaryGraphId = graphId // Parent graph (never changes)
182
230
  this.activeGraphId = graphId // Currently active graph (can switch to workspaces)
183
231
  this.graphId = graphId // Deprecated: kept for backward compatibility
232
+ this.instructions = null // Per-graph routing guidance for the active graph (set by getTools)
184
233
  this.headers = {
185
234
  'X-API-Key': apiKey,
186
235
  'Content-Type': 'application/json',
@@ -227,6 +276,10 @@ class RoboSystemsMCPClient {
227
276
 
228
277
  const data = await response.json()
229
278
  let tools = data.tools || []
279
+ // Per-graph routing guidance for the active graph. Surfaced to the host
280
+ // via the handshake `instructions` field (primary graph) and inline in
281
+ // switch-workspace results (switched graph).
282
+ this.instructions = data.instructions ?? null
230
283
  console.error(`Got ${tools.length} tools from API`)
231
284
 
232
285
  // Add client-side workspace tools (if not already provided by server)
@@ -248,6 +301,7 @@ class RoboSystemsMCPClient {
248
301
  } catch (error) {
249
302
  console.error(`Failed to get tools: ${error.message}`)
250
303
  console.error(`Stack: ${error.stack}`)
304
+ this.instructions = null
251
305
  return []
252
306
  }
253
307
  }
@@ -895,6 +949,16 @@ class RoboSystemsMCPClient {
895
949
  const workspace = this.workspaces.get(targetGraphId)
896
950
  console.error(`Switched from ${previousGraph} to ${targetGraphId}`)
897
951
 
952
+ // The handshake `instructions` field is immutable mid-session, so surface
953
+ // the now-active graph's routing guidance inline in the switch result.
954
+ let instructions
955
+ try {
956
+ await this.getTools()
957
+ instructions = this.instructions || undefined
958
+ } catch (error) {
959
+ console.error(`Could not load instructions for ${targetGraphId}: ${error.message}`)
960
+ }
961
+
898
962
  return {
899
963
  type: 'text',
900
964
  text: JSON.stringify(
@@ -904,6 +968,7 @@ class RoboSystemsMCPClient {
904
968
  switched_to: targetGraphId,
905
969
  workspace_type: workspace.type,
906
970
  message: `Switched to ${workspace.type === 'primary' ? 'primary graph' : `workspace "${workspace.name}"`}. All operations now use this environment.`,
971
+ ...(instructions ? { instructions } : {}),
907
972
  },
908
973
  null,
909
974
  2
@@ -1157,22 +1222,50 @@ async function main() {
1157
1222
  }
1158
1223
 
1159
1224
  console.error(`RoboSystems MCP Client v${PACKAGE_VERSION}`)
1225
+ void checkForUpdate() // fire-and-forget stale-version warning (stderr only)
1160
1226
  console.error(`Connecting to ${baseUrl}`)
1161
1227
  console.error(`Primary graph: ${graphId}`)
1162
1228
  console.error(`API Key: ${apiKey.substring(0, 10)}...`)
1163
1229
 
1164
1230
  const remoteClient = new RoboSystemsMCPClient(baseUrl, apiKey, graphId)
1165
1231
 
1232
+ // Prefetch the primary graph's tools + instructions BEFORE constructing the
1233
+ // server. The MCP `instructions` field ships in the initialize handshake and
1234
+ // is immutable afterward, so it must be present at construction time (unlike
1235
+ // tools, which are fetched lazily per ListTools request). This also serves as
1236
+ // the initial connection test.
1237
+ let primaryInstructions
1238
+ try {
1239
+ console.error('Testing API connection...')
1240
+ const tools = await remoteClient.getTools()
1241
+ const toolNames = tools.map((t) => t.name)
1242
+ console.error(`Connected successfully. Available tools: ${toolNames.join(', ')}`)
1243
+ primaryInstructions = remoteClient.instructions || undefined
1244
+ if (primaryInstructions) {
1245
+ console.error(
1246
+ `Loaded per-graph instructions for ${graphId} (${primaryInstructions.length} chars)`
1247
+ )
1248
+ }
1249
+ } catch (error) {
1250
+ console.error(`Initial connection test failed: ${error.message}`)
1251
+ // Continue anyway: ListTools retries on demand; instructions stay unset.
1252
+ }
1253
+
1254
+ const serverOptions = {
1255
+ capabilities: {
1256
+ tools: {},
1257
+ },
1258
+ }
1259
+ if (primaryInstructions) {
1260
+ serverOptions.instructions = primaryInstructions
1261
+ }
1262
+
1166
1263
  const server = new Server(
1167
1264
  {
1168
1265
  name: 'robosystems-mcp',
1169
1266
  version: PACKAGE_VERSION,
1170
1267
  },
1171
- {
1172
- capabilities: {
1173
- tools: {},
1174
- },
1175
- }
1268
+ serverOptions
1176
1269
  )
1177
1270
 
1178
1271
  // List tools handler
@@ -1218,13 +1311,8 @@ async function main() {
1218
1311
  }
1219
1312
  })
1220
1313
 
1221
- // Test connection and start server
1314
+ // Start server (connection + tools already verified during prefetch above)
1222
1315
  try {
1223
- console.error('Testing API connection...')
1224
- const tools = await remoteClient.getTools()
1225
- const toolNames = tools.map((t) => t.name)
1226
- console.error(`Connected successfully. Available tools: ${toolNames.join(', ')}`)
1227
-
1228
1316
  const transport = new StdioServerTransport()
1229
1317
  console.error('Starting MCP stdio transport...')
1230
1318
  await server.connect(transport)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/mcp",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "MCP client adapter for connecting AI agents to RoboSystems Financial Knowledge Graph API endpoints with workspace support",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -25,8 +25,7 @@
25
25
  "test:watch": "vitest",
26
26
  "test:all": "npm run validate && npm run test",
27
27
  "feature:create": "./bin/create-feature.sh",
28
- "release:create": "./bin/create-release.sh",
29
- "pr:create": "./bin/create-pr.sh"
28
+ "release:create": "./bin/create-release.sh"
30
29
  },
31
30
  "keywords": [
32
31
  "mcp",