Skip to content

Commit 6ceeae4

Browse files
authored
Merge pull request #1174 from dhsifss/feat/mcp
feat: add doc and rename
2 parents abd0427 + 1a80a5a commit 6ceeae4

19 files changed

+425
-21
lines changed
File renamed without changes.

mcp_server/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## mcp_server - A SafeLine WAF mcp server
2+
3+
- Easy to use
4+
- one command to run mcp_server
5+
- Easy to develop
6+
- add yoor own tools to `tools` dirctory without modify other files
7+
8+
### quick start
9+
10+
```shell
11+
docker compose -f docker-compose.yaml up -d
12+
```
13+
14+
### custom your own tool
15+
16+
#### Hello Tool Example
17+
18+
This tool used to say hello to someone
19+
20+
1. create file `tools/hello.py`
21+
22+
```python
23+
from pydantic import BaseModel, Field
24+
from tools import register_tool, Tool
25+
26+
# Hello describe function paramters
27+
class Hello(BaseModel):
28+
name: str = Field(description="username to say hello")
29+
30+
# hello is tool logic
31+
async def hello(arguments: dict) -> str:
32+
"""
33+
Say hello to someone
34+
"""
35+
return f"Hello {arguments['name']}"
36+
37+
# register tool to global variable
38+
register_tool(
39+
Tool(
40+
name="hello",
41+
description="say hello to someone",
42+
inputSchema=Hello.model_json_schema()
43+
),
44+
hello
45+
)
46+
```
47+
48+
2. import this tool in `tools/__init__.py`
49+
50+
```python
51+
from . import hello
52+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class Config:
99

1010
def __init__(self):
1111
self.SAFELINE_ADDRESS = os.getenv("SAFELINE_ADDRESS")
12+
if self.SAFELINE_ADDRESS:
13+
self.SAFELINE_ADDRESS = self.SAFELINE_ADDRESS.removesuffix("/")
1214
self.SAFELINE_API_TOKEN = os.getenv("SAFELINE_API_TOKEN")
1315
self.SECRET = os.getenv("SAFELINE_SECRET")
1416
env_listen_port = os.getenv("LISTEN_PORT")

mcp_server/docker-compose.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
mcp_server:
3+
image: chaitin/mcp_server:0.1
4+
container_name: mcp_server
5+
ports:
6+
- "5678:5678"
7+
environment:
8+
- SAFELINE_SECRET=your_secret_key # optional, if you want to use secret key to authenticate
9+
- SAFELINE_ADDRESS=https://your_safeline_ip:9443 # required, your SafeLine WAF address
10+
- SAFELINE_API_TOKEN=your_safeline_api_token # required, your SafeLine WAF api token
11+
- LISTEN_PORT=5678 # optional, default is 5678
12+
- LISTEN_ADDRESS=0.0.0.0 # optional, default is 0.0.0.0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
2-
name = "slmcp"
2+
name = "mcp_server"
33
version = "0.1.0"
4-
description = "Add your description here"
4+
description = "SafeLine WAF mcp server"
55
readme = "README.md"
66
requires-python = ">=3.13"
77
dependencies = [
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ idna==3.10
3333
markdown-it-py==3.0.0
3434
# via rich
3535
mcp==1.6.0
36-
# via slmcp (pyproject.toml)
36+
# via mcp_server (pyproject.toml)
3737
mdurl==0.1.2
3838
# via markdown-it-py
3939
pydantic==2.11.1

0 commit comments

Comments
 (0)