Skip to content

Commit 3c0d5db

Browse files
committed
Replace deprecated servert.tool() intialization snippet in getting started example with server.registerTool()
1 parent 6e924e6 commit 3c0d5db

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

docs/docs/develop/build-server.mdx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,14 @@ The tool execution handler is responsible for actually executing the logic of ea
587587

588588
```typescript
589589
// Register weather tools
590-
server.tool(
590+
591+
server.registerTool(
591592
"get_alerts",
592-
"Get weather alerts for a state",
593593
{
594-
state: z.string().length(2).describe("Two-letter state code (e.g. CA, NY)"),
594+
description: "Get weather alerts for a state",
595+
inputSchema: {
596+
state: z.string().length(2).describe("Two-letter state code (e.g. CA, NY)"),
597+
}
595598
},
596599
async ({ state }) => {
597600
const stateCode = state.toUpperCase();
@@ -635,16 +638,14 @@ server.tool(
635638
},
636639
);
637640

638-
server.tool(
641+
server.registerTool(
639642
"get_forecast",
640-
"Get weather forecast for a location",
641643
{
642-
latitude: z.number().min(-90).max(90).describe("Latitude of the location"),
643-
longitude: z
644-
.number()
645-
.min(-180)
646-
.max(180)
647-
.describe("Longitude of the location"),
644+
description: "Get weather forecast for a location",
645+
inputSchema: {
646+
latitude: z.number().min(-90).max(90).describe("Latitude of the location"),
647+
longitude: z.number().min(-180).max(180).describe("Longitude of the location"),
648+
}
648649
},
649650
async ({ latitude, longitude }) => {
650651
// Get grid point data
@@ -721,7 +722,7 @@ server.tool(
721722
],
722723
};
723724
},
724-
);
725+
)
725726
```
726727

727728
### Running the server

0 commit comments

Comments
 (0)