mcpField
B
btp-mcp-server

btp-mcp-server

本地服务
github.com/ABRANJAN07云与基础设施127 周前更新

关于 btp-mcp-server

btp-mcp-server 是面向 SAP Business Technology Platform 开发者和 Agent 的开源 MCP 服务。它提供目录、服务计划、实例、目标配置及服务推荐工具,并支持响应缓存和列表分页获取。

主要功能

  1. 01浏览全局 BTP 服务目录
  2. 02查看服务计划及免费选项
  3. 03列出子账号实例和健康状态
  4. 04查看已配置目标及其认证方式
  5. 05按使用需求推荐服务
  6. 06缓存响应并获取所有列表分页

适用场景

  1. 01查询账号可用的服务
  2. 02确认子账号中是否运行 HANA Cloud
  3. 03检查外部目标及其认证方式
  4. 04为应用需求寻找合适的 BTP 服务

MCP 相关

它将 SAP BTP API 作为工具提供给兼容 MCP 的 AI 客户端,并支持 stdio 和 HTTP 传输方式。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"abranjan07-btp": {
"command": "uvx",
"args": [
"btp-mcp-server"
]
}
}
}
启动命令uvx btp-mcp-server

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypibtp-mcp-server1.0.0

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

SAP BTP 服务发现 — MCP 服务

一个可用于生产环境的 MCP(Model Context Protocol)服务,可将 SAP BTP 平台 API 暴露为工具,供任何兼容 MCP 的 AI Agent 使用 — Claude Code、Cursor、Joule Studio、 LangGraph Agent,或任何其他 MCP 客户端。

image

通过 Model Context Protocol 将任何 AI Agent 连接到你的 SAP BTP 环境。

PyPI version Python MCP License: MIT


这是什么?

BTP MCP Server 是一个开源的 Model Context Protocol 服务,可将 AI Agent 连接到 SAP Business Technology Platform(BTP)API。

你无需切换到 BTP Cockpit 来回答常见的开发者问题, 可以直接询问你的 AI Agent:

  • “我的账户中有哪些可用的 BTP 服务?”
  • “我的子账户中已经运行 HANA Cloud 了吗?”
  • “我的 CAP 应用需要异步消息传递 — 应该使用什么?”
  • “配置了哪些目标,它们使用什么身份验证方式?”

兼容 Claude Code、Cursor、Joule Studio、LangGraph Agent 以及任何其他兼容 MCP 的 AI 客户端。


工具

工具可回答的问题
list_btp_services全局目录中有哪些 BTP 服务?
get_btp_service_plans服务 X 有哪些计划?有免费的吗?
list_btp_instances我的子账户中正在运行什么?运行状况是否正常?
get_btp_destinations配置了哪些外部连接?
recommend_btp_service根据使用场景,我应该使用什么服务?

安装

pip install btp-mcp-server

先决条件

你需要一个来自 BTP 子账户的 Service Manager 服务密钥。

获取步骤:

  1. 前往 BTP Cockpit → 你的子账户 → Services → Service Marketplace
  2. 搜索 Service Manager → 使用计划 subaccount-admin 创建实例
  3. 在实例上创建一个 Service Key
  4. 密钥 JSON 中包含你的凭据 — 请参阅下方的配置部分

配置

所有配置均通过环境变量完成。将 .env.example 复制为 .env, 并填写 Service Manager 服务密钥中的值:

# From your Service Manager service key JSON
BTP_CLIENT_ID=your-client-id          # from "clientid"
BTP_CLIENT_SECRET=your-client-secret  # from "clientsecret"
BTP_TOKEN_URL=https://your-subdomain.authentication.us10.hana.ondemand.com/oauth/token
BTP_SM_URL=https://service-manager.cfapps.us10.hana.ondemand.com  # from "sm_url"

# From BTP Cockpit → your subaccount → Overview → "Subaccount ID"
BTP_SUBACCOUNT_ID=your-subaccount-guid

# Destination Service URL (region-specific — adjust region if needed)
BTP_DESTINATION_URL=https://destination.cfapps.us10.hana.ondemand.com

# Optional: cache TTL in seconds (default: 300)
# CACHE_TTL_SECONDS=300

注意: 切勿将 .env 文件提交到 GitHub。 使用 .env.example(不包含真实值)作为参考模板。


使用方法

使用 Claude Desktop

添加到你的 claude_desktop_config.json:

Mac: ~/.claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "sap-btp": {
      "command": "btp-mcp-server",
      "env": {
        "BTP_CLIENT_ID": "your-client-id",
        "BTP_CLIENT_SECRET": "your-client-secret",
        "BTP_TOKEN_URL": "https://your-subdomain.authentication.us10.hana.ondemand.com/oauth/token",
        "BTP_SM_URL": "https://service-manager.cfapps.us10.hana.ondemand.com",
        "BTP_SUBACCOUNT_ID": "your-subaccount-guid",
        "BTP_DESTINATION_URL": "https://destination.cfapps.us10.hana.ondemand.com"
      }
    }
  }
}

重启 Claude Desktop。然后询问:

  • “我有哪些可用的 BTP 服务?”
  • “有没有失败的服务实例?”
  • “我需要连接到本地部署的 SAP 系统 — 哪项 BTP 服务可以处理?”

使用 Claude Code / Cursor
{
  "mcpServers": {
    "sap-btp": {
      "command": "btp-mcp-server",
      "env": {
        "BTP_CLIENT_ID": "...",
        "BTP_CLIENT_SECRET": "...",
        "BTP_TOKEN_URL": "...",
        "BTP_SM_URL": "...",
        "BTP_SUBACCOUNT_ID": "..."
      }
    }
  }
}
使用 LangGraph Agent
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic

async with MultiServerMCPClient({
    "btp": {
        "command": "btp-mcp-server",
        "transport": "stdio",
        "env": {
            "BTP_CLIENT_ID": "...",
            "BTP_CLIENT_SECRET": "...",
            "BTP_TOKEN_URL": "...",
            "BTP_SM_URL": "...",
            "BTP_SUBACCOUNT_ID": "...",
        }
    }
}) as client:
    tools = client.get_tools()
    agent = create_react_agent(
        ChatAnthropic(model="claude-sonnet-4-6"),
        tools
    )
    result = await agent.ainvoke({
        "messages": [{"role": "user", "content":
            "What BTP services do I have? Is there anything I should use for messaging?"
        }]
    })
使用 Joule Studio(BTP)

以 HTTP 模式部署,并将其注册为 BTP Destination:

MCP_TRANSPORT=http btp-mcp-server
# Server starts at http://0.0.0.0:8080/mcp

然后在 BTP Cockpit → Destinations → 创建一个指向你的服务 URL 的目标。 在 Joule Studio Agent Builder → Tools → Add MCP Server → 选择该目标。


从源代码在本地运行

git clone https://github.com/ABRANJAN07/btp-mcp-server.git
cd btp-mcp-server

pip install -r requirements.txt
cp .env.example .env
# fill in .env with your BTP credentials

# Test BTP connectivity
python test_connection.py

# Start the MCP server
python server.py

运行测试

测试使用模拟的 BTP 响应 — 无需真实凭据。

pip install -r requirements.txt
pytest tests/ -v

预期输出:17 项测试通过


项目结构

btp-mcp-server/
├── server.py              ← MCP server entry point (5 tools)
├── test_connection.py     ← Verify BTP connectivity
├── requirements.txt
├── .env.example           ← Configuration template
├── btp_mcp/
│   ├── config.py          ← Reads .env settings
│   ├── auth.py            ← OAuth2 token management
│   ├── btp_client.py      ← BTP API calls + caching
│   ├── cache.py           ← TTL cache
│   └── models.py          ← Pydantic response models
└── tests/
    └── test_tools.py      ← 17 tests with mocked responses

工作原理

AI Agent (Claude / Cursor / LangGraph)
    │
    │  MCP Protocol (stdio)
    ▼
BTP MCP Server (this package)
    │  OAuth2 client_credentials
    │  + TTL cache (5 min)
    ▼
SAP BTP APIs
  ├── Service Manager API  → service catalog, instances, plans
  └── Destination API      → configured connections

缓存: BTP API 响应默认缓存 5 分钟。 服务目录和实例列表很少发生变化,因此缓存可以加快响应速度,同时保证数据足够新。

分页: 所有列表端点都会从 BTP 获取每一页数据,而不只是前 50 条结果。


路线图

这是一个分 6 个阶段推进的项目的第 2 阶段,目标是构建一个功能完整的 AI 驱动 BTP 运维平台。

阶段状态描述
阶段 1✅ 已完成BTP 身份验证 + 2 个工具 + 本地 MCP 服务
阶段 2✅ 已完成5 个工具 + 缓存 + 分页 + 测试 + PyPI
阶段 3🔜 下一步LangGraph Agent + FastAPI 流式传输 + 记忆
阶段 4📋 计划中Chainlit 原型 → React + BTP 上的 UI5 Web Components
阶段 5📋 计划中多 Agent 监督器 + RAG + 主动告警
阶段 6📋 计划中生产环境加固 + CI/CD + BTP 市场

即将推出(第 3 阶段)

  • 支持多轮对话记忆的 LangGraph ReAct Agent
  • FastAPI SSE 流式传输端点
  • 为推荐服务生成代码 (CAP 绑定配置、CLI 命令、YAML 清单)

Entitlements API(暂时禁用)

get_btp_entitlements 工具需要单独的 Cloud Management Service(CIS Central 计划)服务密钥。 代码已完整编写,目前已注释掉——准备启用时请参阅 ENTITLEMENTS_SETUP.md。


贡献

欢迎贡献!请先提交 issue,讨论你想要更改的内容。

git clone https://github.com/ABRANJAN07/btp-mcp-server.git
cd btp-mcp-server
pip install -r requirements.txt
pytest tests/ -v   # make sure tests pass before submitting a PR

许可证

MIT — 详情请参阅 LICENSE。


作者

由 Abhijeet Ranjan 构建, 是 AI + SAP BTP 集成系列项目的一部分。

在 LinkedIn 关注项目进展,获取第 3 阶段的最新动态。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。