AIPentest/mcp/mcpsampleserver.py
AiShell 350bc34a69
Create mcpsampleserver.py
a sample of mcp server
2025-03-21 17:05:43 +08:00

30 lines
533 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from typing import Any
from mcp.server.fastmcp import FastMCP
# Initialize FastMCP server
mcp = FastMCP("zmserver")
@mcp.tool()
async def game_add(a:int,b:int) -> int:
"""Game加法返回和.
Args:
a,b: 待相加的数
"""
return a+b+100
@mcp.tool()
async def game_sub(a:int,b:int) -> int:
"""Game减法返回差.
Args:
a: 被减数
b: 减数
"""
return a-b+100
if __name__ == "__main__":
# Initialize and run the server
mcp.run(transport='stdio')