@modelcontextprotocol/inspector 0.1.7 → 0.2.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/README.md +8 -15
- package/client/dist/assets/index-Ch18HgOq.js +190 -0
- package/client/dist/assets/{index-DJlejpJa.css → index-DSYhznMv.css} +1 -1
- package/client/dist/index.html +2 -2
- package/package.json +6 -5
- package/server/build/index.js +18 -2
- package/client/dist/assets/index-CfHoM4KT.js +0 -195
- package/server/build/client.js +0 -76
package/server/build/client.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Client } from "mcp-typescript/client/index.js";
|
|
2
|
-
import { SSEClientTransport } from "mcp-typescript/client/sse.js";
|
|
3
|
-
import { StdioClientTransport } from "mcp-typescript/client/stdio.js";
|
|
4
|
-
import { ListResourcesResultSchema, ReadResourceResultSchema, ListPromptsResultSchema, GetPromptResultSchema, ListToolsResultSchema, CallToolResultSchema, } from "mcp-typescript/types.js";
|
|
5
|
-
export class McpClient {
|
|
6
|
-
client;
|
|
7
|
-
transport;
|
|
8
|
-
constructor(name, version) {
|
|
9
|
-
this.client = new Client({
|
|
10
|
-
name,
|
|
11
|
-
version,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
async connect(url) {
|
|
15
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
16
|
-
if (urlObj.protocol === "http:" || urlObj.protocol === "https:") {
|
|
17
|
-
this.transport = new SSEClientTransport();
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
throw new Error(`Unsupported protocol: ${urlObj.protocol}`);
|
|
21
|
-
}
|
|
22
|
-
await this.transport.connect(urlObj);
|
|
23
|
-
await this.client.connect(this.transport);
|
|
24
|
-
}
|
|
25
|
-
async connectStdio(command, args = []) {
|
|
26
|
-
this.transport = new StdioClientTransport();
|
|
27
|
-
await this.transport.spawn({ command, args });
|
|
28
|
-
await this.client.connect(this.transport);
|
|
29
|
-
}
|
|
30
|
-
async close() {
|
|
31
|
-
await this.client.close();
|
|
32
|
-
}
|
|
33
|
-
// Resource Operations
|
|
34
|
-
async listResources() {
|
|
35
|
-
return await this.client.request({
|
|
36
|
-
method: "resources/list",
|
|
37
|
-
}, ListResourcesResultSchema);
|
|
38
|
-
}
|
|
39
|
-
async readResource(params) {
|
|
40
|
-
return await this.client.request({
|
|
41
|
-
method: "resources/read",
|
|
42
|
-
params,
|
|
43
|
-
}, ReadResourceResultSchema);
|
|
44
|
-
}
|
|
45
|
-
// Prompt Operations
|
|
46
|
-
async listPrompts() {
|
|
47
|
-
return await this.client.request({
|
|
48
|
-
method: "prompts/list",
|
|
49
|
-
}, ListPromptsResultSchema);
|
|
50
|
-
}
|
|
51
|
-
async getPrompt(params) {
|
|
52
|
-
return await this.client.request({
|
|
53
|
-
method: "prompts/get",
|
|
54
|
-
params,
|
|
55
|
-
}, GetPromptResultSchema);
|
|
56
|
-
}
|
|
57
|
-
// Tool Operations
|
|
58
|
-
async listTools() {
|
|
59
|
-
return await this.client.request({
|
|
60
|
-
method: "tools/list",
|
|
61
|
-
}, ListToolsResultSchema);
|
|
62
|
-
}
|
|
63
|
-
async callTool(params) {
|
|
64
|
-
return await this.client.request({
|
|
65
|
-
method: "tools/call",
|
|
66
|
-
params,
|
|
67
|
-
}, CallToolResultSchema);
|
|
68
|
-
}
|
|
69
|
-
getServerCapabilities() {
|
|
70
|
-
return this.client.getServerCapabilities();
|
|
71
|
-
}
|
|
72
|
-
getServerVersion() {
|
|
73
|
-
return this.client.getServerVersion();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export default McpClient;
|