PasarGuard MCP

PasarGuard MCP

Local MCP server for managing PasarGuard panels via their REST APIs, supporting read operations and a two-step plan/apply workflow for safe writes. It handles nodes, cores, hosts, groups, and users with confirmation-based changes and rollback plans.

Category
访问服务器

README

PasarGuard MCP

PasarGuard MCP is a local Model Context Protocol server for managing one or more PasarGuard panels through their REST APIs. It is intentionally limited to panel operations. It does not install servers, manage Vultr, SSH into nodes, manage Cloudflare/Fastly, or change provider infrastructure.

The server supports both reading and writing. Writes use a two-step plan/apply workflow: the MCP reads the current object, creates a short-lived confirmation token, and only applies the saved change after the user confirms it. Update plans preserve fields that were not changed, which is important because PasarGuard core and host updates expect complete valid objects.

Install

cd projects/pasarguard-mcp
python3 -m venv .venv
.venv/bin/python -m pip install -e '.[dev]'

Python 3.11 or newer is required.

Configure panels

Static configuration is optional. The MCP can also load a credential file from a chat-driven tool call; see the next section.

Copy config/panels.example.json to a file outside Git, for example ~/.config/pasarguard-mcp/panels.json, and set the password in an environment variable:

export PASARGUARD_MCP_CONFIG="$HOME/.config/pasarguard-mcp/panels.json"
export PASARGUARD_EXAMPLE_PASSWORD='your-panel-password'

The configuration accepts multiple named panels:

{
  "panels": {
    "main": {
      "base_url": "https://panel.example.com",
      "username": "admin",
      "password_env": "PASARGUARD_MAIN_PASSWORD",
      "verify_tls": true,
      "timeout": 30
    },
    "staging": {
      "base_url": "https://staging-panel.example.com",
      "username_env": "PASARGUARD_STAGING_USERNAME",
      "password_env": "PASARGUARD_STAGING_PASSWORD"
    }
  }
}

An existing bearer token can be configured with token_env instead of username/password. Do not commit panel URLs, credentials, tokens, node API keys, certificates, or exported panel objects to this repository.

The local state directory stores confirmation plans and before-snapshots with mode 0700/0600. Override it with PASARGUARD_MCP_STATE_DIR when needed.

MCP client configuration

For a stdio MCP client, use the installed executable:

{
  "mcpServers": {
    "pasarguard": {
      "command": "/absolute/path/to/projects/pasarguard-mcp/.venv/bin/pasarguard-mcp",
      "env": {
        "PASARGUARD_MCP_CONFIG": "/absolute/path/to/panels.json",
        "PASARGUARD_MAIN_PASSWORD": "set-this-in-your-local-client-config"
      }
    }
  }
}

Prefer the client's secret/environment mechanism where it provides one. The MCP server never prints passwords or bearer tokens to stdout.

Chat-based credential files

You can tell Codex where an existing local credential file is instead of putting it in the MCP setup. Ask it to use the load_panel_credentials tool, for example:

Use the PasarGuard credentials in
/Users/me/workspace/memory/30-clients/example/credentials.local.md for the
panel named example. Keep them session-only and test the connection.

The tool reads the file locally and extracts only recognized fields. Supported formats are .env, .md, and .markdown; common keys include PANEL_URL, PASARGUARD_BASE_URL, username, password, and token. The password is never returned by the tool and is kept only in the MCP process by default.

If a Markdown file contains multiple named accounts, select the intended credential block explicitly. For example, a file with a flowship_super_admin block should be loaded with credential_name=flowship_super_admin. The parser strips one matching pair of Markdown backticks or quote characters around values. This matters for entries such as Password: \...`; sending the backticks as part of the password causes PasarGuard to return HTTP 401. When multiple complete credential blocks exist, omitting credential_name` now fails safely instead of merging the username from one account with the password or URL from another.

The tool accepts persist=true only when you explicitly want the profile written to the protected local JSON config. The default is persist=false. Use absolute local paths and keep credential files outside Git repositories.

Tool groups

Read operations:

  • list_panels, load_panel_credentials, test_panel
  • get_panel_inventory
  • list_panel_resource, get_panel_resource
  • get_node_realtime_stats, get_panel_system_status

Write planning operations:

  • Nodes: create, update, delete, reconnect, sync, reset usage, update core
  • Cores: create and update, with explicit optional node restart on updates
  • Hosts: create and update
  • Groups: create and update
  • Users: create and update by numeric ID
  • All supported resources can be planned for deletion

Write execution and recovery:

  • apply_change applies one still-valid confirmation token.
  • inspect_change shows a safe summary without the stored payload.
  • plan_rollback creates a new confirmation plan from an applied update's before-snapshot.

The normal sequence is:

  1. Inspect the panel or resource.
  2. Call the relevant plan_* tool.
  3. Show the returned summary and ask the user for confirmation.
  4. Call apply_change with the returned token.
  5. Verify the resulting resource and node status.

API compatibility

The implementation follows the current public PasarGuard panel API layout, including POST /api/admin/token, /api/nodes, /api/cores, /api/hosts, /api/groups, /api/users, node action endpoints, and ID-based user routes under /api/user/by-id/{user_id}. The panel API can evolve, so endpoint changes should be updated in src/pasarguard_mcp/server.py and covered by tests before release.

Development

.venv/bin/python -m pytest
.venv/bin/python -m compileall -q src tests

Tests use an in-memory HTTP transport and never contact a real panel.

Security boundary

This is an operations tool with write access. Run it locally over stdio, use a least-privileged PasarGuard administrator when possible, keep TLS verification enabled, and review every plan before applying it. Credential-file loading extracts only known fields and does not return passwords. The MCP deliberately does not provide a generic arbitrary-URL request tool.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选