
Magicsword Mcp
io.github.magicsword-iov0.1.0更新于 Oct 7, 2026
Manage MagicSword endpoints, alerts, policies, and private intelligence through MCP.
概览
让助手通过对话管理 MagicSword 终端安全:列出终端、查询与处置告警、编辑策略并管理私有情报源。
- 功能
- 这是一个本地 stdio MCP 服务器,封装 MagicSword 客户 API。它提供 21 个工具,用于列出终端和代理版本、搜索告警与审计或拦截事件、处置告警、查看和编辑策略及其规则、预览并应用策略分配、将策略切换为强制模式、升级终端、请求终端签到、签发注册令牌,以及管理私有情报源和条目。写入类工具需要匹配的 API 权限范围,破坏性操作采用先预览后确认的流程。
- 适用场景
- 适用于已部署 MagicSword,并希望用 Claude Desktop、Cursor 等支持 MCP 的客户端在对话中查看终端、处置告警、审查事件或调整策略与情报的场景。主要面向 Enterprise 套餐组织;使用试点层级密钥时只会返回套餐限制提示,其他功能均不可用。
- 运行要求
- 需要 Node.js 22 或更高版本,通过 npm 安装 @magicsword-io/magicsword-mcp。需要从 Magic Portal 设置中获取的 MagicSword 客户 API 密钥(msk_...),可通过 MAGICSWORD_API_KEY 环境变量提供,或运行 configure 命令写入权限为 600 的 ~/.magicsword/mcp.json。需要访问所配置门户基础 URL 的网络,默认使用 HTTPS。写入类工具需要匹配的客户 API 权限范围,例如 alerts:write、policies:write、endpoints:write 或 intel:write。
安装
在 SourceWeft 中
- 打开 控制台中的 Magicsword Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
magicsword-mcp
A Model Context Protocol server for MagicSword. Lets users running Claude Desktop, Cursor, or any MCP-aware client manage MagicSword conversationally — list endpoints, query alerts, triage findings, mint enrollment tokens, and preview / commit policy changes.
The server is a thin, opinionated wrapper around the
/api/public/v1/* customer API exposed by the Magic Portal. It runs on
the user's machine, holds an msk_… API key, and speaks MCP over stdio.
Plan gate. The customer API is Enterprise-only. With a pilot-tier key the server returns a clear "this MagicSword org needs the Enterprise plan to use MCP" message; nothing else works until the org is upgraded.
Install
From npm
Requires Node 22+. After publication, MCP clients that consume the official
Registry can discover this server as
io.github.magicsword-io/magicsword-mcp. Homebrew, winget, and curl packaging
can follow if demand justifies maintaining signed platform artifacts.
Configure
You'll be prompted for an API key (mint one in Magic Portal → Settings →
API Keys) and a portal base URL (defaults to https://www.magicsword.io).
The command writes ~/.magicsword/mcp.json (mode 600) and prints the exact
JSON snippet to paste into Claude Desktop's config:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
The snippet looks like this:
Restart Claude Desktop and "magicsword" will appear with 21 tools. Logs are
at ~/Library/Logs/Claude/mcp*.log on macOS.
If you need a per-client override instead of ~/.magicsword/mcp.json, set
MAGICSWORD_API_KEY and optionally MAGICSWORD_BASE_URL in that MCP host's
environment. Keep API keys out of shared config snippets and screenshots.
Tools
Write tools require matching Customer API scopes in Magic Portal, such as
alerts:write, policies:write, endpoints:write, or intel:write.
Event review uses alerts:read; turning selected events into policy rules
uses policies:write.
Tools publish standard MCP safety annotations. Read-only discovery tools are marked read-only and idempotent; enforcement, deletion, policy assignment, rule changes, and agent upgrades are marked destructive so MCP clients can apply appropriate confirmation UX.
Example transcript
Configuration sources, in order of precedence
MAGICSWORD_API_KEY/MAGICSWORD_BASE_URLenv vars (set by the MCP host).~/.magicsword/mcp.json(or$MAGICSWORD_CONFIG).- Default base URL
https://www.magicsword.io.
Optional transport controls are MAGICSWORD_REQUEST_TIMEOUT_MS (default
30 seconds), MAGICSWORD_RESPONSE_MAX_BYTES (default 4 MiB), and
MAGICSWORD_GET_RETRIES (default 2, maximum 3). Only idempotent GET requests
are retried; write actions are never retried automatically.
Safety notes
flip_to_enforcingis two-step. The first call returns a server preview and one-time confirmation token; you must show the preview to a human and pass the token back to commit. Tokens are short-lived and single-use.- Fleet changes and deletion are explicit. Endpoint upgrades, policy
assignments, and private-intel deletion return a no-op preview unless the
approved follow-up call includes
confirm=true. - Windows WDAC policy edits should not use explicit flat file hashes.
Use
manage_policy_ruleswithevent_idswhen approving audit events so the Portal can derive supported path / publisher / filename rules, or useupsert_customer_intel_itemsfor hash, AuthentiHash, page-hash, and TBS intelligence in a private feed. - Secrets stay on the user's machine. The MCP server is a local stdio
process; the API key is read from
~/.magicsword/mcp.json(mode 600) or an env var passed by the MCP host. Nothing is sent off-machine except the requests to the configuredMAGICSWORD_BASE_URL. - Remote Portal URLs must use HTTPS. Plain HTTP is accepted only for localhost development. Configured URLs cannot contain credentials, paths, query strings, or fragments.
Develop
Tests validate --help, --version, configure validation, secret redaction,
modern and legacy MCP startup, focused mutation confirmation, retry and timeout
semantics, response-size bounds, malformed responses, write non-retry behavior,
and npm pack contents. test:package installs a production-only tarball and
checks the installed CLI and MCP tool discovery; release:verify checks all
release metadata. See docs/RELEASING.md for npm and MCP Registry releases.
来源:README.md,提交 981980f
工具
0版本历史
1- v0.1.0最新Oct 7, 2026

