File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
+ import * as fs from "fs" ;
3
4
import { Client } from "@modelcontextprotocol/sdk/client/index.js" ;
4
5
import { Command } from "commander" ;
5
6
import {
@@ -31,8 +32,6 @@ type JsonValue =
31
32
| JsonValue [ ]
32
33
| { [ key : string ] : JsonValue } ;
33
34
34
- import packageJson from "../package.json" with { type : "json" } ;
35
-
36
35
type Args = {
37
36
target : string [ ] ;
38
37
method ?: string ;
@@ -101,6 +100,15 @@ function createTransportOptions(
101
100
}
102
101
103
102
async function callMethod ( args : Args ) : Promise < void > {
103
+ // Read package.json to get name and version for client identity
104
+ const pathA = "../package.json" ; // We're in package @modelcontextprotocol/inspector-cli
105
+ const pathB = "../../package.json" ; // We're in package @modelcontextprotocol/inspector
106
+ let packageJson : { name: string ; version: string } ;
107
+ let packageJsonData = await import ( fs . existsSync ( pathA ) ? pathA : pathB , {
108
+ with : { type : "json" } ,
109
+ } ) ;
110
+ packageJson = packageJsonData . default ;
111
+
104
112
const transportOptions = createTransportOptions (
105
113
args . target ,
106
114
args . transport ,
You can’t perform that action at this time.
0 commit comments