forked from i-am-bee/beeai-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_tool.py
More file actions
25 lines (18 loc) · 773 Bytes
/
mcp_tool.py
File metadata and controls
25 lines (18 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from mcp.server.fastmcp.server import Settings
from beeai_framework.adapters.mcp.serve.server import MCPServer, MCPServerConfig
from beeai_framework.tools import tool
from beeai_framework.tools.types import StringToolOutput
from beeai_framework.tools.weather.openmeteo import OpenMeteoTool
@tool
def reverse_tool(word: str) -> StringToolOutput:
"""
A tool that reverses a word
"""
return StringToolOutput(result=word[::-1])
def main() -> None:
# create a MCP server with custom config, register ReverseTool and OpenMeteoTool to the MCP server and run it
MCPServer(config=MCPServerConfig(transport="sse", settings=Settings(port=8001))).register_many(
[reverse_tool, OpenMeteoTool()]
).serve()
if __name__ == "__main__":
main()