Skip to content

Running Model Context Protocol locally ​

Use this page to run the extracted MCP weather server on your computer and call its weather tool from MCP Inspector. Two things differ from what you may expect: the start script needs one tool the project forgot to list, and the server never opens a page of its own. It talks to whichever program starts it, through the terminal's input and output, so you test it with Inspector, which starts it for you and gives you a page to click through.

What you need first ​

Install Node.js 24, which includes npm. MCP Inspector needs Node 22.19 or newer, and Node 24 is comfortably past that.

Check the version. Yours may be newer:

bash
$ node --version
v24.18.0

You need no API key and no .env file: the weather data is written into the server's own code.

JunoWhat you need first Install Node 24 and check that node --version prints a version starting with 24 or higher. That is the whole list: no key, no .env file.
JunoWhat you need first The server itself would run on older Node versions. The version matters because the same Node also runs Inspector, the tool you test with, and Inspector's current release needs 22.19 or newer.
JunoWhat you need first On Node 22 releases before 22.19, npx does not refuse Inspector: it quietly picks the newest release that accepts that Node, the deprecated version 1. So the problem shows up as a different Inspector, not as an error.

Install the packages and add tsx ​

Open a terminal in the extracted project folder. It is the one containing package.json and server.ts:

bash
$ cd path-to-your-extracted-project

The project's start script runs tsx server.ts. tsx is the tool that runs a TypeScript file directly, but package.json does not list it, so a plain install leaves it out and npm start stops with sh: tsx: command not found. Install the listed packages, then add tsx:

bash
$ npm ci
added 91 packages, and audited 92 packages in 3s
…
$ npm install --save-dev tsx
added 3 packages, and audited 95 packages in 7s
…

npm may also report vulnerabilities and suggest npm audit fix. Leave them for now. It may also print a warning that begins npm warn allow-scripts and names esbuild; that does not stop tsx from working.

JunoInstall the packages and add tsx In the folder with package.json, run npm ci, then npm install --save-dev tsx. Each one reports how many packages it added.

If npm says it cannot find package.json, you are in the wrong folder.

JunoInstall the packages and add tsxnpm ci installs exactly what the shipped lockfile records, and tsx is not in it. --save-dev adds it to package.json and the lockfile, so the start script finds it in node_modules from now on.
JunoInstall the packages and add tsx Recording tsx in the project, not installing it globally, is what lets a desktop client start this server later with npm exec from any folder: the runner travels with the project instead of depending on someone's PATH.

Check that the server starts ​

Start the server once on its own:

bash
$ npm start

> [email protected] start
> tsx server.ts

🌤️  Weather MCP Server Started!
🛠️  Tool: getWeatherDataByCityName
📚 Resource: weather://cities
🏙️  Supported Cities: New York, London
✅ Server ready!

After Server ready! the terminal goes quiet. That is a working server: it is waiting for a program to send it a message, and it never prints an address to open. Stop it with Ctrl+C before you start Inspector.

JunoCheck that the server starts Run npm start and wait for Server ready!. Nothing else will happen, and nothing should: press Ctrl+C and move on to Inspector.
JunoCheck that the server starts An MCP server over standard input and output has no port. It reads requests from whatever program started it, so your terminal can start it but cannot talk to it. That is Inspector's job.
JunoCheck that the server starts The five status lines go to standard error on purpose: standard output is reserved for protocol messages, and a stray console.log there would break the connection to any client.

Call the weather tool in MCP Inspector ​

From the same project folder, run the official MCP Inspector, followed by the command that starts your server:

bash
$ npx @modelcontextprotocol/inspector npx tsx server.ts

The first time, npx asks before it downloads Inspector. Check that the package is @modelcontextprotocol/inspector, then type y:

text
Need to install the following packages:
@modelcontextprotocol/[email protected]
Ok to proceed? (y)

Inspector prints its address and opens it in your browser:

text
Starting MCP inspector...
…
MCP Inspector Web is up and running at:
   http://127.0.0.1:6274?MCP_INSPECTOR_API_TOKEN=…
…
Opening browser...

If no browser opens, copy the whole address, token included, into one.

The page lists one server, npx, marked Disconnected. Ignore the Read-only session note above it. Turn on the switch beside the server: Inspector starts your server and the label changes to Connected. Then:

  1. Open Tools at the top and select getWeatherDataByCityName.
  2. Type New York in the city field and click Execute Tool.
  3. The result appears under Results:
json
{
  "temp": "22°C",
  "forecast": "Partly cloudy with a breeze"
}

London works too. Any other city returns the course's Weather data not available for this city message, which is the tool working as written. The tool use chapter explains what a tool like this gives a model.

Resources lists weather://cities, but selecting it shows Read Error and Invalid URL. That comes from how the lesson's code registers the resource, not from your setup; the tool is the part to test.

When you are done, press Ctrl+C in the terminal. That stops Inspector and the server it started.

JunoCall the weather tool in MCP Inspector Run the Inspector command, type y if npx asks, and switch the server on in the page that opens. Then go to Tools, pick the weather tool, type New York and click Execute Tool.

If the label says Failed instead of Connected, open Inspector's Console tab on the right and look for the line starting Error.

JunoCall the weather tool in MCP Inspector Here Inspector is the client. Everything after its package name is the command it runs to start your server, so it starts tsx server.ts itself and talks to it through that process's input and output. The page is Inspector's own; your server still has none.
JunoCall the weather tool in MCP Inspector The resource fails because the SDK reads server.resource's arguments as name, address, then options. The lesson passes the address first and a description second, so the resource is listed under the name weather://cities with List of supported cities as its address, which is not a URL, and the read function never gets registered.

Connect another MCP client ​

A desktop MCP client starts the server too, but from its own working folder, so it needs full paths. Copy the absolute path of the extracted project folder, then give the client this command and these arguments, with both example paths replaced:

text
command: npm
arguments:
  - --prefix
  - /absolute/path/to/project
  - exec
  - --
  - tsx
  - /absolute/path/to/project/server.ts

--prefix tells npm which project's tsx to use, wherever the client starts from. Keep each argument as a separate item, so a path containing spaces stays one value, and add no URL or port.

Each client names these fields differently, so put the command and arguments where its MCP setup instructions say, then restart the client. You need no other download: this is the server you already tested. The agents chapter covers the loop a client runs when its model uses a tool like this one.

JunoConnect another MCP client Set the command to npm, add the six arguments with your project's path in both places, and restart the client.

The server already worked in Inspector, so if the client cannot reach it, check the paths in its settings first.

JunoConnect another MCP client The client runs the same server, but through npm --prefix, so the launch works from the client's own folder: --prefix picks the project, and exec -- tsx runs its server file.
JunoConnect another MCP client Desktop clients rarely inherit your terminal's PATH, so a bare tsx command works only where a global install happens to be visible. Going through npm --prefix ties the launch to the tsx recorded in this project. If the client says it cannot find npm, use the full path that which npm prints as the command.

Troubleshooting ​

npm start says sh: tsx: command not found: tsx is not installed in the project yet. Run npm install --save-dev tsx in the project folder. For a desktop client, also check that its command is npm and its arguments begin with --prefix and the project's absolute path.

Inspector says @modelcontextprotocol/inspector v1 is deprecated: Your Node is older than 22.19, so npx fetched the old Inspector. Install Node 24, open a new terminal, check node --version, and run the Inspector command again.

The server shows Failed, and Inspector's Console tab says Cannot find module ending in server.ts: Inspector was started outside the project folder. Stop it with Ctrl+C, cd into the folder that contains server.ts, and run the command again.

JunoTroubleshooting Match what you see to a bold heading above. When Inspector shows Failed, the reason is in its Console tab, not in your terminal.
JunoTroubleshooting Keep three steps apart: npm finding tsx, npx choosing an Inspector your Node can run, and Inspector starting your server. Each fails in a different place: the terminal, the terminal, then Inspector's Console tab.
JunoTroubleshooting Inspector collects the server's standard error in its Console tab, which is why a missing file or a crash at startup appears there while the terminal running Inspector stays quiet.