SAP BTP MCP Server

SAP BTP MCP Server

Enables conversational management of SAP BTP cloud infrastructure, security, and entitlements through natural language via AI agents.

Category
访问服务器

README

🚀 SAP BTP MCP Server

License: MIT Protocol: MCP Python: 3.10+

A professional Model Context Protocol (MCP) server providing a robust natural language interface for SAP Business Technology Platform (BTP).

Manage your cloud infrastructure, security, and entitlements conversationally through AI agents (Claude, Gemini, etc.) using your local btp CLI session.


🌟 Key Features

  • Conversational Infrastructure: Provision subaccounts and assign roles using simple language.
  • Fail-Safe Design: Built-in timeouts, non-interactive execution, and resilient output parsing.
  • Secure by Design:
    • Runs entirely locally; no external credentials or tokens are stored.
    • Leverages your existing BTP CLI authentication (SSO/JWT).
  • Proactive Error Handling: Provides clear instructions when authentication expires or inputs are invalid.
  • Automatic Discovery: Intelligently locates the btp binary across Windows, macOS, and Linux.

🏗️ Fail-Proof Architecture

This server is designed for mission-critical AI automation:

  • Intelligent Timeouts: Prevents "hanging" on long SAP BTP API operations with 60s/120s thresholds.
  • Deep JSON Recovery: Automatically extracts valid data even if the CLI returns mixed output or warnings.
  • Input Validation: Pre-validates technical IDs (GUIDs) and Emails to prevent unnecessary CLI failures.
  • Non-Interactivity: Guaranteed non-blocking execution using CI-mode environments and null-input piping.

📋 Prerequisites

  1. SAP BTP CLI: Installed and in your system PATH.
  2. Active Session: You must be logged in. Verify with: btp list accounts/global-account
  3. Python 3.10+: Ensure a modern Python environment.

🛠️ Installation

Using uv (Recommended)

uv tool install --from . btp-mcp-server

Using pip

pip install .

⚙️ Configuration

Add the following to your MCP client config (e.g., claude_desktop_config.json):

Using uv (Fastest)

{
  "mcpServers": {
    "btp": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/BTP MCP Server",
        "run",
        "btp-mcp-server"
      ]
    }
  }
}

Using Python

{
  "mcpServers": {
    "btp": {
      "command": "python3",
      "args": ["-m", "btp_mcp_server"],
      "env": { "PYTHONPATH": "/absolute/path/to/BTP MCP Server/src" }
    }
  }
}

🧠 Available Tools

Category Tool Description
System btp_ping Checks CLI health and login status.
btp_execute_command Run any generic BTP CLI command.
Accounts btp_list_subaccounts List all accessible subaccounts.
btp_create_subaccount Provision a new subaccount with validation.
btp_delete_subaccount Permanent deletion of a subaccount.
btp_list_regions List available technical regions (us10, eu10, etc).
btp_list_directories List directories in the global account.
Security btp_list_users List global account users.
btp_assign_role_collection Grant roles (e.g., Admin) to a user.
Resources btp_list_entitlements Check available service plans/quotas.
btp_remove_entitlement Remove an assigned entitlement from a subaccount.
btp_list_service_instances List active services in a subaccount.
btp_list_environment_instances List environments like Cloud Foundry or Kyma.
btp_list_subscriptions List SaaS application subscriptions.

💬 Usage Examples

  • "Check if my BTP session is still active using ping."
  • "Show me all subaccounts in region eu10."
  • "Assign the 'Subaccount Admin' role to colleague@example.com."
  • "Create a development subaccount named 'Internal-Alpha' in us10."

🆘 Troubleshooting

Authentication Error (❌ AUTHENTICATION ERROR) If you see this, your BTP CLI session has expired.

  1. Clear the error in the AI chat.
  2. Run btp login in your terminal.
  3. Refresh the AI session.

CLI Not Found (⚠️ BTP CLI not found) Ensure btp is in your PATH. On macOS/Linux, try ln -s /path/to/btp /usr/local/bin/btp.


🏗️ System Design

The server follows a layered architecture to ensure separation of concerns and maximum stability:

  • Tool Layer (server.py): Uses FastMCP to register Python functions as MCP tools. Implements strict Pydantic validation and maps technical exceptions to human-readable markdown tips.
  • Service Layer (btp_cli.py): Orchestrates command execution. Manages the state of the CLI path, handles binary auto-discovery, and implements the "Deep JSON Recovery" algorithm.
  • Execution Layer (subprocess): Interacts directly with the OS. Uses hardened environments (CI=true) and standard error redirection to maintain security and non-interactivity.
  • Utility Layer (utils.py): Centralizes cross-cutting concerns like logging to stderr and custom domain-specific exceptions.

🔄 Control Flow

  1. Request Intake: The AI client (e.g., Antigravity) sends a JSON-RPC request to a registered tool (e.g., btp_list_subaccounts).
  2. Pre-Validation: The Tool Layer hydrates parameters and performs regex-based technical validation (IDs/GUIDs).
  3. Execution: The Service Layer constructs a safe CLI command, injecting --format json as a global prefix.
  4. Retry & Recovery:
    • If the command times out, it retries with exponential backoff.
    • If the output contains warnings + JSON, the "Deep Recovery" engine extracts the valid payload.
  5. Error Mapping: If the CLI returns "Session Expired", the decorator catches it and provides the user with an exact btp login command for their specific binary path.
  6. Structured Response: The final JSON payload is beautified and returned to the AI as a markdown-formatted string.

📄 License

MIT License.

👤 Author

Kallol Chakraborty - @kallolchakraborty

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选