inspector icon indicating copy to clipboard operation
inspector copied to clipboard

ReferenceError: AbortController is not defined

Open LuisValgoi opened this issue 8 months ago • 1 comments

Describe the bug npx @modelcontextprotocol/inspector does not work

To Reproduce

package.json

{
  "name": "mcp-quickstart",
  "version": "1.0.0",
  "description": "A quick start example of Model Context Protocol",
  "type": "module",
  "main": "dist/server.js",
  "scripts": {
    "start": "ts-node --esm src/server.ts",
    "build": "tsc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@modelcontextprotocol/sdk": "^1.9.0",
    "@types/node": "^22.14.1",
    "ts-node": "^10.9.2",
    "typescript": "^5.8.3",
    "zod": "^3.24.2"
  }
} 

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "esnext",
    "moduleResolution": "node",
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
} 

server.ts

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from 'zod';

// Create a new MCP server instance
const server = new McpServer({
  name: 'Echo Server',
  version: '1.0.0',
});

// Register a simple echo tool
server.tool(
  'echo',
  {
    message: z.string().describe('The message to echo back'),
  },
  async ({ message }) => {
    console.log('Received message:', message);
    return {
      content: [
        {
          type: 'text',
          text: `Echo: ${message}`,
        },
      ],
    };
  }
);

const transport = new StdioServerTransport();
await server.connect(transport);

command executed

npx @modelcontextprotocol/inspector node /Users/luisvalgoi/.../mcp-quickstart/dist/server.js

Expected behavior

  • To work

Logs

mcp-quickstart npx @modelcontextprotocol/inspector node /Users/luisvalgoi/.../mcp-quickstart/dist/server.js
npx: installed 232 in 10.011s
Starting MCP inspector...
ReferenceError: AbortController is not defined
    at main (file:///Users/luisvalgoi/.npm/_npx/31517/lib/node_modules/@modelcontextprotocol/inspector/bin/cli.js:69:17)
    at file:///Users/luisvalgoi/.npm/_npx/31517/lib/node_modules/@modelcontextprotocol/inspector/bin/cli.js:115:1
    at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
    at async Loader.import (internal/modules/esm/loader.js:178:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)

LuisValgoi avatar Apr 13 '25 19:04 LuisValgoi

Hi @LuisValgoi could you add what version of Node you're using?

olaservo avatar Apr 15 '25 14:04 olaservo

@LuisValgoi I'm going to close this since I believe this is an issue with your node version and not Inspector itself, but feel free to re-open if you're still having this issue and can provide a few more details about your node environment.

olaservo avatar May 11 '25 13:05 olaservo

I was getting this error using node v14.21.3. Updating it (to v22.11.0) solved the error,

henriqueholtz avatar May 30 '25 21:05 henriqueholtz