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 =
3131 | JsonValue [ ]
3232 | { [ key : string ] : JsonValue } ;
3333
34+ import packageJson from "../package.json" with { type : "json" } ;
35+
3436type Args = {
3537 target : string [ ] ;
3638 method ?: string ;
@@ -105,10 +107,12 @@ async function callMethod(args: Args): Promise<void> {
105107 args . headers ,
106108 ) ;
107109 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 ) ;
112116
113117 try {
114118 await connect ( client , transport ) ;
Original file line number Diff line number Diff line change 11import { 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+ } ) ( ) ;
210
311// OAuth-related session storage keys
412export const SESSION_KEYS = {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { renderHook, act } from "@testing-library/react";
22import { useConnection } from "../useConnection" ;
33import { z } from "zod" ;
44import { ClientRequest } from "@modelcontextprotocol/sdk/types.js" ;
5- import { DEFAULT_INSPECTOR_CONFIG } from "../../constants" ;
5+ import { DEFAULT_INSPECTOR_CONFIG , CLIENT_IDENTITY } from "../../constants" ;
66import {
77 SSEClientTransportOptions ,
88 SseError ,
@@ -251,8 +251,8 @@ describe("useConnection", () => {
251251
252252 expect ( Client ) . toHaveBeenCalledWith (
253253 expect . objectContaining ( {
254- name : "mcp-inspector" ,
255- version : expect . any ( String ) ,
254+ name : CLIENT_IDENTITY . name ,
255+ version : CLIENT_IDENTITY . version ,
256256 } ) ,
257257 expect . objectContaining ( {
258258 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";
3535import { useEffect , useState } from "react" ;
3636import { useToast } from "@/lib/hooks/useToast" ;
3737import { z } from "zod" ;
38- import { ConnectionStatus } from "../constants" ;
38+ import { ConnectionStatus , CLIENT_IDENTITY } from "../constants" ;
3939import { Notification } from "../notificationTypes" ;
4040import {
4141 auth ,
@@ -47,7 +47,6 @@ import {
4747 saveClientInformationToSessionStorage ,
4848 discoverScopes ,
4949} from "../auth" ;
50- import packageJson from "../../../package.json" ;
5150import {
5251 getMCPProxyAddress ,
5352 getMCPServerRequestMaxTotalTimeout ,
@@ -364,20 +363,19 @@ export function useConnection({
364363 } ;
365364
366365 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 ,
379372 } ,
380373 } ,
374+ } ;
375+
376+ const client = new Client < Request , Notification , Result > (
377+ CLIENT_IDENTITY ,
378+ clientCapabilities ,
381379 ) ;
382380
383381 // Only check proxy health for proxy connections
You can’t perform that action at this time.
0 commit comments