Arguments

Arguments
šŸ‘Øā€šŸ’¼ Time to make your tool dynamic! In this step, you'll:
  • Update your add tool to accept two arguments: firstNumber and secondNumber.
  • Use Zod to validate these arguments.
  • Return the sum of the two numbers provided by the client.
This will make your tool interactive and able to respond to user input.
Here's a quick example of a tool with arguments.
import { z } from 'zod'

server.registerTool(
	'hello',
	{
		title: 'Hello',
		description: 'Say hello to someone',
		// llm-facing input schema (the description is for the llm)
		inputSchema: { name: z.string().describe('The name to greet') },
	},
	async ({ name }) => {
		return {
			content: [{ type: 'text', text: `Hello, ${name}!` }],
		}
	},
)
Note the describe on the argument. This is optional, but very helpful for the LLM to understand the tool and where to get the arguments from.

Please set the playground first

Loading "Arguments"
Loading "Arguments"

Access Denied

You must login or register for the workshop to view the diff.

Check out this video to see how the diff tab works.

Epic Workshop Diff Tab Demo