@robosystems/mcp 0.3.6 → 0.3.8

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 (3) hide show
  1. package/README.md +51 -14
  2. package/index.js +64 -76
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,20 +3,19 @@
3
3
  [![npm version](https://badge.fury.io/js/@robosystems%2Fmcp.svg)](https://www.npmjs.com/package/@robosystems/mcp)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- Official MCP (Model Context Protocol) client adapter for connecting AI agents to the RoboSystems Financial Knowledge Graph API. Access comprehensive financial data including accounting transactions, financial reports, and advanced graph analytics through the Model Context Protocol.
6
+ Official MCP (Model Context Protocol) server for connecting AI agents to the RoboSystems Financial Knowledge Graph API. Query financial statements, explore graph structures, resolve XBRL elements, and build fact grids — all from Claude Desktop, Claude Code, Cursor, or any MCP-compatible client.
7
7
 
8
8
  ## Features
9
9
 
10
- - **AI Memory Graphs** - Persistent agent memory with built-in Concept/Observation/Session schema
11
- - **Workspace Management** - Create isolated subgraphs for memory, data workspaces, and experimentation
12
- - **Dynamic Schema Extension** - Add custom node and relationship tables to subgraphs via MCP tools
13
- - **MCP-compliant server** for Claude Desktop, Claude Code, Cursor, and other AI agents
14
- - **Streaming support** for memory-efficient processing of large result sets
15
- - **Connection pooling** for optimal SSE performance
10
+ - **Financial data tools** for statements, disclosures, and multidimensional fact grids
11
+ - **Graph exploration** with Cypher queries, schema introspection, and element resolution
12
+ - **Workspace management** for isolated subgraphs, staging data, and persistent agent memory
13
+ - **Streaming support** via SSE and NDJSON for large result sets
14
+ - **Connection pooling** with LRU eviction for optimal performance
16
15
  - **Smart caching** for frequently accessed schemas and metadata
17
16
  - **Automatic retry logic** with exponential backoff
18
17
 
19
- ## Quick Start
18
+ ## Installation
20
19
 
21
20
  Add to your MCP servers configuration:
22
21
 
@@ -36,19 +35,57 @@ Add to your MCP servers configuration:
36
35
  }
37
36
  ```
38
37
 
39
- ## Environment Variables
38
+ ### Environment Variables
40
39
 
41
- | Variable | Description | Example |
42
- | ---------------------- | ----------------------------------------------------- | ---------------------------- |
43
- | `ROBOSYSTEMS_API_URL` | The RoboSystems API endpoint | `https://api.robosystems.ai` |
44
- | `ROBOSYSTEMS_API_KEY` | Your API key | `rfs...` |
45
- | `ROBOSYSTEMS_GRAPH_ID` | The primary graph database ID (parent for workspaces) | `kg...` or `sec` |
40
+ | Variable | Description | Default |
41
+ | ---------------------- | ---------------------------------------- | ---------------------------- |
42
+ | `ROBOSYSTEMS_API_KEY` | Your API key | _(required)_ |
43
+ | `ROBOSYSTEMS_GRAPH_ID` | Primary graph ID (parent for workspaces) | _(required)_ |
44
+ | `ROBOSYSTEMS_API_URL` | API endpoint | `https://api.robosystems.ai` |
45
+
46
+ ## Tools
47
+
48
+ Tools are loaded dynamically from the RoboSystems API based on your graph. The client also provides built-in workspace management tools.
49
+
50
+ ### Financial Data
51
+
52
+ | Tool | Description |
53
+ | ------------------------- | ------------------------------------------------------------------------------------------------ |
54
+ | `get-financial-statement` | Retrieve structured financial statements (income, balance sheet, cash flow) by ticker and period |
55
+ | `list-disclosures` | List available disclosure types with counts, optionally filtered by ticker |
56
+ | `get-disclosure-detail` | Get facts for a specific disclosure type |
57
+ | `build-fact-grid` | Construct multidimensional fact grids from graph data for analysis |
58
+
59
+ ### Graph Exploration
60
+
61
+ | Tool | Description |
62
+ | -------------------------- | ---------------------------------------------------------------------------- |
63
+ | `execute-cypher` | Run Cypher queries against the knowledge graph with validation and streaming |
64
+ | `get-graph-schema` | Introspect node types, relationships, and properties |
65
+ | `describe-graph-structure` | Explore graph structure and relationship patterns |
66
+ | `get-graph-info` | Graph metadata and statistics |
67
+ | `resolve-element` | Map financial concepts (e.g. "revenue") to XBRL element qnames |
68
+ | `resolve-structure` | Find financial statement structures by type |
69
+ | `get-properties` | Discover available properties on node types |
70
+ | `get-example-queries` | Query templates and examples for common patterns |
71
+
72
+ ### Workspaces
73
+
74
+ | Tool | Description |
75
+ | ------------------ | --------------------------------------------------- |
76
+ | `create-workspace` | Create an isolated subgraph (static or memory type) |
77
+ | `switch-workspace` | Switch active workspace context |
78
+ | `list-workspaces` | List all workspaces with active indicator |
79
+ | `delete-workspace` | Remove a workspace and its data |
80
+
81
+ Workspaces let you create isolated subgraphs for experimentation, staging data, or persistent agent memory. Use `subgraph_type: "memory"` when creating a workspace to get a dedicated memory graph.
46
82
 
47
83
  ## Resources
48
84
 
49
85
  - [RoboSystems Platform](https://robosystems.ai)
50
86
  - [GitHub Repository](https://github.com/RoboFinSystems/robosystems)
51
87
  - [MCP API Documentation](https://api.robosystems.ai/docs#tag/MCP)
88
+ - [OpenAPI Specification](https://api.robosystems.ai/openapi.json)
52
89
 
53
90
  ## Support
54
91
 
package/index.js CHANGED
@@ -452,93 +452,81 @@ class RoboSystemsMCPClient {
452
452
  }
453
453
 
454
454
  async handleSSEResponse(response, toolName) {
455
- return new Promise((resolve, reject) => {
456
- const events = []
457
- const operationId = response.headers.get('x-operation-id') || `sse-${Date.now()}`
458
-
459
- const eventSource = this.connectionPool.getConnection(operationId, response.url, this.headers)
455
+ // Read SSE events directly from the POST response body instead of opening
456
+ // a new EventSource. EventSource always uses GET, which 405s on this
457
+ // POST-only endpoint. The SSE stream is already in the response body.
458
+ const events = []
459
+ const reader = response.body.getReader()
460
+ const decoder = new TextDecoder()
461
+ let buffer = ''
460
462
 
461
- const timeout = setTimeout(() => {
462
- this.connectionPool.closeConnection(operationId)
463
- reject(new Error('SSE timeout after 5 minutes'))
464
- }, 300000)
463
+ let timeoutId
464
+ const timeout = new Promise((_, reject) => {
465
+ timeoutId = setTimeout(() => reject(new Error('SSE timeout after 5 minutes')), 300000)
466
+ })
465
467
 
466
- eventSource.onmessage = (event) => {
467
- try {
468
- const data = JSON.parse(event.data)
469
- events.push({ event: event.type || 'message', data })
470
- } catch (e) {
471
- console.error('Failed to parse SSE event:', e)
472
- }
473
- }
468
+ const readStream = async () => {
469
+ try {
470
+ while (true) {
471
+ const { done, value } = await reader.read()
472
+ if (done) break
473
+
474
+ buffer += decoder.decode(value, { stream: true })
475
+ const lines = buffer.split(/\r?\n/)
476
+ buffer = lines.pop() || ''
477
+
478
+ for (const line of lines) {
479
+ if (line.startsWith('data:')) {
480
+ const dataStr = line.slice(5).trim()
481
+ if (!dataStr || dataStr === '[DONE]') continue
482
+
483
+ let data
484
+ try {
485
+ data = JSON.parse(dataStr)
486
+ } catch (e) {
487
+ console.error('Failed to parse SSE event:', e)
488
+ continue
489
+ }
474
490
 
475
- eventSource.addEventListener('complete', () => {
476
- clearTimeout(timeout)
477
- const result = this.aggregateStreamedResults(events, toolName)
478
- resolve(result)
479
- })
491
+ const eventType = data.event || 'message'
480
492
 
481
- // Listen for the actual server event types
482
- eventSource.addEventListener('operation_completed', () => {
483
- clearTimeout(timeout)
484
- this.connectionPool.closeConnection(operationId)
485
- const result = this.aggregateStreamedResults(events, toolName)
486
- resolve(result)
487
- })
493
+ if (eventType === 'operation_error') {
494
+ throw new Error(data.data?.error || data.data?.message || 'Operation failed')
495
+ }
488
496
 
489
- eventSource.addEventListener('operation_error', (event) => {
490
- clearTimeout(timeout)
491
- this.connectionPool.closeConnection(operationId)
492
- try {
493
- const data = JSON.parse(event.data)
494
- reject(new Error(data.error || data.message || 'Operation failed'))
495
- } catch (_e) {
496
- reject(new Error('Operation failed'))
497
- }
498
- })
497
+ if (eventType === 'operation_progress' || eventType === 'progress') {
498
+ const progress = data.data?.percentage ? `${data.data.percentage}% - ` : ''
499
+ console.error(`Progress: ${progress}${data.data?.message || 'Processing...'}`)
500
+ continue
501
+ }
499
502
 
500
- eventSource.addEventListener('error', () => {
501
- clearTimeout(timeout)
502
- this.connectionPool.closeConnection(operationId)
503
+ events.push({ event: eventType, data: data.data ?? data })
503
504
 
504
- if (events.length > 0) {
505
- const result = this.aggregateStreamedResults(events, toolName)
506
- resolve(result)
507
- } else {
508
- reject(new Error('SSE connection failed'))
505
+ if (eventType === 'complete' || eventType === 'operation_completed') {
506
+ return
507
+ }
508
+ } else if (line.startsWith('event:')) {
509
+ // event: lines are handled via the data: payload's event field
510
+ }
511
+ }
509
512
  }
510
- })
513
+ } finally {
514
+ reader.cancel().catch(() => {})
515
+ }
516
+ }
511
517
 
512
- // Handle specific event types
513
- eventSource.addEventListener('query_chunk', (event) => {
514
- try {
515
- const data = JSON.parse(event.data)
516
- events.push({ event: 'query_chunk', data })
517
- } catch (e) {
518
- console.error('Failed to parse query chunk:', e)
519
- }
520
- })
518
+ try {
519
+ await Promise.race([readStream(), timeout])
520
+ } finally {
521
+ clearTimeout(timeoutId)
522
+ reader.cancel().catch(() => {})
523
+ }
521
524
 
522
- eventSource.addEventListener('progress', (event) => {
523
- try {
524
- const data = JSON.parse(event.data)
525
- console.error(`Progress: ${data.message || 'Processing...'}`)
526
- } catch (_e) {
527
- // Ignore progress parsing errors
528
- }
529
- })
525
+ if (events.length === 0) {
526
+ throw new Error('SSE connection failed')
527
+ }
530
528
 
531
- // Also listen for operation_progress events
532
- eventSource.addEventListener('operation_progress', (event) => {
533
- try {
534
- const data = JSON.parse(event.data)
535
- const progress = data.percentage ? `${data.percentage}% - ` : ''
536
- console.error(`Progress: ${progress}${data.message || 'Processing...'}`)
537
- } catch (_e) {
538
- // Ignore progress parsing errors
539
- }
540
- })
541
- })
529
+ return this.aggregateStreamedResults(events, toolName)
542
530
  }
543
531
 
544
532
  async handleNDJSONResponse(response) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/mcp",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
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",