@mcp-abap-adt/llm-proxy 0.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/LICENSE +22 -0
- package/README.md +526 -0
- package/dist/agent.d.ts +49 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +96 -0
- package/dist/agent.js.map +1 -0
- package/dist/agents/anthropic-agent.d.ts +32 -0
- package/dist/agents/anthropic-agent.d.ts.map +1 -0
- package/dist/agents/anthropic-agent.js +80 -0
- package/dist/agents/anthropic-agent.js.map +1 -0
- package/dist/agents/base.d.ts +64 -0
- package/dist/agents/base.d.ts.map +1 -0
- package/dist/agents/base.js +93 -0
- package/dist/agents/base.js.map +1 -0
- package/dist/agents/deepseek-agent.d.ts +31 -0
- package/dist/agents/deepseek-agent.d.ts.map +1 -0
- package/dist/agents/deepseek-agent.js +71 -0
- package/dist/agents/deepseek-agent.js.map +1 -0
- package/dist/agents/index.d.ts +9 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +9 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/openai-agent.d.ts +32 -0
- package/dist/agents/openai-agent.d.ts.map +1 -0
- package/dist/agents/openai-agent.js +69 -0
- package/dist/agents/openai-agent.js.map +1 -0
- package/dist/agents/prompt-based-agent.d.ts +28 -0
- package/dist/agents/prompt-based-agent.d.ts.map +1 -0
- package/dist/agents/prompt-based-agent.js +62 -0
- package/dist/agents/prompt-based-agent.js.map +1 -0
- package/dist/agents/sap-core-ai-agent.d.ts +22 -0
- package/dist/agents/sap-core-ai-agent.d.ts.map +1 -0
- package/dist/agents/sap-core-ai-agent.js +20 -0
- package/dist/agents/sap-core-ai-agent.js.map +1 -0
- package/dist/cli.d.ts +53 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +313 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-providers/anthropic.d.ts +21 -0
- package/dist/llm-providers/anthropic.d.ts.map +1 -0
- package/dist/llm-providers/anthropic.js +58 -0
- package/dist/llm-providers/anthropic.js.map +1 -0
- package/dist/llm-providers/base.d.ts +28 -0
- package/dist/llm-providers/base.d.ts.map +1 -0
- package/dist/llm-providers/base.js +18 -0
- package/dist/llm-providers/base.js.map +1 -0
- package/dist/llm-providers/deepseek.d.ts +21 -0
- package/dist/llm-providers/deepseek.d.ts.map +1 -0
- package/dist/llm-providers/deepseek.js +50 -0
- package/dist/llm-providers/deepseek.js.map +1 -0
- package/dist/llm-providers/index.d.ts +13 -0
- package/dist/llm-providers/index.d.ts.map +1 -0
- package/dist/llm-providers/index.js +15 -0
- package/dist/llm-providers/index.js.map +1 -0
- package/dist/llm-providers/openai.d.ts +23 -0
- package/dist/llm-providers/openai.d.ts.map +1 -0
- package/dist/llm-providers/openai.js +59 -0
- package/dist/llm-providers/openai.js.map +1 -0
- package/dist/llm-providers/sap-core-ai.d.ts +72 -0
- package/dist/llm-providers/sap-core-ai.d.ts.map +1 -0
- package/dist/llm-providers/sap-core-ai.js +114 -0
- package/dist/llm-providers/sap-core-ai.js.map +1 -0
- package/dist/mcp/client.d.ts +119 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +271 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Wraps the MCP SDK client to provide a simpler interface for the agent
|
|
5
|
+
*/
|
|
6
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
7
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
8
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
9
|
+
export class MCPClientWrapper {
|
|
10
|
+
client = null;
|
|
11
|
+
config;
|
|
12
|
+
tools = [];
|
|
13
|
+
detectedTransport;
|
|
14
|
+
sessionId;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.detectedTransport = this.detectTransport();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Detect transport type from config
|
|
21
|
+
*/
|
|
22
|
+
detectTransport() {
|
|
23
|
+
// If transport is explicitly set and not 'auto', use it
|
|
24
|
+
if (this.config.transport && this.config.transport !== 'auto') {
|
|
25
|
+
return this.config.transport;
|
|
26
|
+
}
|
|
27
|
+
// If direct handlers or server instance are provided, use embedded mode
|
|
28
|
+
if (this.config.listToolsHandler ||
|
|
29
|
+
this.config.callToolHandler ||
|
|
30
|
+
this.config.serverInstance) {
|
|
31
|
+
return 'embedded';
|
|
32
|
+
}
|
|
33
|
+
// If URL is provided, try to detect from URL
|
|
34
|
+
if (this.config.url) {
|
|
35
|
+
const url = this.config.url.toLowerCase();
|
|
36
|
+
if (url.includes('/sse') || url.endsWith('/sse')) {
|
|
37
|
+
return 'sse';
|
|
38
|
+
}
|
|
39
|
+
if (url.includes('/stream/http') || url.includes('/http')) {
|
|
40
|
+
return 'stream-http';
|
|
41
|
+
}
|
|
42
|
+
// Default for HTTP URLs
|
|
43
|
+
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
44
|
+
return 'stream-http';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// If command is provided, assume stdio
|
|
48
|
+
if (this.config.command) {
|
|
49
|
+
return 'stdio';
|
|
50
|
+
}
|
|
51
|
+
// Default fallback
|
|
52
|
+
throw new Error('Cannot determine transport type. Please provide either:\n' +
|
|
53
|
+
' - transport: "embedded" with serverInstance\n' +
|
|
54
|
+
' - transport: "stdio" with command\n' +
|
|
55
|
+
' - transport: "sse" or "stream-http" with url\n' +
|
|
56
|
+
' - url (will auto-detect transport)');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Initialize MCP client connection
|
|
60
|
+
*/
|
|
61
|
+
async connect() {
|
|
62
|
+
const transport = this.detectedTransport;
|
|
63
|
+
if (transport === 'embedded') {
|
|
64
|
+
const hasDirectTools = this.config.listToolsHandler || this.config.toolsRegistry;
|
|
65
|
+
// Embedded mode - allow direct handlers without serverInstance
|
|
66
|
+
if (!this.config.serverInstance && !hasDirectTools) {
|
|
67
|
+
throw new Error('serverInstance or toolsRegistry/listToolsHandler is required for embedded transport');
|
|
68
|
+
}
|
|
69
|
+
// If tools registry is provided, use it directly
|
|
70
|
+
if (this.config.listToolsHandler) {
|
|
71
|
+
this.tools = await this.config.listToolsHandler();
|
|
72
|
+
}
|
|
73
|
+
else if (this.config.toolsRegistry) {
|
|
74
|
+
this.tools = this.config.toolsRegistry.getAllTools();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Fallback: try to get from server instance if it has a method
|
|
78
|
+
if (this.config.serverInstance?.server) {
|
|
79
|
+
// Try to simulate ListToolsRequest
|
|
80
|
+
try {
|
|
81
|
+
// MCP Server has request handlers, but we need to call them directly
|
|
82
|
+
throw new Error('Direct server.listTools() not supported, use toolsRegistry');
|
|
83
|
+
}
|
|
84
|
+
catch (_err) {
|
|
85
|
+
throw new Error('Cannot get tools list in embedded mode. Provide toolsRegistry.');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new Error('Cannot get tools list in embedded mode. Provide toolsRegistry.');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// No need to connect in embedded mode - server is already in process
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
else if (transport === 'stdio') {
|
|
96
|
+
if (!this.config.command) {
|
|
97
|
+
throw new Error('Command is required for stdio transport');
|
|
98
|
+
}
|
|
99
|
+
const stdioTransport = new StdioClientTransport({
|
|
100
|
+
command: this.config.command,
|
|
101
|
+
args: this.config.args || [],
|
|
102
|
+
});
|
|
103
|
+
this.client = new Client({
|
|
104
|
+
name: 'llm-proxy',
|
|
105
|
+
version: '0.1.0',
|
|
106
|
+
}, {
|
|
107
|
+
capabilities: {},
|
|
108
|
+
});
|
|
109
|
+
await this.client.connect(stdioTransport);
|
|
110
|
+
// List available tools
|
|
111
|
+
const toolsResponse = await this.client.listTools();
|
|
112
|
+
this.tools = toolsResponse.tools || [];
|
|
113
|
+
}
|
|
114
|
+
else if (transport === 'sse' || transport === 'stream-http') {
|
|
115
|
+
if (!this.config.url) {
|
|
116
|
+
throw new Error('URL is required for HTTP transports');
|
|
117
|
+
}
|
|
118
|
+
// Use StreamableHTTPClientTransport for both SSE and stream-http
|
|
119
|
+
// The SDK handles the protocol differences internally
|
|
120
|
+
const httpTransport = new StreamableHTTPClientTransport(new URL(this.config.url), {
|
|
121
|
+
sessionId: this.config.sessionId,
|
|
122
|
+
requestInit: {
|
|
123
|
+
headers: this.config.headers || {},
|
|
124
|
+
signal: AbortSignal.timeout(this.config.timeout || 30000),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
this.client = new Client({
|
|
128
|
+
name: 'llm-proxy',
|
|
129
|
+
version: '0.1.0',
|
|
130
|
+
}, {
|
|
131
|
+
capabilities: {},
|
|
132
|
+
});
|
|
133
|
+
await this.client.connect(httpTransport);
|
|
134
|
+
// Store session ID if provided by transport
|
|
135
|
+
if (httpTransport.sessionId) {
|
|
136
|
+
this.sessionId = httpTransport.sessionId;
|
|
137
|
+
}
|
|
138
|
+
// List available tools
|
|
139
|
+
const toolsResponse = await this.client.listTools();
|
|
140
|
+
this.tools = toolsResponse.tools || [];
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw new Error(`Unsupported transport type: ${transport}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get detected transport type
|
|
148
|
+
*/
|
|
149
|
+
getTransport() {
|
|
150
|
+
return this.detectedTransport;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get current session ID (for HTTP transports)
|
|
154
|
+
*/
|
|
155
|
+
getSessionId() {
|
|
156
|
+
return this.sessionId || this.config.sessionId;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get list of available tools
|
|
160
|
+
*/
|
|
161
|
+
async listTools() {
|
|
162
|
+
// For embedded mode, tools are already loaded in connect()
|
|
163
|
+
if (this.detectedTransport === 'embedded') {
|
|
164
|
+
return this.tools;
|
|
165
|
+
}
|
|
166
|
+
if (!this.client) {
|
|
167
|
+
await this.connect();
|
|
168
|
+
}
|
|
169
|
+
if (this.tools.length === 0) {
|
|
170
|
+
const response = await this.client.listTools();
|
|
171
|
+
this.tools = response.tools || [];
|
|
172
|
+
}
|
|
173
|
+
return this.tools;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Execute a tool call
|
|
177
|
+
*/
|
|
178
|
+
async callTool(toolCall) {
|
|
179
|
+
// For embedded mode, use direct handler or server instance
|
|
180
|
+
if (this.detectedTransport === 'embedded') {
|
|
181
|
+
try {
|
|
182
|
+
let result;
|
|
183
|
+
if (this.config.callToolHandler) {
|
|
184
|
+
result = await this.config.callToolHandler(toolCall.name, toolCall.arguments);
|
|
185
|
+
}
|
|
186
|
+
else if (this.config.toolCallHandler) {
|
|
187
|
+
// Use provided handler
|
|
188
|
+
result = await this.config.toolCallHandler(toolCall.name, toolCall.arguments);
|
|
189
|
+
}
|
|
190
|
+
else if (this.config.serverInstance?.server) {
|
|
191
|
+
// Use MCP Server instance directly via CallToolRequest
|
|
192
|
+
// The server has request handlers registered, we need to call them
|
|
193
|
+
const { CallToolRequestSchema } = await import('@modelcontextprotocol/sdk/types.js');
|
|
194
|
+
// Create a request object that matches CallToolRequest format
|
|
195
|
+
const request = {
|
|
196
|
+
jsonrpc: '2.0',
|
|
197
|
+
id: 1,
|
|
198
|
+
method: 'tools/call',
|
|
199
|
+
params: {
|
|
200
|
+
name: toolCall.name,
|
|
201
|
+
arguments: toolCall.arguments,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
// Call the handler directly
|
|
205
|
+
// The server.setRequestHandler registers handlers, but we need to access them
|
|
206
|
+
// This is a limitation - provide toolCallHandler for embedded mode
|
|
207
|
+
throw new Error('Direct server.callTool() requires toolCallHandler. Provide toolCallHandler in mcpConfig.');
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
throw new Error('No tool call handler available in embedded mode. Provide toolCallHandler in mcpConfig.');
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
toolCallId: toolCall.id,
|
|
214
|
+
name: toolCall.name,
|
|
215
|
+
result: result.content || result,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
return {
|
|
220
|
+
toolCallId: toolCall.id,
|
|
221
|
+
name: toolCall.name,
|
|
222
|
+
result: null,
|
|
223
|
+
error: error.message || 'Tool execution failed',
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (!this.client) {
|
|
228
|
+
await this.connect();
|
|
229
|
+
}
|
|
230
|
+
try {
|
|
231
|
+
const response = await this.client.callTool({
|
|
232
|
+
name: toolCall.name,
|
|
233
|
+
arguments: toolCall.arguments,
|
|
234
|
+
});
|
|
235
|
+
return {
|
|
236
|
+
toolCallId: toolCall.id,
|
|
237
|
+
name: toolCall.name,
|
|
238
|
+
result: response.content,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
return {
|
|
243
|
+
toolCallId: toolCall.id,
|
|
244
|
+
name: toolCall.name,
|
|
245
|
+
result: null,
|
|
246
|
+
error: error.message || 'Tool execution failed',
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Execute multiple tool calls
|
|
252
|
+
*/
|
|
253
|
+
async callTools(toolCalls) {
|
|
254
|
+
const results = await Promise.all(toolCalls.map((toolCall) => this.callTool(toolCall)));
|
|
255
|
+
return results;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Disconnect from MCP server
|
|
259
|
+
*/
|
|
260
|
+
async disconnect() {
|
|
261
|
+
// For embedded mode, no need to disconnect
|
|
262
|
+
if (this.detectedTransport === 'embedded') {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (this.client) {
|
|
266
|
+
await this.client.close();
|
|
267
|
+
this.client = null;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AA4FnG,MAAM,OAAO,gBAAgB;IACnB,MAAM,GAAkB,IAAI,CAAC;IAC7B,MAAM,CAAkB;IACxB,KAAK,GAAU,EAAE,CAAC;IAClB,iBAAiB,CAAgB;IACjC,SAAS,CAAU;IAE3B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IAClD,CAAC;IAED;;OAEG;IACK,eAAe;QACrB,wDAAwD;QACxD,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAC/B,CAAC;QAED,wEAAwE;QACxE,IACE,IAAI,CAAC,MAAM,CAAC,gBAAgB;YAC5B,IAAI,CAAC,MAAM,CAAC,e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CAAC;IACH,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for LLM Proxy
|
|
3
|
+
*/
|
|
4
|
+
export interface Message {
|
|
5
|
+
/**
|
|
6
|
+
* Message role
|
|
7
|
+
* - 'user': User input
|
|
8
|
+
* - 'assistant': LLM response
|
|
9
|
+
* - 'system': System instructions
|
|
10
|
+
* - 'tool': Tool/function result (reserved for external consumers)
|
|
11
|
+
*/
|
|
12
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ToolCall {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
arguments: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
export interface ToolResult {
|
|
21
|
+
toolCallId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
result: any;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AgentResponse {
|
|
27
|
+
message: string;
|
|
28
|
+
raw?: unknown;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface LLMResponse {
|
|
32
|
+
content: string;
|
|
33
|
+
raw?: unknown;
|
|
34
|
+
finishReason?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface LLMProviderConfig {
|
|
37
|
+
apiKey: string;
|
|
38
|
+
baseURL?: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
temperature?: number;
|
|
41
|
+
maxTokens?: number;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcp-abap-adt/llm-proxy",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Minimal LLM proxy that normalizes provider access and surfaces MCP tools without executing them.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.json",
|
|
15
|
+
"dev": "tsx src/cli.ts",
|
|
16
|
+
"dev:llm": "tsx src/cli.ts --llm-only",
|
|
17
|
+
"start": "node dist/cli.js",
|
|
18
|
+
"start:llm": "node dist/cli.js --llm-only",
|
|
19
|
+
"test": "npm run build && npm start",
|
|
20
|
+
"test:llm": "npm run build && npm run start:llm",
|
|
21
|
+
"lint": "npx biome check --write --config-path . src",
|
|
22
|
+
"lint:check": "npx biome check --config-path . src",
|
|
23
|
+
"format": "npx biome format --write --config-path . src",
|
|
24
|
+
"clean": "rimraf dist || rm -rf dist",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.17.2",
|
|
29
|
+
"axios": "^1.7.7",
|
|
30
|
+
"dotenv": "^16.6.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@biomejs/biome": "^2.3.10",
|
|
34
|
+
"@types/node": "^22.0.0",
|
|
35
|
+
"tsx": "^4",
|
|
36
|
+
"typescript": "^5"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"author": "Oleksii Kyslytsia <oleksij.kyslytsja@gmail.com>",
|
|
40
|
+
"private": false,
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/fr0ster/cloud-llm-hub.git"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"llm",
|
|
50
|
+
"agent",
|
|
51
|
+
"mcp",
|
|
52
|
+
"model-context-protocol",
|
|
53
|
+
"sap-ai-core"
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18.0.0",
|
|
57
|
+
"npm": ">=9.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|