File tree Expand file tree Collapse file tree 4 files changed +31
-21
lines changed Expand file tree Collapse file tree 4 files changed +31
-21
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ type JsonValue =
31
31
| JsonValue [ ]
32
32
| { [ key : string ] : JsonValue } ;
33
33
34
+ import packageJson from "../package.json" with { type : "json" } ;
35
+
34
36
type Args = {
35
37
target : string [ ] ;
36
38
method ?: string ;
@@ -105,10 +107,12 @@ async function callMethod(args: Args): Promise<void> {
105
107
args . headers ,
106
108
) ;
107
109
const transport = createTransport ( transportOptions ) ;
108
- const client = new Client ( {
109
- name : "inspector-cli" ,
110
- version : "0.5.1" ,
111
- } ) ;
110
+
111
+ const [ , name = packageJson . name ] = packageJson . name . split ( "/" ) ;
112
+ const version = packageJson . version ;
113
+ const clientIdentity = { name, version } ;
114
+
115
+ const client = new Client ( clientIdentity ) ;
112
116
113
117
try {
114
118
await connect ( client , transport ) ;
Original file line number Diff line number Diff line change 1
1
import { InspectorConfig } from "./configurationTypes" ;
2
+ import packageJson from "../../package.json" ;
3
+
4
+ // Client identity for MCP connections
5
+ export const CLIENT_IDENTITY = ( ( ) => {
6
+ const [ , name = packageJson . name ] = packageJson . name . split ( "/" ) ;
7
+ const version = packageJson . version ;
8
+ return { name, version } ;
9
+ } ) ( ) ;
2
10
3
11
// OAuth-related session storage keys
4
12
export const SESSION_KEYS = {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { renderHook, act } from "@testing-library/react";
2
2
import { useConnection } from "../useConnection" ;
3
3
import { z } from "zod" ;
4
4
import { ClientRequest } from "@modelcontextprotocol/sdk/types.js" ;
5
- import { DEFAULT_INSPECTOR_CONFIG } from "../../constants" ;
5
+ import { DEFAULT_INSPECTOR_CONFIG , CLIENT_IDENTITY } from "../../constants" ;
6
6
import {
7
7
SSEClientTransportOptions ,
8
8
SseError ,
@@ -251,8 +251,8 @@ describe("useConnection", () => {
251
251
252
252
expect ( Client ) . toHaveBeenCalledWith (
253
253
expect . objectContaining ( {
254
- name : "mcp-inspector" ,
255
- version : expect . any ( String ) ,
254
+ name : CLIENT_IDENTITY . name ,
255
+ version : CLIENT_IDENTITY . version ,
256
256
} ) ,
257
257
expect . objectContaining ( {
258
258
capabilities : expect . objectContaining ( {
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
35
35
import { useEffect , useState } from "react" ;
36
36
import { useToast } from "@/lib/hooks/useToast" ;
37
37
import { z } from "zod" ;
38
- import { ConnectionStatus } from "../constants" ;
38
+ import { ConnectionStatus , CLIENT_IDENTITY } from "../constants" ;
39
39
import { Notification } from "../notificationTypes" ;
40
40
import {
41
41
auth ,
@@ -47,7 +47,6 @@ import {
47
47
saveClientInformationToSessionStorage ,
48
48
discoverScopes ,
49
49
} from "../auth" ;
50
- import packageJson from "../../../package.json" ;
51
50
import {
52
51
getMCPProxyAddress ,
53
52
getMCPServerRequestMaxTotalTimeout ,
@@ -364,20 +363,19 @@ export function useConnection({
364
363
} ;
365
364
366
365
const connect = async ( _e ?: unknown , retryCount : number = 0 ) => {
367
- const client = new Client < Request , Notification , Result > (
368
- {
369
- name : "mcp-inspector" ,
370
- version : packageJson . version ,
371
- } ,
372
- {
373
- capabilities : {
374
- sampling : { } ,
375
- elicitation : { } ,
376
- roots : {
377
- listChanged : true ,
378
- } ,
366
+ const clientCapabilities = {
367
+ capabilities : {
368
+ sampling : { } ,
369
+ elicitation : { } ,
370
+ roots : {
371
+ listChanged : true ,
379
372
} ,
380
373
} ,
374
+ } ;
375
+
376
+ const client = new Client < Request , Notification , Result > (
377
+ CLIENT_IDENTITY ,
378
+ clientCapabilities ,
381
379
) ;
382
380
383
381
// Only check proxy health for proxy connections
You can’t perform that action at this time.
0 commit comments