investbuddy-mcp-server 1.0.0 → 1.0.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.
- package/index.js +25 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -129,24 +129,38 @@ const TOOLS = [
|
|
|
129
129
|
];
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
|
-
*
|
|
132
|
+
* Map MCP tool names to API endpoints
|
|
133
133
|
*/
|
|
134
|
-
|
|
134
|
+
const TOOL_ENDPOINTS = {
|
|
135
|
+
'get_stock_prediction': '/mcp/predict',
|
|
136
|
+
'get_market_regime': '/mcp/market-regime',
|
|
137
|
+
'discover_stocks': '/mcp/discover',
|
|
138
|
+
'analyze_portfolio': '/mcp/analyze-portfolio',
|
|
139
|
+
'optimize_portfolio': '/mcp/optimize-portfolio',
|
|
140
|
+
'batch_predict': '/mcp/batch-predict'
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Call InvestBuddy API
|
|
145
|
+
*/
|
|
146
|
+
function callAPI(tool, args) {
|
|
135
147
|
return new Promise((resolve, reject) => {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
148
|
+
const endpoint = TOOL_ENDPOINTS[tool];
|
|
149
|
+
if (!endpoint) {
|
|
150
|
+
return reject(new Error(`Unknown tool: ${tool}`));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const data = JSON.stringify(args);
|
|
140
154
|
|
|
141
155
|
const options = {
|
|
142
156
|
hostname: 'www.investbuddy.ai',
|
|
143
157
|
port: 443,
|
|
144
|
-
path:
|
|
158
|
+
path: endpoint,
|
|
145
159
|
method: 'POST',
|
|
146
160
|
headers: {
|
|
147
161
|
'Content-Type': 'application/json',
|
|
148
162
|
'Content-Length': data.length,
|
|
149
|
-
'
|
|
163
|
+
'x-api-key': API_KEY
|
|
150
164
|
}
|
|
151
165
|
};
|
|
152
166
|
|
|
@@ -160,13 +174,9 @@ function callMCPAPI(tool, args) {
|
|
|
160
174
|
res.on('end', () => {
|
|
161
175
|
try {
|
|
162
176
|
const parsed = JSON.parse(responseData);
|
|
163
|
-
|
|
164
|
-
resolve(parsed.data);
|
|
165
|
-
} else {
|
|
166
|
-
reject(new Error(parsed.error || 'API call failed'));
|
|
167
|
-
}
|
|
177
|
+
resolve(parsed);
|
|
168
178
|
} catch (error) {
|
|
169
|
-
reject(
|
|
179
|
+
reject(new Error(`Failed to parse response: ${responseData}`));
|
|
170
180
|
}
|
|
171
181
|
});
|
|
172
182
|
});
|
|
@@ -209,7 +219,7 @@ async function handleMessage(message) {
|
|
|
209
219
|
|
|
210
220
|
case 'tools/call':
|
|
211
221
|
const { name, arguments: toolArgs } = params;
|
|
212
|
-
const apiResult = await
|
|
222
|
+
const apiResult = await callAPI(name, toolArgs || {});
|
|
213
223
|
result = {
|
|
214
224
|
content: [
|
|
215
225
|
{
|