Files
SafeLine/mcp_server/tools/__init__.py
2025-04-03 14:33:17 +08:00

18 lines
441 B
Python

from mcp.types import Tool
from typing import Callable
ALL_TOOLS = []
TOOL_FUNC_MAP = {}
def register_tool(tool: Tool, func: Callable):
ALL_TOOLS.append(tool)
TOOL_FUNC_MAP[tool.name] = func
async def run(name:str, arguments:dict) -> str:
if name not in TOOL_FUNC_MAP:
return f"Unknown tool: {name}"
return await TOOL_FUNC_MAP[name](arguments)
from . import create_black_custom_rule, create_http_application