-
Notifications
You must be signed in to change notification settings - Fork 218
Open
Description
Hi, I used python version of fastmcp a lot, and the python code is simple and clean. How about rewrite the following code to use decorators and doc comments.
server.addTool({
name: "add",
description: "Add two numbers",
parameters: z.object({
a: z.number(),
b: z.number(),
}),
execute: async (args) => {
return String(args.a + args.b);
},
});
Version 1:
@server.tool({
name: "add",
description: "Add two numbers",
parameters: z.object({
a: z.number(),
b: z.number(),
}),
})
async function add(a: number, b: number) {
return a + b;
};
Version 2:
/**
* add two numbers
* @param a First number
* @param b Second number
* @returns addition of a and b
*/
@server.tool()
async function add(a: number, b: number) {
return a + b;
};
Here is python version of code.
@mcp.tool
def add(a: float, b: float) -> float:
"""add two numbers."""
return a + b
Metadata
Metadata
Assignees
Labels
No labels