@@ -22,35 +22,17 @@ This guide uses the OpenWeatherMap API. You'll need a free API key from [OpenWea
22
22
</Step >
23
23
24
24
<Step title = " Create a new project" >
25
+ You can use our [ create-typescript-server] ( https://github.com/modelcontextprotocol/create-typescript-server ) tool to bootstrap a new project:
26
+
25
27
``` bash
26
- mkdir weather-server
28
+ npx @modelcontextprotocol/create-server weather-server
27
29
cd weather-server
28
- npm init -y
29
30
```
30
31
</Step >
31
32
32
33
<Step title = " Install dependencies" >
33
34
``` bash
34
- npm install @modelcontextprotocol/sdk axios dotenv typescript @types/node
35
- npm install --save-dev ts-node
36
- ```
37
- </Step >
38
-
39
- <Step title = " Configure TypeScript" >
40
- Create ` tsconfig.json ` :
41
- ```json
42
- {
43
- " compilerOptions" : {
44
- " target" : " ES2020" ,
45
- " module" : " ES2020" ,
46
- " moduleResolution" : " node" ,
47
- " esModuleInterop" : true ,
48
- " outDir" : " ./dist" ,
49
- " rootDir" : " ./src" ,
50
- " strict" : true
51
- },
52
- " include" : [" src/**/*" ]
53
- }
35
+ npm install --save axios dotenv
54
36
```
55
37
</Step >
56
38
@@ -65,16 +47,8 @@ This guide uses the OpenWeatherMap API. You'll need a free API key from [OpenWea
65
47
## Create your server
66
48
67
49
<Steps >
68
- <Step title = " Create project structure" >
69
- ``` bash
70
- mkdir src
71
- touch src/index.ts
72
- touch src/types.ts
73
- ```
74
- </Step >
75
-
76
50
<Step title = " Define types" >
77
- In ` src/ types.ts` :
51
+ Create a file ` types.ts ` , and add the following :
78
52
79
53
``` typescript
80
54
export interface OpenWeatherResponse {
@@ -124,7 +98,7 @@ This guide uses the OpenWeatherMap API. You'll need a free API key from [OpenWea
124
98
</Step >
125
99
126
100
<Step title = " Add the base code" >
127
- In ` src/ index.ts` :
101
+ Replace ` index.ts ` with the following :
128
102
129
103
``` typescript
130
104
import { Server } from " @modelcontextprotocol/sdk/server/index.js" ;
@@ -376,21 +350,9 @@ This guide uses the OpenWeatherMap API. You'll need a free API key from [OpenWea
376
350
</Step >
377
351
378
352
<Step title = " Build and test" >
379
- Add these scripts to ` package.json ` :
380
- ```json
381
- {
382
- " scripts" : {
383
- " build" : " tsc" ,
384
- " start" : " node dist/index.js" ,
385
- " dev" : " ts-node src/index.ts"
386
- }
387
- }
388
- ```
389
-
390
- Then run:
391
353
``` bash
392
354
npm run build
393
- npm install -g .
355
+ npm link
394
356
```
395
357
</Step >
396
358
</Steps >
@@ -628,4 +590,4 @@ npx tsc --noEmit
628
590
629
591
<Note >
630
592
Need help? Ask Claude! Since it has access to the MCP SDK documentation, it can help you debug issues and suggest improvements to your server.
631
- </Note >
593
+ </Note >
0 commit comments