Skip to content

Commit b27928e

Browse files
committed
feat: add MCP server — 7 security tools over stdio, zero dependencies
Native MCP protocol implementation (JSON-RPC 2.0 over stdio) exposing ShellWard's 8-layer security engine as 7 MCP tools: check_command, check_injection, scan_data, check_path, check_tool, check_response, security_status. Works with Claude Desktop, Cursor, OpenClaw, and any MCP client. Includes 11 integration tests (123 total passing).
1 parent b2ad279 commit b27928e

File tree

4 files changed

+666
-12
lines changed

4 files changed

+666
-12
lines changed

README.md

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
[![npm](https://img.shields.io/npm/v/shellward?color=cb0000&label=npm)](https://www.npmjs.com/package/shellward)
1212
[![license](https://img.shields.io/badge/license-Apache--2.0-blue)](./LICENSE)
13-
[![tests](https://img.shields.io/badge/tests-112%20passing-brightgreen)](#performance)
13+
[![tests](https://img.shields.io/badge/tests-123%20passing-brightgreen)](#performance)
1414
[![deps](https://img.shields.io/badge/dependencies-0-brightgreen)](#performance)
1515

1616
[English](#demo) | [中文](#中文)
@@ -54,13 +54,15 @@ Your AI agent has full access to tools — shell, email, HTTP, file system. One
5454

5555
| Platform | Integration | Note |
5656
|----------|------------|------|
57-
| **OpenClaw** | Plugin + SDK | `openclaw plugins install shellward` — adapts to available hooks |
58-
| **Claude Code** | SDK | Anthropic's official CLI agent |
59-
| **Cursor** | SDK | AI-powered coding IDE |
57+
| **Claude Desktop** | MCP Server | Add to `claude_desktop_config.json` — 7 security tools |
58+
| **Cursor** | MCP Server | Add to `.cursor/mcp.json` |
59+
| **OpenClaw** | MCP + Plugin + SDK | `openclaw plugins install shellward` — adapts to available hooks |
60+
| **Claude Code** | MCP + SDK | Anthropic's official CLI agent |
6061
| **LangChain** | SDK | LLM application framework |
6162
| **AutoGPT** | SDK | Autonomous AI agents |
6263
| **OpenAI Agents** | SDK | GPT agent platform |
6364
| **Dify / Coze** | SDK | Low-code AI platforms |
65+
| **Any MCP Client** | MCP Server | stdio JSON-RPC, zero dependencies |
6466
| **Any AI Agent** | SDK | `npm install shellward` — 3 lines to integrate |
6567

6668
## Features
@@ -75,7 +77,59 @@ Your AI agent has full access to tools — shell, email, HTTP, file system. One
7577

7678
## Quick Start
7779

78-
**As SDK (any AI agent platform):**
80+
### As MCP Server
81+
82+
ShellWard runs as a standalone MCP server over stdio — zero dependencies, no `@modelcontextprotocol/sdk` needed.
83+
84+
**Claude Desktop / Cursor / any MCP client:**
85+
86+
Add to your MCP config (`claude_desktop_config.json`, `.cursor/mcp.json`, etc.):
87+
88+
```json
89+
{
90+
"mcpServers": {
91+
"shellward": {
92+
"command": "npx",
93+
"args": ["tsx", "/path/to/shellward/src/mcp-server.ts"]
94+
}
95+
}
96+
}
97+
```
98+
99+
**OpenClaw:**
100+
101+
```json
102+
{
103+
"mcpServers": {
104+
"shellward": {
105+
"command": "npx",
106+
"args": ["tsx", "/path/to/shellward/src/mcp-server.ts"]
107+
}
108+
}
109+
}
110+
```
111+
112+
**7 MCP tools available:**
113+
114+
| Tool | Description |
115+
|------|-------------|
116+
| `check_command` | Check if a shell command is safe (rm -rf, reverse shell, fork bomb...) |
117+
| `check_injection` | Detect prompt injection in text (32+ rules, zh+en) |
118+
| `scan_data` | Scan for PII & sensitive data (CN ID/phone/bank, API keys, SSN...) |
119+
| `check_path` | Check if file path operation is safe (.env, .ssh, credentials...) |
120+
| `check_tool` | Check if tool name is allowed (blocks payment/transfer tools) |
121+
| `check_response` | Audit AI response for canary leaks & PII exposure |
122+
| `security_status` | Get current security config & active layers |
123+
124+
**Environment variables:**
125+
126+
| Variable | Values | Default |
127+
|----------|--------|---------|
128+
| `SHELLWARD_MODE` | `enforce` / `audit` | `enforce` |
129+
| `SHELLWARD_LOCALE` | `auto` / `zh` / `en` | `auto` |
130+
| `SHELLWARD_THRESHOLD` | `0`-`100` | `60` |
131+
132+
### As SDK (any AI agent platform):
79133

80134
```bash
81135
npm install shellward
@@ -215,7 +269,7 @@ password: "MyP@ssw0rd!" → Detected (Password)
215269
| Command check throughput | 125,000/sec |
216270
| Injection detection throughput | ~7,700/sec |
217271
| Dependencies | 0 |
218-
| Tests | 112 passing |
272+
| Tests | 123 passing (incl. 11 MCP) |
219273

220274
## Vulnerability Database
221275

@@ -269,22 +323,45 @@ ShellWard is built for teams that need runtime security for AI agents — whethe
269323

270324
| 平台 | 集成方式 | 说明 |
271325
|------|---------|------|
272-
| **OpenClaw** | 插件 | `openclaw plugins install shellward`,开箱即用 |
273-
| **Claude Code** | SDK | Anthropic 官方 CLI Agent |
274-
| **Cursor** | SDK | AI 编程 IDE |
326+
| **Claude Desktop** | MCP 服务器 | 添加到 `claude_desktop_config.json`,7 个安全工具 |
327+
| **Cursor** | MCP 服务器 | 添加到 `.cursor/mcp.json` |
328+
| **OpenClaw** | MCP + 插件 + SDK | `openclaw plugins install shellward`,开箱即用 |
329+
| **Claude Code** | MCP + SDK | Anthropic 官方 CLI Agent |
275330
| **LangChain** | SDK | LLM 应用开发框架 |
276331
| **AutoGPT** | SDK | 自主 AI Agent |
277332
| **OpenAI Agents** | SDK | GPT Agent 平台 |
278333
| **Dify / Coze** | SDK | 低代码 AI 平台 |
334+
| **任意 MCP 客户端** | MCP 服务器 | stdio JSON-RPC,零依赖 |
279335
| **任意 AI Agent** | SDK | `npm install shellward`,3 行代码接入 |
280336

281337
### 安装
282338

339+
**MCP 服务器模式(推荐):**
340+
341+
在 MCP 配置中添加(适用于 Claude Desktop、Cursor、OpenClaw 等):
342+
343+
```json
344+
{
345+
"mcpServers": {
346+
"shellward": {
347+
"command": "npx",
348+
"args": ["tsx", "/path/to/shellward/src/mcp-server.ts"]
349+
}
350+
}
351+
}
352+
```
353+
354+
零依赖,原生实现 MCP 协议。提供 7 个安全工具:命令检查、注入检测、敏感数据扫描、路径保护、工具策略、响应审计、安全状态。
355+
356+
**OpenClaw 插件模式:**
357+
283358
```bash
284-
# OpenClaw 插件
285359
openclaw plugins install shellward
360+
```
361+
362+
**SDK 模式:**
286363

287-
# 或 SDK 模式
364+
```bash
288365
npm install shellward
289366
```
290367

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@
5151
},
5252
"scripts": {
5353
"build": "tsc",
54-
"test": "npx tsx test-sdk.ts && npx tsx test-integration.ts && npx tsx test-edge-cases.ts",
54+
"mcp": "npx tsx src/mcp-server.ts",
55+
"test": "npx tsx test-sdk.ts && npx tsx test-integration.ts && npx tsx test-edge-cases.ts && npx tsx test-mcp.ts",
5556
"test:integration": "npx tsx test-integration.ts",
5657
"test:edge": "npx tsx test-edge-cases.ts",
5758
"test:sdk": "npx tsx test-sdk.ts",
59+
"test:mcp": "npx tsx test-mcp.ts",
5860
"prepublishOnly": "npm run build"
5961
},
6062
"openclaw": {

0 commit comments

Comments
 (0)