investbuddy-mcp-server 1.0.0 → 1.0.2

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 (2) hide show
  1. package/index.js +32 -42
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -87,30 +87,6 @@ const TOOLS = [
87
87
  required: ['holdings']
88
88
  }
89
89
  },
90
- {
91
- name: 'optimize_portfolio',
92
- description: 'Get AI-powered portfolio optimization recommendations',
93
- inputSchema: {
94
- type: 'object',
95
- properties: {
96
- holdings: {
97
- type: 'array',
98
- items: {
99
- type: 'object',
100
- properties: {
101
- symbol: { type: 'string' },
102
- shares: { type: 'number' }
103
- }
104
- }
105
- },
106
- risk_tolerance: {
107
- type: 'string',
108
- enum: ['conservative', 'moderate', 'aggressive']
109
- }
110
- },
111
- required: ['holdings', 'risk_tolerance']
112
- }
113
- },
114
90
  {
115
91
  name: 'batch_predict',
116
92
  description: 'Get predictions for multiple stocks in a single call',
@@ -129,27 +105,43 @@ const TOOLS = [
129
105
  ];
130
106
 
131
107
  /**
132
- * Call InvestBuddy MCP API
108
+ * Map MCP tool names to API endpoints and methods
109
+ */
110
+ const TOOL_ENDPOINTS = {
111
+ 'get_stock_prediction': { path: '/mcp/predict', method: 'POST' },
112
+ 'get_market_regime': { path: '/mcp/market-regime', method: 'GET' },
113
+ 'discover_stocks': { path: '/mcp/discover', method: 'POST' },
114
+ 'analyze_portfolio': { path: '/mcp/analyze-portfolio', method: 'POST' },
115
+ 'batch_predict': { path: '/mcp/batch-predict', method: 'POST' }
116
+ };
117
+
118
+ /**
119
+ * Call InvestBuddy API
133
120
  */
134
- function callMCPAPI(tool, args) {
121
+ function callAPI(tool, args) {
135
122
  return new Promise((resolve, reject) => {
136
- const data = JSON.stringify({
137
- tool: tool,
138
- arguments: args
139
- });
123
+ const endpoint = TOOL_ENDPOINTS[tool];
124
+ if (!endpoint) {
125
+ return reject(new Error(`Unknown tool: ${tool}`));
126
+ }
127
+
128
+ const data = endpoint.method === 'POST' ? JSON.stringify(args) : null;
140
129
 
141
130
  const options = {
142
131
  hostname: 'www.investbuddy.ai',
143
132
  port: 443,
144
- path: '/mcp/call',
145
- method: 'POST',
133
+ path: endpoint.path,
134
+ method: endpoint.method,
146
135
  headers: {
147
136
  'Content-Type': 'application/json',
148
- 'Content-Length': data.length,
149
- 'Authorization': `Bearer ${API_KEY}`
137
+ 'x-api-key': API_KEY
150
138
  }
151
139
  };
152
140
 
141
+ if (data) {
142
+ options.headers['Content-Length'] = data.length;
143
+ }
144
+
153
145
  const req = https.request(options, (res) => {
154
146
  let responseData = '';
155
147
 
@@ -160,13 +152,9 @@ function callMCPAPI(tool, args) {
160
152
  res.on('end', () => {
161
153
  try {
162
154
  const parsed = JSON.parse(responseData);
163
- if (parsed.success) {
164
- resolve(parsed.data);
165
- } else {
166
- reject(new Error(parsed.error || 'API call failed'));
167
- }
155
+ resolve(parsed);
168
156
  } catch (error) {
169
- reject(error);
157
+ reject(new Error(`Failed to parse response: ${responseData}`));
170
158
  }
171
159
  });
172
160
  });
@@ -175,7 +163,9 @@ function callMCPAPI(tool, args) {
175
163
  reject(error);
176
164
  });
177
165
 
178
- req.write(data);
166
+ if (data) {
167
+ req.write(data);
168
+ }
179
169
  req.end();
180
170
  });
181
171
  }
@@ -209,7 +199,7 @@ async function handleMessage(message) {
209
199
 
210
200
  case 'tools/call':
211
201
  const { name, arguments: toolArgs } = params;
212
- const apiResult = await callMCPAPI(name, toolArgs || {});
202
+ const apiResult = await callAPI(name, toolArgs || {});
213
203
  result = {
214
204
  content: [
215
205
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "investbuddy-mcp-server",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Model Context Protocol server for InvestBuddy AI - Stock predictions with 79.86% accuracy",
5
5
  "main": "index.js",
6
6
  "bin": {