SentinelX Core MCP
SentinelX Core MCP
用于 SentinelX Core 的 MCP/OAuth 网关。将您的服务器代理作为带有 OIDC 令牌验证的 MCP 工具公开。
SentinelX Core MCP 位于 MCP 客户端(Claude、ChatGPT、Cursor 或任何兼容 MCP 的代理)与正在运行的 SentinelX Core 实例之间。它根据 JWKS 端点验证传入的 OAuth Bearer 令牌,然后将工具调用转发给上游代理。
架构
Claude / ChatGPT / Cursor / any MCP client
│
│ MCP + OAuth Bearer token
▼
sentinelx-core-mcp (public, port 8098)
│ validates token via OIDC/JWKS
│ HTTP + internal Bearer token
▼
sentinelx-core (local only, port 8091)
│
└─ command allowlist, structured editing, uploads, services两个独立的身份验证层:
层级 | 验证方式 | 令牌类型 |
外部 (MCP) |
| OAuth 访问令牌(来自您的身份提供商) |
内部 (代理) |
| 静态 Bearer 令牌 ( |
Related MCP server: mcp_sdk_eyra_accelerator_v19
公开的 MCP 工具
工具 | 功能 | 所需作用域 |
| 健康检查 | public |
| 代理运行时状态 |
|
| 执行允许的命令 |
|
| 服务操作 (启动/停止/重启/重载/状态) |
|
| 重启已注册的服务 |
|
| 结构化文件编辑 (无 shell 引号) |
|
| 初始化大文件编辑上传 |
|
| 上传用于编辑的角色文件 |
|
| 完成大文件编辑 |
|
| 上传文件 (URL 或 base64) |
|
| 初始化分块上传 |
|
| 上传一个分块 |
|
| 完成分块上传 |
|
| 运行临时 bash/python3 脚本 |
|
| 允许的命令、服务、位置、剧本 |
|
| 来自代理的嵌入式帮助 |
|
要求
一个正在运行的 SentinelX Core 实例
一个兼容 OIDC 的身份提供商 (Keycloak, Auth0, Authentik, Zitadel 或任何带有 JWKS 端点的提供商)
Python 3.11+
快速入门
在服务器上安装
git clone https://github.com/pensados/sentinelx-core-mcp.git
cd sentinelx-core-mcp
sudo bash install.sh然后进行配置:
sudo nano /etc/sentinelx-core-mcp/sentinelx-core-mcp.env最低要求:
MCP_PORT=8098
SENTINELX_URL=http://127.0.0.1:8091
SENTINELX_TOKEN=your_internal_agent_token
OIDC_ISSUER=https://auth.example.com/realms/sentinelx
OIDC_JWKS_URI=https://auth.example.com/realms/sentinelx/protocol/openid-connect/certs
OIDC_EXPECTED_AUDIENCE=
RESOURCE_URL=https://sentinelx.example.com
AUTH_DEBUG=false重启并验证:
sudo systemctl restart sentinelx-core-mcp
sudo systemctl status sentinelx-core-mcp
sudo journalctl -u sentinelx-core-mcp -n 50 --no-pager本地开发
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
./run.sh本地默认值:
MCP 端口: 8099
上游 SentinelX Core:
http://127.0.0.1:8092
安装路径
路径 | 内容 |
| 应用程序代码 |
| 环境变量配置 |
| 日志 |
| systemd 单元 |
连接反向代理
位于 /mcp 的 MCP 端点应通过 HTTPS 公开。Nginx 配置示例:
server {
listen 443 ssl http2;
server_name sentinelx.example.com;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
location = /mcp {
proxy_pass http://127.0.0.1:8098/mcp;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Authorization $http_authorization;
proxy_buffering off;
proxy_request_buffering off;
proxy_read_timeout 3600s;
add_header Cache-Control "no-cache";
}
}连接到 Claude
在 Claude 的设置中添加 MCP 服务器:
https://sentinelx.example.com/mcpClaude 将在首次使用时提示进行 OAuth 登录。授权后,它将拥有您的令牌作用域所允许的所有工具的访问权限。
连接到 ChatGPT
将 MCP 服务器 URL 注册为 GPT Action 或在您的 ChatGPT 连接器配置中进行注册。OAuth 流程适用于任何支持授权码流程的 OIDC 提供商。
MCP 冒烟测试 (curl)
MCP 端点使用基于 HTTP 的 JSON-RPC。一个最小会话:
1. 初始化
SESSION=$(curl -si -X POST https://sentinelx.example.com/mcp \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0","id":"1","method":"initialize",
"params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"0.1"}}
}' | grep -i mcp-session-id | awk '{print $2}' | tr -d '\r')2. 通知已初始化
curl -s -X POST https://sentinelx.example.com/mcp \
-H "Content-Type: application/json" \
-H "mcp-session-id: $SESSION" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}'3. 调用 ping (公开)
curl -s -X POST https://sentinelx.example.com/mcp \
-H "Content-Type: application/json" \
-H "mcp-session-id: $SESSION" \
-d '{"jsonrpc":"2.0","id":"2","method":"tools/call","params":{"name":"ping","arguments":{}}}' \
| sed -n 's/^data: //p' | jq4. 调用受保护的工具
curl -s -X POST https://sentinelx.example.com/mcp \
-H "Content-Type: application/json" \
-H "mcp-session-id: $SESSION" \
-H "Authorization: Bearer YOUR_OAUTH_ACCESS_TOKEN" \
-d '{"jsonrpc":"2.0","id":"3","method":"tools/call","params":{"name":"sentinel_exec","arguments":{"cmd":"uptime"}}}' \
| sed -n 's/^data: //p' | jq身份提供商设置
任何兼容 OIDC 的提供商均可使用:Keycloak, Auth0, Authentik, Zitadel 或您自己的提供商。您需要:
一个配置为授权码流程(交互式)或客户端凭据(机器对机器)的 客户端
与您想要公开的工具相匹配的 自定义作用域 (
sentinelx:exec,sentinelx:edit等)您提供商的 JWKS URI
对于 Claude 和 ChatGPT:在客户端中注册正确的 重定向 URI
在环境变量文件中设置这些内容:
OIDC_ISSUER=https://your-provider.example.com/realms/your-realm
OIDC_JWKS_URI=https://your-provider.example.com/realms/your-realm/protocol/openid-connect/certs
OIDC_EXPECTED_AUDIENCE= # set to your client ID, or leave empty to skip audience validation关于 OIDC_EXPECTED_AUDIENCE
如果您的提供商在
aud声明中包含它(机密客户端常见),请设置为您的 客户端 ID如果不确定,请保持 为空 — 服务器将跳过受众验证
如果令牌被拒绝,请解码令牌 (
echo $TOKEN | cut -d. -f2 | base64 -d | jq) 并检查aud声明
连接 Claude
在 Claude 的设置中添加 MCP 服务器:
https://sentinelx.example.com/mcpClaude 将在首次使用时重定向到您的身份提供商。请确保:
重定向 URI
https://claude.ai/api/mcp/auth_callback已在您的 OIDC 客户端中注册您的服务器公开了带有正确
authorization_servers值的/.well-known/oauth-protected-resource
连接 ChatGPT
将 MCP URL 注册为 GPT Action。将 https://chatgpt.com/aip/g-*/oauth/callback 添加到您客户端的重定向 URI 中。
有关 Keycloak 的完整端到端演练(包括令牌获取、Claude 设置、冒烟测试和故障排除),请参阅 docs/keycloak-example.md。
没有运行 Keycloak?请参阅 docs/oidc-alternatives.md 获取关于 Authentik、Zitadel 和 Zitadel Cloud 的快速入门指南。
故障排除
工具失败并显示 Missing Authorization header
MCP 客户端未发送 OAuth 令牌。请验证授权流程是否已成功完成。
Invalid access token
检查 OIDC_ISSUER 和 OIDC_JWKS_URI 是否与您的身份提供商完全匹配。暂时启用 AUTH_DEBUG=true 以在日志中查看令牌验证详细信息。
Missing required scope
令牌不包含该工具所需的作用域。将该作用域添加到您的 OIDC 客户端配置中并重新授权。
ping 有效但所有其他工具失败
通常是身份验证问题。ping 是公开的;所有其他工具都需要具有正确作用域的有效令牌。
MCP 启动但无法连接到 SentinelX Core
检查 SENTINELX_URL 是否指向正在运行的核心实例,以及 SENTINELX_TOKEN 是否与核心的 SENTINEL_TOKEN 匹配。
安全说明
将 MCP 服务置于 HTTPS 和反向代理之后
使用仅包含所需作用域的专用 OIDC 客户端
定期轮换
SENTINELX_TOKEN和 OIDC 客户端凭据定期审查执行审计日志 (
/var/log/sentinelx/exec.log)AUTH_DEBUG=true会记录令牌声明 — 请在生产环境中禁用
相关
sentinelx-core — 底层 HTTP 代理:命令执行、结构化编辑、上传和服务管理。
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
- StytchOAuthdev.stytch.mcp
The Stytch MCP server is a reference implementation that demonstrates remote MCP server authentication and authorization using Stytch Connected Apps. It provides OAuth 2.1-compliant authorization (including PKCE), Dynamic Client Registration, and validates Stytch-issued access tokens to enable AI agents to securely interact with external services through permissioned access, supporting scopes like openid, email, profile, and manage:project_data.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA standalone MCP server that exposes API endpoints as tools for AI assistants by proxying requests to a target API defined in an OpenAPI specification. It supports various authentication methods and utilizes Server-Sent Events (SSE) to facilitate integration with clients like Claude and ChatGPT.-
- FlicenseNot gradedqualityDmaintenanceA standalone MCP server that exposes Eyra Accelerator API endpoints as tools for AI assistants via SSE transport. It enables secure interaction with the target API by proxying requests and handling authentication automatically.-
- FlicenseNot gradedqualityDmaintenanceA production-ready MCP server that authenticates agents via OAuth 2.1 Bearer tokens, validates JWTs with JWKS, enforces tool-level scopes and roles, and logs the full delegation chain.-
- FlicenseAqualityDmaintenanceStandalone MCP server that proxies tool calls to Ottoauth HTTP endpoints, enabling account creation and dynamic service interaction.7-