@robosystems/mcp 0.1.1

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +43 -0
  3. package/index.js +203 -0
  4. package/package.json +47 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Harbinger FinLab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # RoboSystems MCP
2
+
3
+ MCP (Model Context Protocol) server for accessing RoboSystems Financial Knowledge Graph API through Claude and other AI assistants.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @robosystems/mcp
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Add to your Claude Desktop configuration:
14
+
15
+ ```json
16
+ "robosystems": {
17
+ "command": "npx",
18
+ "args": ["-y", "@robosystems/mcp"],
19
+ "env": {
20
+ "ROBOSYSTEMS_API_URL": "https://api.robosystems.ai",
21
+ "ROBOSYSTEMS_API_KEY": "your-api-key-here",
22
+ "ROBOSYSTEMS_GRAPH_ID": "your-graph-id"
23
+ }
24
+ }
25
+ ```
26
+
27
+ ## Environment Variables
28
+
29
+ - `ROBOSYSTEMS_API_URL`: The RoboSystems API endpoint (default: http://localhost:8000)
30
+ - `ROBOSYSTEMS_API_KEY`: Your API key (required)
31
+ - `ROBOSYSTEMS_GRAPH_ID`: The graph database ID to connect to (default: default)
32
+
33
+ ## Available Tools
34
+
35
+ - `read-graph-cypher`: Execute read-only Cypher queries on the graph database
36
+ - `get-graph-schema`: Retrieve the database schema
37
+ - `get-graph-info`: Get basic information about the graph
38
+
39
+ ## License
40
+
41
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
42
+
43
+ MIT © 2024 Harbinger FinLab
package/index.js ADDED
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * RoboSystems MCP Client - JavaScript Implementation
5
+ *
6
+ * This client connects to the RoboSystems HTTP API and exposes it as MCP tools.
7
+ */
8
+
9
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js'
10
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
11
+ import {
12
+ CallToolRequestSchema,
13
+ ListToolsRequestSchema,
14
+ } from '@modelcontextprotocol/sdk/types.js'
15
+
16
+ class RoboSystemsMCPClient {
17
+ constructor(baseUrl, apiKey, graphId) {
18
+ this.baseUrl = baseUrl.replace(/\/$/, '') // Remove trailing slash
19
+ this.apiKey = apiKey
20
+ this.graphId = graphId
21
+ this.headers = {
22
+ 'X-API-Key': apiKey,
23
+ 'Content-Type': 'application/json',
24
+ }
25
+ }
26
+
27
+ async getTools() {
28
+ try {
29
+ const response = await fetch(
30
+ `${this.baseUrl}/v1/${this.graphId}/mcp/tools`,
31
+ {
32
+ headers: this.headers,
33
+ }
34
+ )
35
+
36
+ if (!response.ok) {
37
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`)
38
+ }
39
+
40
+ const data = await response.json()
41
+ return data.tools || []
42
+ } catch (error) {
43
+ console.error(`Failed to get tools: ${error.message}`)
44
+ return []
45
+ }
46
+ }
47
+
48
+ async callTool(name, args = {}) {
49
+ try {
50
+ const response = await fetch(
51
+ `${this.baseUrl}/v1/${this.graphId}/mcp/call-tool`,
52
+ {
53
+ method: 'POST',
54
+ headers: this.headers,
55
+ body: JSON.stringify({ name, arguments: args }),
56
+ }
57
+ )
58
+
59
+ if (!response.ok) {
60
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`)
61
+ }
62
+
63
+ const data = await response.json()
64
+ return data.result || { type: 'text', text: 'No result' }
65
+ } catch (error) {
66
+ console.error(`Failed to call tool ${name}: ${error.message}`)
67
+ return { type: 'text', text: `Error: ${error.message}` }
68
+ }
69
+ }
70
+ }
71
+
72
+ async function main() {
73
+ // Get configuration from environment variables
74
+ const baseUrl = process.env.ROBOSYSTEMS_API_URL || 'http://localhost:8000'
75
+ const apiKey = process.env.ROBOSYSTEMS_API_KEY
76
+ const graphId = process.env.ROBOSYSTEMS_GRAPH_ID || 'default'
77
+
78
+ if (!apiKey) {
79
+ console.error('ROBOSYSTEMS_API_KEY environment variable is required')
80
+ process.exit(1)
81
+ }
82
+
83
+ console.error(
84
+ `Connecting to RoboSystems API at ${baseUrl} for graph ${graphId}`
85
+ )
86
+
87
+ // Initialize the remote client
88
+ const remoteClient = new RoboSystemsMCPClient(baseUrl, apiKey, graphId)
89
+
90
+ // Create local MCP server that bridges to the remote service
91
+ const server = new Server(
92
+ {
93
+ name: 'robosystems-mcp',
94
+ version: '1.0.0',
95
+ },
96
+ {
97
+ capabilities: {
98
+ tools: {},
99
+ },
100
+ }
101
+ )
102
+
103
+ // List tools handler
104
+ server.setRequestHandler(
105
+ ListToolsRequestSchema,
106
+ async () => {
107
+ try {
108
+ const toolsData = await remoteClient.getTools()
109
+
110
+ // Convert to MCP Tool objects
111
+ const tools = toolsData.map((toolData) => ({
112
+ name: toolData.name,
113
+ description: toolData.description,
114
+ inputSchema: toolData.inputSchema,
115
+ }))
116
+
117
+ return { tools }
118
+ } catch (error) {
119
+ console.error(`Error listing tools: ${error.message}`)
120
+ return { tools: [] }
121
+ }
122
+ }
123
+ )
124
+
125
+ // Call tool handler
126
+ server.setRequestHandler(
127
+ CallToolRequestSchema,
128
+ async (request) => {
129
+ try {
130
+ const { name, arguments: args } = request.params
131
+
132
+ const result = await remoteClient.callTool(name, args || {})
133
+
134
+ // Convert result to MCP content
135
+ const content = []
136
+ if (result.type === 'text') {
137
+ content.push({
138
+ type: 'text',
139
+ text: result.text,
140
+ })
141
+ } else {
142
+ content.push({
143
+ type: 'text',
144
+ text: JSON.stringify(result, null, 2),
145
+ })
146
+ }
147
+
148
+ return { content }
149
+ } catch (error) {
150
+ console.error(
151
+ `Error calling tool ${request.params.name}: ${error.message}`
152
+ )
153
+
154
+ return {
155
+ content: [
156
+ {
157
+ type: 'text',
158
+ text: `Error: ${error.message}`,
159
+ },
160
+ ],
161
+ }
162
+ }
163
+ }
164
+ )
165
+
166
+ // Test connection and start server
167
+ try {
168
+ const tools = await remoteClient.getTools()
169
+ const toolNames = tools.map((t) => t.name)
170
+ console.error(
171
+ `Connected successfully. Available tools: ${toolNames.join(', ')}`
172
+ )
173
+
174
+ // Start the MCP server
175
+ const transport = new StdioServerTransport()
176
+ await server.connect(transport)
177
+
178
+ console.error('RoboSystems MCP server running with stdio transport')
179
+
180
+ // Keep the process alive
181
+ await new Promise(() => {}) // Never resolves
182
+ } catch (error) {
183
+ console.error(`MCP server error: ${error.message}`)
184
+ process.exit(1)
185
+ }
186
+ }
187
+
188
+ // Handle graceful shutdown
189
+ process.on('SIGINT', () => {
190
+ console.error('Shutting down RoboSystems MCP client')
191
+ process.exit(0)
192
+ })
193
+
194
+ process.on('SIGTERM', () => {
195
+ console.error('Shutting down RoboSystems MCP client')
196
+ process.exit(0)
197
+ })
198
+
199
+ // Run the server
200
+ main().catch((error) => {
201
+ console.error(`Fatal error: ${error.message}`)
202
+ process.exit(1)
203
+ })
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@robosystems/mcp",
3
+ "version": "0.1.1",
4
+ "description": "MCP server for RoboSystems Financial Knowledge Graph API",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "@robosystems/mcp": "./index.js"
9
+ },
10
+ "files": [
11
+ "index.js",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "start": "node index.js"
17
+ },
18
+ "keywords": [
19
+ "mcp",
20
+ "robosystems",
21
+ "financial",
22
+ "graph",
23
+ "kuzu",
24
+ "api",
25
+ "model-context-protocol"
26
+ ],
27
+ "author": "RoboSystems Team",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "@modelcontextprotocol/sdk": "^1.13.0"
31
+ },
32
+ "engines": {
33
+ "node": ">=18.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/HarbingerFinLab/robosystems-mcp",
41
+ "directory": "package"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/HarbingerFinLab/robosystems-mcp/issues"
45
+ },
46
+ "homepage": "https://github.com/HarbingerFinLab/robosystems-mcp#readme"
47
+ }