Skip to content
Merged
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: 10 additions & 2 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

import * as fs from "fs";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { Command } from "commander";
import {
Expand Down Expand Up @@ -31,8 +32,6 @@ type JsonValue =
| JsonValue[]
| { [key: string]: JsonValue };

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

type Args = {
target: string[];
method?: string;
Expand Down Expand Up @@ -101,6 +100,15 @@ function createTransportOptions(
}

async function callMethod(args: Args): Promise<void> {
// Read package.json to get name and version for client identity
const pathA = "../package.json"; // We're in package @modelcontextprotocol/inspector-cli
const pathB = "../../package.json"; // We're in package @modelcontextprotocol/inspector
let packageJson: { name: string; version: string };
let packageJsonData = await import(fs.existsSync(pathA) ? pathA : pathB, {
with: { type: "json" },
});
packageJson = packageJsonData.default;

const transportOptions = createTransportOptions(
args.target,
args.transport,
Expand Down
Loading