Merge pull request #544 from richardkmichael/accurate-cli-version
fix: hard-coded CLI inspector version
This commit is contained in:
commit
42aa95b343
4 changed files with 31 additions and 21 deletions
|
|
@ -31,6 +31,8 @@ type JsonValue =
|
||||||
| JsonValue[]
|
| JsonValue[]
|
||||||
| { [key: string]: JsonValue };
|
| { [key: string]: JsonValue };
|
||||||
|
|
||||||
|
import packageJson from "../package.json" with { type: "json" };
|
||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
target: string[];
|
target: string[];
|
||||||
method?: string;
|
method?: string;
|
||||||
|
|
@ -105,10 +107,12 @@ async function callMethod(args: Args): Promise<void> {
|
||||||
args.headers,
|
args.headers,
|
||||||
);
|
);
|
||||||
const transport = createTransport(transportOptions);
|
const transport = createTransport(transportOptions);
|
||||||
const client = new Client({
|
|
||||||
name: "inspector-cli",
|
const [, name = packageJson.name] = packageJson.name.split("/");
|
||||||
version: "0.5.1",
|
const version = packageJson.version;
|
||||||
});
|
const clientIdentity = { name, version };
|
||||||
|
|
||||||
|
const client = new Client(clientIdentity);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await connect(client, transport);
|
await connect(client, transport);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,12 @@
|
||||||
import { InspectorConfig } from "./configurationTypes";
|
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
|
// OAuth-related session storage keys
|
||||||
export const SESSION_KEYS = {
|
export const SESSION_KEYS = {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { renderHook, act } from "@testing-library/react";
|
||||||
import { useConnection } from "../useConnection";
|
import { useConnection } from "../useConnection";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { ClientRequest } from "@modelcontextprotocol/sdk/types.js";
|
import { ClientRequest } from "@modelcontextprotocol/sdk/types.js";
|
||||||
import { DEFAULT_INSPECTOR_CONFIG } from "../../constants";
|
import { DEFAULT_INSPECTOR_CONFIG, CLIENT_IDENTITY } from "../../constants";
|
||||||
import {
|
import {
|
||||||
SSEClientTransportOptions,
|
SSEClientTransportOptions,
|
||||||
SseError,
|
SseError,
|
||||||
|
|
@ -251,8 +251,8 @@ describe("useConnection", () => {
|
||||||
|
|
||||||
expect(Client).toHaveBeenCalledWith(
|
expect(Client).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "mcp-inspector",
|
name: CLIENT_IDENTITY.name,
|
||||||
version: expect.any(String),
|
version: CLIENT_IDENTITY.version,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
capabilities: expect.objectContaining({
|
capabilities: expect.objectContaining({
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useToast } from "@/lib/hooks/useToast";
|
import { useToast } from "@/lib/hooks/useToast";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { ConnectionStatus } from "../constants";
|
import { ConnectionStatus, CLIENT_IDENTITY } from "../constants";
|
||||||
import { Notification } from "../notificationTypes";
|
import { Notification } from "../notificationTypes";
|
||||||
import {
|
import {
|
||||||
auth,
|
auth,
|
||||||
|
|
@ -47,7 +47,6 @@ import {
|
||||||
saveClientInformationToSessionStorage,
|
saveClientInformationToSessionStorage,
|
||||||
discoverScopes,
|
discoverScopes,
|
||||||
} from "../auth";
|
} from "../auth";
|
||||||
import packageJson from "../../../package.json";
|
|
||||||
import {
|
import {
|
||||||
getMCPProxyAddress,
|
getMCPProxyAddress,
|
||||||
getMCPServerRequestMaxTotalTimeout,
|
getMCPServerRequestMaxTotalTimeout,
|
||||||
|
|
@ -364,20 +363,19 @@ export function useConnection({
|
||||||
};
|
};
|
||||||
|
|
||||||
const connect = async (_e?: unknown, retryCount: number = 0) => {
|
const connect = async (_e?: unknown, retryCount: number = 0) => {
|
||||||
const client = new Client<Request, Notification, Result>(
|
const clientCapabilities = {
|
||||||
{
|
capabilities: {
|
||||||
name: "mcp-inspector",
|
sampling: {},
|
||||||
version: packageJson.version,
|
elicitation: {},
|
||||||
},
|
roots: {
|
||||||
{
|
listChanged: true,
|
||||||
capabilities: {
|
|
||||||
sampling: {},
|
|
||||||
elicitation: {},
|
|
||||||
roots: {
|
|
||||||
listChanged: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const client = new Client<Request, Notification, Result>(
|
||||||
|
CLIENT_IDENTITY,
|
||||||
|
clientCapabilities,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Only check proxy health for proxy connections
|
// Only check proxy health for proxy connections
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue