mirror of
https://github.com/chaitin/SafeLine.git
synced 2026-01-31 22:04:02 +08:00
1.1 KiB
1.1 KiB
mcp_server - A SafeLine WAF mcp server
- Easy to use
- one command to run mcp_server
- Easy to develop
- add yoor own tools to
toolsdirctory without modify other files
- add yoor own tools to
quick start
docker compose -f docker-compose.yaml up -d
custom your own tool
Hello Tool Example
This tool used to say hello to someone
- create file
tools/hello.py
from pydantic import BaseModel, Field
from tools import Tool, ABCTool, tools
# register to global tools
@tools.register
# Hello describe function paramters
class Hello(BaseModel, ABCTool):
# tools paramters
name: str = Field(description="username to say hello")
# run is tool logic, must use classmethod
@classmethod
async def run(arguments: dict) -> str:
req = Hello.model_validate(arguments)
return f"Hello {req.name}"
# tool description, must use classmethod
@classmethod
def tool(self) -> Tool:
return Tool(
name="hello",
description="say hello to someone",
inputSchema=self.model_json_schema()
)