Magicsword Mcp

io.github.magicsword-iov0.1.0更新於 Oct 7, 2026

Manage MagicSword endpoints, alerts, policies, and private intelligence through MCP.

概覽

AI 產生的概覽

讓助手以對話方式管理 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。
安裝前請注意
API 金鑰屬於機密,不要放入共用設定片段或截圖。多個工具會修改或刪除資料:政策規則編輯、政策指派、flip_to_enforcing、端點升級、簽到、簽發註冊權杖,以及情報來源或項目刪除。破壞性操作會被標示,並要求先預覽再傳 confirm=true 或一次性權杖,核准前應檢視預覽。請求只會送往所設定的入口網站基礎 URL,除 localhost 外必須使用 HTTPS。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Magicsword Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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

sh
npm install -g @magicsword-io/magicsword-mcp

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

sh
magicsword-mcp 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:

json
{  "mcpServers": {    "magicsword": {      "command": "magicsword-mcp"    }  }}

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

ToolWhat it does
whoamiReturns organization, key id, and scopes. Always call first when troubleshooting.
list_endpointsLists endpoints with optional platform / status / hostname-glob filtering.
show_endpointFetches one endpoint with OS, policy, compliance, upgrade, heartbeat, and AMSI details.
list_agent_releasesLists available agent versions and per-platform latest releases.
find_alertsSearches alerts by severity / ack state / since / hostname / MITRE technique.
list_eventsLists audit/block telemetry events, including last-day event review workflows.
triage_alertFetches one alert directly with triggering events, metadata, and file context; optionally acknowledges or dismisses it.
list_policiesLists policies with current version + mode.
show_policyShows one policy by id.
manage_policy_rulesLists rules or adds explicit / event-derived rules to a policy by id or name. Avoid explicit flat hash rules for Windows WDAC.
apply_policy_to_endpointsResolves endpoints and previews a policy assignment; confirm=true applies it after approval.
flip_to_enforcingTwo-step preview/confirm flip with a server-issued one-time confirm token. Safety-critical.
list_customer_intel_feedsLists private intel feeds or feed items.
manage_customer_intel_feedCreates or updates feeds; deletion requires a preview followed by confirm=true.
manage_customer_intel_itemEdits feed items; deletion requires a preview followed by confirm=true.
upsert_customer_intel_itemsAdds indicators extracted from reports into a private feed.
manage_policy_intel_sourcesLists, attaches, or detaches intel feeds on a policy.
upgrade_endpointsPreviews upgrades for an endpoint selection; confirm=true queues them after approval.
request_endpoint_checkinQueues an endpoint check-in command.
mint_enrollment_tokenMints a one-time agent enrollment token.
agent_install_instructionsReturns the install one-liner for macOS / Linux / Windows. No API call.

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

User:   Show me unack'd critical alerts from the last 24h.Claude: [calls find_alerts severity=critical acknowledged=false since=...]        → 3 critical alerts on 2 endpoints. Want me to triage the top one?
User:   Yes.Claude: [calls triage_alert]        → Evidence chain: cmd.exe spawned by winword.exe with -enc base64.          MITRE T1059.001. Acknowledge with comment "office macro chain — under investigation"?
User:   Yes, and extract the IOCs from this report into our SOC feed.Claude: [calls upsert_customer_intel_items]        → Upserted 47 indicators into feed 8d6...
User:   Show me audited or blocked events from the last day.Claude: [calls list_events hours=24 status=audited,blocked]        → 31 events. Here are the file paths, publishers, and hashes.
User:   Allow the first 5 on the Workstations policy.Claude: [calls manage_policy_rules action=add policy_name=Workstations event_ids=[...] status=allowed]        → Created a new policy version with 5 allowed rules.

Configuration sources, in order of precedence

  1. MAGICSWORD_API_KEY / MAGICSWORD_BASE_URL env vars (set by the MCP host).
  2. ~/.magicsword/mcp.json (or $MAGICSWORD_CONFIG).
  3. 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_enforcing is 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_rules with event_ids when approving audit events so the Portal can derive supported path / publisher / filename rules, or use upsert_customer_intel_items for 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 configured MAGICSWORD_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

sh
npm installnpm run buildnpm testnpm run test:packagenpm run release:verifynode dist/index.js --version

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
  1. v0.1.0最新Oct 7, 2026