Simple Tool
π¨βπΌ Let's get your MCP server ready to support tools! In this step, you'll:
- Declare the
tools
capability on your server. - Register a simple tool named
add
that always returns the sum of 1 and 2 (hardcoded).
This is your first step toward making your server interactive and extensible. No
need to handle dynamic input yetβjust get the tool registered and returning a
static result.
As a reminder, here's an example of a tool:
server.registerTool(
'hello',
{
title: 'Hello',
description: 'Say hello',
},
async () => {
return {
content: [{ type: 'text', text: 'Hello, world!' }],
}
},
)