Skip to content

Commit 4aba6c5

Browse files
committed
new api
1 parent a00a5df commit 4aba6c5

File tree

94 files changed

+3826
-1843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3826
-1843
lines changed

exercises/01.ping/01.problem.connect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@epic-web/invariant": "^1.0.0",
14-
"@modelcontextprotocol/sdk": "^1.13.0",
14+
"@modelcontextprotocol/sdk": "npm:@kentcdodds/tmp-modelcontextprotocol_sdk@1.13.1-alpha.0",
1515
"zod": "^3.25.67"
1616
},
1717
"devDependencies": {

exercises/01.ping/01.solution.connect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@epic-web/invariant": "^1.0.0",
14-
"@modelcontextprotocol/sdk": "^1.13.0",
14+
"@modelcontextprotocol/sdk": "npm:@kentcdodds/tmp-modelcontextprotocol_sdk@1.13.1-alpha.0",
1515
"zod": "^3.25.67"
1616
},
1717
"devDependencies": {

exercises/02.tools/01.problem.simple/README.mdx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@ static result.
1313
As a reminder, here's an example of a tool:
1414

1515
```ts
16-
server.tool('hello', 'Say hello', async () => {
17-
return {
18-
content: [{ type: 'text', text: 'Hello, world!' }],
19-
}
20-
})
16+
server.registerTool(
17+
'hello',
18+
{
19+
title: 'Hello',
20+
description: 'Say hello',
21+
},
22+
async () => {
23+
return {
24+
content: [{ type: 'text', text: 'Hello, world!' }],
25+
}
26+
},
27+
)
2128
```

exercises/02.tools/01.problem.simple/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@epic-web/invariant": "^1.0.0",
14-
"@modelcontextprotocol/sdk": "^1.13.0",
14+
"@modelcontextprotocol/sdk": "npm:@kentcdodds/tmp-modelcontextprotocol_sdk@1.13.1-alpha.0",
1515
"zod": "^3.25.67"
1616
},
1717
"devDependencies": {

exercises/02.tools/01.problem.simple/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const server = new McpServer(
1212
},
1313
)
1414

15-
// 🐨 add a tool to the server with the server.tool API
15+
// 🐨 add a tool to the server with the server.registerTool API
1616
// - the name should be 'add'
17-
// - the description should explain what it can be used to do (add one and two)
17+
// - the config object should include a user-facing title and an llm-facing description explaining what it can be used to do (add one and two)
1818
// - the callback should return a standard text response that says "one and two equals three"
1919

2020
async function main() {

exercises/02.tools/01.solution.simple/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@epic-web/invariant": "^1.0.0",
14-
"@modelcontextprotocol/sdk": "^1.13.0",
14+
"@modelcontextprotocol/sdk": "npm:@kentcdodds/tmp-modelcontextprotocol_sdk@1.13.1-alpha.0",
1515
"zod": "^3.25.67"
1616
},
1717
"devDependencies": {

exercises/02.tools/01.solution.simple/src/index.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ const server = new McpServer(
1414
},
1515
)
1616

17-
server.tool('add', 'Add one and two', async () => {
18-
return {
19-
content: [
20-
{
21-
type: 'text',
22-
text: `The sum of 1 and 2 is 3.`,
23-
},
24-
],
25-
}
26-
})
17+
server.registerTool(
18+
'add',
19+
{
20+
title: 'Add',
21+
description: 'Add one and two',
22+
},
23+
async () => {
24+
return {
25+
content: [
26+
{
27+
type: 'text',
28+
text: `The sum of 1 and 2 is 3.`,
29+
},
30+
],
31+
}
32+
},
33+
)
2734

2835
async function main() {
2936
const transport = new StdioServerTransport()

exercises/02.tools/02.problem.args/README.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ Here's a quick example of a tool with arguments.
1414
```ts
1515
import { z } from 'zod'
1616

17-
server.tool(
17+
server.registerTool(
1818
'hello',
19-
'Say hello to someone',
20-
{ name: z.string().describe('The name to greet') },
19+
{
20+
title: 'Hello',
21+
description: 'Say hello to someone',
22+
// llm-facing input schema (the description is for the llm)
23+
inputSchema: { name: z.string().describe('The name to greet') },
24+
},
2125
async ({ name }) => {
2226
return {
2327
content: [{ type: 'text', text: `Hello, ${name}!` }],

exercises/02.tools/02.problem.args/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@epic-web/invariant": "^1.0.0",
14-
"@modelcontextprotocol/sdk": "^1.13.0",
14+
"@modelcontextprotocol/sdk": "npm:@kentcdodds/tmp-modelcontextprotocol_sdk@1.13.1-alpha.0",
1515
"zod": "^3.25.67"
1616
},
1717
"devDependencies": {

exercises/02.tools/02.problem.args/src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ const server = new McpServer(
1414
},
1515
)
1616

17-
server.tool(
17+
server.registerTool(
1818
'add',
19-
// 🐨 update the description to indicate this adds any two numbers
20-
'Add one and two',
21-
// 🐨 add an object with a firstNumber and secondNumber property
22-
// 📜 These should be zod schemas https://zod.dev/
19+
{
20+
title: 'Add',
21+
// 🐨 update the description to indicate this adds any two numbers
22+
description: 'Add one and two',
23+
// 🐨 add an inputSchema object with a firstNumber and secondNumber property
24+
// 📜 These should be zod schemas https://zod.dev/
25+
// 💯 add descriptions for the llm to know what they're for
26+
},
27+
// 🐨 accept an object parameter with a firstNumber and secondNumber property
2328
async () => {
24-
// 🐨 accept an object parameter with a firstNumber and secondNumber property
2529
return {
2630
content: [
2731
{

0 commit comments

Comments
 (0)