npm init -y --> creates package json npm install @modelcontextprotocol/sdk zod@3 -- install mcp sdk and zod for data validation mkdir src --> makes src folder touch src/index.ts --> makes index.ts file
****replace package.json content bby this --> this will create module format and add scriot for build { "name": "mcpserver", "version": "1.0.0", "description": "", "type": "module", "main": "index.js", "bin": { "weather": "./build/index.js" }, "scripts": { "test": "echo "Error: no test specified" && exit 1", "build": "tsc && chmod 755 build/index.js" }, "files": [ "build" ], "keywords": [], "author": "", "license": "ISC", "dependencies": { "@modelcontextprotocol/sdk": "^1.22.0", "install": "^0.13.0", "pm": "^2.2.6", "zod": "^3.25.76" } }
****Create a tsconfig.json in the root of your project:
then npm install --save-dev @types/node npm install -g typescript npm run build node build/index.js
then to connect to claude desktop go to terminal and paste this open ~/Library/Application\ Support/Claude/claude_desktop_config.json then you will see your config json, but go to thid folder and paste { "mcpServers": { "weather-server": { "command": "node", "args": ["/Users--> path to your index.js file and close it with /"] } } } save it now you can restart claude desktop and can see your mcp server then chat on claude desktop and ask it to fetch weather data by city name or by latitude and longitude
after getting the gitrepo: git clone (thisrepourl) npm install npm run build node build/index.js
This server cannot be installed