@qverisai/sdk 0.1.2 → 0.2.0
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 +1 -1
- package/README.md +93 -216
- package/dist/client.d.ts +106 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +293 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +34 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -260
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +260 -62
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -2
- package/dist/types.js.map +1 -1
- package/package.json +53 -55
- package/dist/api/client.d.ts +0 -147
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -201
- package/dist/api/client.js.map +0 -1
- package/dist/tools/execute.d.ts +0 -89
- package/dist/tools/execute.d.ts.map +0 -1
- package/dist/tools/execute.js +0 -73
- package/dist/tools/execute.js.map +0 -1
- package/dist/tools/get-by-ids.d.ts +0 -69
- package/dist/tools/get-by-ids.d.ts.map +0 -1
- package/dist/tools/get-by-ids.js +0 -55
- package/dist/tools/get-by-ids.js.map +0 -1
- package/dist/tools/search.d.ts +0 -71
- package/dist/tools/search.d.ts.map +0 -1
- package/dist/tools/search.js +0 -53
- package/dist/tools/search.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,268 +1,20 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* QVeris TypeScript SDK.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* and execute third-party tools via natural language.
|
|
8
|
-
*
|
|
9
|
-
* @module @qverisai/sdk
|
|
10
|
-
* @version 0.1.0
|
|
4
|
+
* Typed client for the QVeris Agent External Data & Tool Harness:
|
|
5
|
+
* discover, inspect, call, plus usage and credits-ledger audit.
|
|
11
6
|
*
|
|
12
7
|
* @example
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* "command": "npx",
|
|
19
|
-
* "args": ["@qverisai/sdk"],
|
|
20
|
-
* "env": { "QVERIS_API_KEY": "your-api-key" }
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { Qveris } from '@qverisai/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const qveris = Qveris.fromEnv();
|
|
12
|
+
* const found = await qveris.discover('weather forecast API');
|
|
24
13
|
* ```
|
|
25
|
-
*/
|
|
26
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
27
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
28
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
29
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
30
|
-
import { createClientFromEnv } from './api/client.js';
|
|
31
|
-
import { searchToolsSchema, executeSearchTools, } from './tools/search.js';
|
|
32
|
-
import { executeToolSchema, executeExecuteTool, } from './tools/execute.js';
|
|
33
|
-
import { getToolsByIdsSchema, executeGetToolsByIds, } from './tools/get-by-ids.js';
|
|
34
|
-
// ============================================================================
|
|
35
|
-
// Server Configuration
|
|
36
|
-
// ============================================================================
|
|
37
|
-
const SERVER_NAME = 'qveris';
|
|
38
|
-
const SERVER_VERSION = '0.1.0';
|
|
39
|
-
/**
|
|
40
|
-
* Main entry point for the Qveris MCP Server.
|
|
41
14
|
*
|
|
42
|
-
*
|
|
43
|
-
* and execute_tool handlers, and starts listening for requests.
|
|
44
|
-
*/
|
|
45
|
-
async function main() {
|
|
46
|
-
// Initialize API client (validates QVERIS_API_KEY)
|
|
47
|
-
let client;
|
|
48
|
-
try {
|
|
49
|
-
client = createClientFromEnv();
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.error(error instanceof Error ? error.message : 'Failed to initialize Qveris client');
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
// Generate a default session ID for this server instance
|
|
56
|
-
const defaultSessionId = uuidv4();
|
|
57
|
-
// Create MCP server
|
|
58
|
-
const server = new Server({
|
|
59
|
-
name: SERVER_NAME,
|
|
60
|
-
version: SERVER_VERSION,
|
|
61
|
-
}, {
|
|
62
|
-
capabilities: {
|
|
63
|
-
tools: {},
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
// =========================================================================
|
|
67
|
-
// Tool Handlers
|
|
68
|
-
// =========================================================================
|
|
69
|
-
/**
|
|
70
|
-
* Lists available tools.
|
|
71
|
-
* Returns the search_tools, get_tools_by_ids, and execute_tool definitions.
|
|
72
|
-
*/
|
|
73
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
74
|
-
return {
|
|
75
|
-
tools: [
|
|
76
|
-
{
|
|
77
|
-
name: 'search_tools',
|
|
78
|
-
description: 'Search for available tools based on natural language queries. ' +
|
|
79
|
-
'Returns relevant tools that can help accomplish tasks. ' +
|
|
80
|
-
'Use this to discover tools before executing them.',
|
|
81
|
-
inputSchema: searchToolsSchema,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: 'get_tools_by_ids',
|
|
85
|
-
description: 'Get descriptions of tools based on their tool IDs. ' +
|
|
86
|
-
'Useful for retrieving detailed information about specific tools ' +
|
|
87
|
-
'when you already know their tool_ids from previous searches.',
|
|
88
|
-
inputSchema: getToolsByIdsSchema,
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: 'execute_tool',
|
|
92
|
-
description: 'Execute a specific remote tool with provided parameters. ' +
|
|
93
|
-
'The tool_id and search_id must come from a previous search_tools call. ' +
|
|
94
|
-
'Pass parameters to the tool through params_to_tool as a JSON string.',
|
|
95
|
-
inputSchema: executeToolSchema,
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
/**
|
|
101
|
-
* Handles tool execution requests.
|
|
102
|
-
* Routes to the appropriate handler based on tool name.
|
|
103
|
-
*/
|
|
104
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
105
|
-
const { name, arguments: args } = request.params;
|
|
106
|
-
try {
|
|
107
|
-
if (name === 'search_tools') {
|
|
108
|
-
const input = args;
|
|
109
|
-
// Validate required fields
|
|
110
|
-
if (!input.query || typeof input.query !== 'string') {
|
|
111
|
-
return {
|
|
112
|
-
content: [
|
|
113
|
-
{
|
|
114
|
-
type: 'text',
|
|
115
|
-
text: JSON.stringify({
|
|
116
|
-
error: 'Missing required parameter: query',
|
|
117
|
-
hint: 'Provide a natural language query describing the tool capability you need',
|
|
118
|
-
}),
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
isError: true,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
const result = await executeSearchTools(client, input, defaultSessionId);
|
|
125
|
-
return {
|
|
126
|
-
content: [
|
|
127
|
-
{
|
|
128
|
-
type: 'text',
|
|
129
|
-
text: JSON.stringify(result, null, 2),
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
if (name === 'get_tools_by_ids') {
|
|
135
|
-
const input = args;
|
|
136
|
-
// Validate required fields
|
|
137
|
-
if (!input.tool_ids || !Array.isArray(input.tool_ids) || input.tool_ids.length === 0) {
|
|
138
|
-
return {
|
|
139
|
-
content: [
|
|
140
|
-
{
|
|
141
|
-
type: 'text',
|
|
142
|
-
text: JSON.stringify({
|
|
143
|
-
error: 'Missing or invalid required parameter: tool_ids',
|
|
144
|
-
hint: 'Provide an array of tool IDs (at least one) to retrieve tool information',
|
|
145
|
-
}),
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
isError: true,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
const result = await executeGetToolsByIds(client, input, defaultSessionId);
|
|
152
|
-
return {
|
|
153
|
-
content: [
|
|
154
|
-
{
|
|
155
|
-
type: 'text',
|
|
156
|
-
text: JSON.stringify(result, null, 2),
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
if (name === 'execute_tool') {
|
|
162
|
-
const input = args;
|
|
163
|
-
// Validate required fields
|
|
164
|
-
const missingFields = [];
|
|
165
|
-
if (!input.tool_id)
|
|
166
|
-
missingFields.push('tool_id');
|
|
167
|
-
if (!input.search_id)
|
|
168
|
-
missingFields.push('search_id');
|
|
169
|
-
if (!input.params_to_tool)
|
|
170
|
-
missingFields.push('params_to_tool');
|
|
171
|
-
if (missingFields.length > 0) {
|
|
172
|
-
return {
|
|
173
|
-
content: [
|
|
174
|
-
{
|
|
175
|
-
type: 'text',
|
|
176
|
-
text: JSON.stringify({
|
|
177
|
-
error: `Missing required parameters: ${missingFields.join(', ')}`,
|
|
178
|
-
hint: 'tool_id and search_id must come from a previous search_tools call',
|
|
179
|
-
}),
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
isError: true,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
const result = await executeExecuteTool(client, input, defaultSessionId);
|
|
186
|
-
return {
|
|
187
|
-
content: [
|
|
188
|
-
{
|
|
189
|
-
type: 'text',
|
|
190
|
-
text: JSON.stringify(result, null, 2),
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
// Unknown tool
|
|
196
|
-
return {
|
|
197
|
-
content: [
|
|
198
|
-
{
|
|
199
|
-
type: 'text',
|
|
200
|
-
text: JSON.stringify({
|
|
201
|
-
error: `Unknown tool: ${name}`,
|
|
202
|
-
available_tools: ['search_tools', 'get_tools_by_ids', 'execute_tool'],
|
|
203
|
-
}),
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
isError: true,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
// Handle API errors
|
|
211
|
-
if (isApiError(error)) {
|
|
212
|
-
return {
|
|
213
|
-
content: [
|
|
214
|
-
{
|
|
215
|
-
type: 'text',
|
|
216
|
-
text: JSON.stringify({
|
|
217
|
-
error: error.message,
|
|
218
|
-
status: error.status,
|
|
219
|
-
details: error.details,
|
|
220
|
-
}),
|
|
221
|
-
},
|
|
222
|
-
],
|
|
223
|
-
isError: true,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
// Handle other errors (including fetch network errors)
|
|
227
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
228
|
-
const errorCause = error instanceof Error && error.cause instanceof Error
|
|
229
|
-
? error.cause.message
|
|
230
|
-
: undefined;
|
|
231
|
-
return {
|
|
232
|
-
content: [
|
|
233
|
-
{
|
|
234
|
-
type: 'text',
|
|
235
|
-
text: JSON.stringify({
|
|
236
|
-
error: errorMessage,
|
|
237
|
-
...(errorCause && { cause: errorCause }),
|
|
238
|
-
}),
|
|
239
|
-
},
|
|
240
|
-
],
|
|
241
|
-
isError: true,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
// =========================================================================
|
|
246
|
-
// Start Server
|
|
247
|
-
// =========================================================================
|
|
248
|
-
const transport = new StdioServerTransport();
|
|
249
|
-
await server.connect(transport);
|
|
250
|
-
// Log startup to stderr (stdout is reserved for MCP protocol)
|
|
251
|
-
console.error(`Qveris MCP Server v${SERVER_VERSION} started`);
|
|
252
|
-
console.error(`Session ID: ${defaultSessionId}`);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Type guard for API errors.
|
|
15
|
+
* @module @qverisai/sdk
|
|
256
16
|
*/
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
'status' in error &&
|
|
261
|
-
'message' in error);
|
|
262
|
-
}
|
|
263
|
-
// Run the server
|
|
264
|
-
main().catch((error) => {
|
|
265
|
-
console.error('Fatal error:', error);
|
|
266
|
-
process.exit(1);
|
|
267
|
-
});
|
|
17
|
+
export { Qveris } from './client.js';
|
|
18
|
+
export { QverisApiError } from './errors.js';
|
|
19
|
+
export * from './types.js';
|
|
268
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,cAAc,YAAY,CAAC"}
|