Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type JsonValue =
| JsonValue[]
| { [key: string]: JsonValue };

import packageJson from "../package.json" with { type: "json" };

type Args = {
target: string[];
method?: string;
Expand Down Expand Up @@ -105,10 +107,12 @@ async function callMethod(args: Args): Promise<void> {
args.headers,
);
const transport = createTransport(transportOptions);
const client = new Client({
name: "inspector-cli",
version: "0.5.1",
});

const [, name = packageJson.name] = packageJson.name.split("/");
const version = packageJson.version;
const clientIdentity = { name, version };

const client = new Client(clientIdentity);

try {
await connect(client, transport);
Expand Down
8 changes: 8 additions & 0 deletions client/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { InspectorConfig } from "./configurationTypes";
import packageJson from "../../package.json";

// Client identity for MCP connections
export const CLIENT_IDENTITY = (() => {
const [, name = packageJson.name] = packageJson.name.split("/");
const version = packageJson.version;
return { name, version };
})();

// OAuth-related session storage keys
export const SESSION_KEYS = {
Expand Down
6 changes: 3 additions & 3 deletions client/src/lib/hooks/__tests__/useConnection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { renderHook, act } from "@testing-library/react";
import { useConnection } from "../useConnection";
import { z } from "zod";
import { ClientRequest } from "@modelcontextprotocol/sdk/types.js";
import { DEFAULT_INSPECTOR_CONFIG } from "../../constants";
import { DEFAULT_INSPECTOR_CONFIG, CLIENT_IDENTITY } from "../../constants";
import {
SSEClientTransportOptions,
SseError,
Expand Down Expand Up @@ -251,8 +251,8 @@ describe("useConnection", () => {

expect(Client).toHaveBeenCalledWith(
expect.objectContaining({
name: "mcp-inspector",
version: expect.any(String),
name: CLIENT_IDENTITY.name,
version: CLIENT_IDENTITY.version,
}),
expect.objectContaining({
capabilities: expect.objectContaining({
Expand Down
26 changes: 12 additions & 14 deletions client/src/lib/hooks/useConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
import { useEffect, useState } from "react";
import { useToast } from "@/lib/hooks/useToast";
import { z } from "zod";
import { ConnectionStatus } from "../constants";
import { ConnectionStatus, CLIENT_IDENTITY } from "../constants";
import { Notification } from "../notificationTypes";
import {
auth,
Expand All @@ -47,7 +47,6 @@ import {
saveClientInformationToSessionStorage,
discoverScopes,
} from "../auth";
import packageJson from "../../../package.json";
import {
getMCPProxyAddress,
getMCPServerRequestMaxTotalTimeout,
Expand Down Expand Up @@ -364,20 +363,19 @@ export function useConnection({
};

const connect = async (_e?: unknown, retryCount: number = 0) => {
const client = new Client<Request, Notification, Result>(
{
name: "mcp-inspector",
version: packageJson.version,
},
{
capabilities: {
sampling: {},
elicitation: {},
roots: {
listChanged: true,
},
const clientCapabilities = {
capabilities: {
sampling: {},
elicitation: {},
roots: {
listChanged: true,
},
},
};

const client = new Client<Request, Notification, Result>(
CLIENT_IDENTITY,
clientCapabilities,
);

// Only check proxy health for proxy connections
Expand Down
Loading