@inference-gateway/sdk 0.6.2 → 0.7.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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.7.1](https://github.com/inference-gateway/typescript-sdk/compare/v0.7.0...v0.7.1) (2025-05-27)
6
+
7
+ ### 🐛 Bug Fixes
8
+
9
+ * Allow additional properties in input schema for components ([2216600](https://github.com/inference-gateway/typescript-sdk/commit/22166007ec2704884a4f7a2c816d1bb0a6a95efe))
10
+
11
+ ### 🔧 Miscellaneous
12
+
13
+ * Enable GitHub Copilot and configure authentication ([e590786](https://github.com/inference-gateway/typescript-sdk/commit/e590786c2b3af5cb16ac7dda6dc7f9b0b7e7269c))
14
+
15
+ ## [0.7.0](https://github.com/inference-gateway/typescript-sdk/compare/v0.6.2...v0.7.0) (2025-05-26)
16
+
17
+ ### ✨ Features
18
+
19
+ * Implement MCP List Tools ([#13](https://github.com/inference-gateway/typescript-sdk/issues/13)) ([5c0a38c](https://github.com/inference-gateway/typescript-sdk/commit/5c0a38cbe825161c9d5dc1e15f59b31217aebb23))
20
+
5
21
  ## [0.6.2](https://github.com/inference-gateway/typescript-sdk/compare/v0.6.1...v0.6.2) (2025-04-30)
6
22
 
7
23
  ### ♻️ Improvements
package/README.md CHANGED
@@ -58,6 +58,32 @@ try {
58
58
  }
59
59
  ```
60
60
 
61
+ ### Listing MCP Tools
62
+
63
+ To list available Model Context Protocol (MCP) tools (only available when EXPOSE_MCP is enabled):
64
+
65
+ ```typescript
66
+ import { InferenceGatewayClient } from '@inference-gateway/sdk';
67
+
68
+ const client = new InferenceGatewayClient({
69
+ baseURL: 'http://localhost:8080/v1',
70
+ });
71
+
72
+ try {
73
+ const tools = await client.listTools();
74
+ console.log('Available MCP tools:', tools.data);
75
+
76
+ // Each tool has: name, description, server, and optional input_schema
77
+ tools.data.forEach((tool) => {
78
+ console.log(`Tool: ${tool.name}`);
79
+ console.log(`Description: ${tool.description}`);
80
+ console.log(`Server: ${tool.server}`);
81
+ });
82
+ } catch (error) {
83
+ console.error('Error:', error);
84
+ }
85
+ ```
86
+
61
87
  ### Creating Chat Completions
62
88
 
63
89
  To generate content using a model:
@@ -1,4 +1,4 @@
1
- import type { Provider, SchemaChatCompletionMessageToolCall, SchemaCompletionUsage, SchemaCreateChatCompletionRequest, SchemaCreateChatCompletionResponse, SchemaCreateChatCompletionStreamResponse, SchemaError, SchemaListModelsResponse } from './types/generated';
1
+ import type { Provider, SchemaChatCompletionMessageToolCall, SchemaCompletionUsage, SchemaCreateChatCompletionRequest, SchemaCreateChatCompletionResponse, SchemaCreateChatCompletionStreamResponse, SchemaError, SchemaListModelsResponse, SchemaListToolsResponse } from './types/generated';
2
2
  interface ChatCompletionStreamCallbacks {
3
3
  onOpen?: () => void;
4
4
  onChunk?: (chunk: SchemaCreateChatCompletionStreamResponse) => void;
@@ -37,6 +37,11 @@ export declare class InferenceGatewayClient {
37
37
  * Lists the currently available models.
38
38
  */
39
39
  listModels(provider?: Provider): Promise<SchemaListModelsResponse>;
40
+ /**
41
+ * Lists the currently available MCP tools.
42
+ * Only accessible when EXPOSE_MCP is enabled.
43
+ */
44
+ listTools(): Promise<SchemaListToolsResponse>;
40
45
  /**
41
46
  * Creates a chat completion.
42
47
  */
@@ -77,6 +77,15 @@ class InferenceGatewayClient {
77
77
  }
78
78
  return this.request('/models', { method: 'GET' }, query);
79
79
  }
80
+ /**
81
+ * Lists the currently available MCP tools.
82
+ * Only accessible when EXPOSE_MCP is enabled.
83
+ */
84
+ async listTools() {
85
+ return this.request('/mcp/tools', {
86
+ method: 'GET',
87
+ });
88
+ }
80
89
  /**
81
90
  * Creates a chat completion.
82
91
  */
@@ -47,6 +47,27 @@ export interface paths {
47
47
  patch?: never;
48
48
  trace?: never;
49
49
  };
50
+ '/mcp/tools': {
51
+ parameters: {
52
+ query?: never;
53
+ header?: never;
54
+ path?: never;
55
+ cookie?: never;
56
+ };
57
+ /**
58
+ * Lists the currently available MCP tools
59
+ * @description Lists the currently available MCP tools. Only accessible when EXPOSE_MCP is enabled.
60
+ *
61
+ */
62
+ get: operations['listTools'];
63
+ put?: never;
64
+ post?: never;
65
+ delete?: never;
66
+ options?: never;
67
+ head?: never;
68
+ patch?: never;
69
+ trace?: never;
70
+ };
50
71
  '/proxy/{provider}/{path}': {
51
72
  parameters: {
52
73
  query?: never;
@@ -218,6 +239,55 @@ export interface components {
218
239
  /** @default [] */
219
240
  data: components['schemas']['Model'][];
220
241
  };
242
+ /** @description Response structure for listing MCP tools */
243
+ ListToolsResponse: {
244
+ /**
245
+ * @description Always "list"
246
+ * @example list
247
+ */
248
+ object: string;
249
+ /**
250
+ * @description Array of available MCP tools
251
+ * @default []
252
+ */
253
+ data: components['schemas']['MCPTool'][];
254
+ };
255
+ /** @description An MCP tool definition */
256
+ MCPTool: {
257
+ /**
258
+ * @description The name of the tool
259
+ * @example read_file
260
+ */
261
+ name: string;
262
+ /**
263
+ * @description A description of what the tool does
264
+ * @example Read content from a file
265
+ */
266
+ description: string;
267
+ /**
268
+ * @description The MCP server that provides this tool
269
+ * @example http://mcp-filesystem-server:8083/mcp
270
+ */
271
+ server: string;
272
+ /**
273
+ * @description JSON schema for the tool's input parameters
274
+ * @example {
275
+ * "type": "object",
276
+ * "properties": {
277
+ * "file_path": {
278
+ * "type": "string",
279
+ * "description": "Path to the file to read"
280
+ * }
281
+ * },
282
+ * "required": [
283
+ * "file_path"
284
+ * ]
285
+ * }
286
+ */
287
+ input_schema?: {
288
+ [key: string]: unknown;
289
+ };
290
+ };
221
291
  FunctionObject: {
222
292
  /** @description A description of what the function does, used by the model to choose when and how to call the function. */
223
293
  description?: string;
@@ -458,6 +528,18 @@ export interface components {
458
528
  'application/json': components['schemas']['Error'];
459
529
  };
460
530
  };
531
+ /** @description MCP tools endpoint is not exposed */
532
+ MCPNotExposed: {
533
+ headers: {
534
+ [name: string]: unknown;
535
+ };
536
+ content: {
537
+ /** @example {
538
+ * "error": "MCP tools endpoint is not exposed. Set EXPOSE_MCP=true to enable."
539
+ * } */
540
+ 'application/json': components['schemas']['Error'];
541
+ };
542
+ };
461
543
  /** @description ProviderResponse depends on the specific provider and endpoint being called
462
544
  * If you decide to use this approach, please follow the provider-specific documentations.
463
545
  * */
@@ -513,6 +595,8 @@ export type SchemaMessageRole = components['schemas']['MessageRole'];
513
595
  export type SchemaMessage = components['schemas']['Message'];
514
596
  export type SchemaModel = components['schemas']['Model'];
515
597
  export type SchemaListModelsResponse = components['schemas']['ListModelsResponse'];
598
+ export type SchemaListToolsResponse = components['schemas']['ListToolsResponse'];
599
+ export type SchemaMcpTool = components['schemas']['MCPTool'];
516
600
  export type SchemaFunctionObject = components['schemas']['FunctionObject'];
517
601
  export type SchemaChatCompletionTool = components['schemas']['ChatCompletionTool'];
518
602
  export type SchemaFunctionParameters = components['schemas']['FunctionParameters'];
@@ -534,6 +618,7 @@ export type SchemaConfig = components['schemas']['Config'];
534
618
  export type ResponseBadRequest = components['responses']['BadRequest'];
535
619
  export type ResponseUnauthorized = components['responses']['Unauthorized'];
536
620
  export type ResponseInternalError = components['responses']['InternalError'];
621
+ export type ResponseMcpNotExposed = components['responses']['MCPNotExposed'];
537
622
  export type ResponseProviderResponse = components['responses']['ProviderResponse'];
538
623
  export type RequestBodyProviderRequest = components['requestBodies']['ProviderRequest'];
539
624
  export type RequestBodyCreateChatCompletionRequest = components['requestBodies']['CreateChatCompletionRequest'];
@@ -591,6 +676,29 @@ export interface operations {
591
676
  500: components['responses']['InternalError'];
592
677
  };
593
678
  };
679
+ listTools: {
680
+ parameters: {
681
+ query?: never;
682
+ header?: never;
683
+ path?: never;
684
+ cookie?: never;
685
+ };
686
+ requestBody?: never;
687
+ responses: {
688
+ /** @description Successful response */
689
+ 200: {
690
+ headers: {
691
+ [name: string]: unknown;
692
+ };
693
+ content: {
694
+ 'application/json': components['schemas']['ListToolsResponse'];
695
+ };
696
+ };
697
+ 401: components['responses']['Unauthorized'];
698
+ 403: components['responses']['MCPNotExposed'];
699
+ 500: components['responses']['InternalError'];
700
+ };
701
+ };
594
702
  proxyGet: {
595
703
  parameters: {
596
704
  query?: never;
@@ -82,6 +82,53 @@ describe('InferenceGatewayClient', () => {
82
82
  await expect(client.listModels(generated_1.Provider.openai)).rejects.toThrow(errorMessage);
83
83
  });
84
84
  });
85
+ describe('listTools', () => {
86
+ it('should fetch available MCP tools', async () => {
87
+ const mockResponse = {
88
+ object: 'list',
89
+ data: [
90
+ {
91
+ name: 'read_file',
92
+ description: 'Read content from a file',
93
+ server: 'http://mcp-filesystem-server:8083/mcp',
94
+ },
95
+ {
96
+ name: 'write_file',
97
+ description: 'Write content to a file',
98
+ server: 'http://mcp-filesystem-server:8083/mcp',
99
+ },
100
+ ],
101
+ };
102
+ mockFetch.mockResolvedValueOnce({
103
+ ok: true,
104
+ json: () => Promise.resolve(mockResponse),
105
+ });
106
+ const result = await client.listTools();
107
+ expect(result).toEqual(mockResponse);
108
+ expect(mockFetch).toHaveBeenCalledWith('http://localhost:8080/v1/mcp/tools', expect.objectContaining({
109
+ method: 'GET',
110
+ headers: expect.any(Headers),
111
+ }));
112
+ });
113
+ it('should throw error when MCP is not exposed', async () => {
114
+ const errorMessage = 'MCP not exposed';
115
+ mockFetch.mockResolvedValueOnce({
116
+ ok: false,
117
+ status: 403,
118
+ json: () => Promise.resolve({ error: errorMessage }),
119
+ });
120
+ await expect(client.listTools()).rejects.toThrow(errorMessage);
121
+ });
122
+ it('should throw error when unauthorized', async () => {
123
+ const errorMessage = 'Unauthorized';
124
+ mockFetch.mockResolvedValueOnce({
125
+ ok: false,
126
+ status: 401,
127
+ json: () => Promise.resolve({ error: errorMessage }),
128
+ });
129
+ await expect(client.listTools()).rejects.toThrow(errorMessage);
130
+ });
131
+ });
85
132
  describe('createChatCompletion', () => {
86
133
  it('should create a chat completion', async () => {
87
134
  const mockRequest = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inference-gateway/sdk",
3
- "version": "0.6.2",
3
+ "version": "0.7.1",
4
4
  "description": "An SDK written in Typescript for the [Inference Gateway](https://github.com/inference-gateway/inference-gateway).",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",