Salesforce SAP MCP

Salesforce SAP MCP

Enables Claude AI to securely query live SAP inventory data through Salesforce by invoking typed Apex methods via MCP, using OAuth 2.0 JWT Bearer flow for authentication.

Category
访问服务器

README

Salesforce SAP MCP Integration

Claude connects directly to Salesforce via a custom MCP Server, invoking Apex to fetch live SAP inventory data. No middleware. No Flow. Direct agent-to-backend integration.


Business Problem

AI agents need a secure, structured way to call enterprise backend systems — not screen scraping, not unstructured API calls. MCP (Model Context Protocol) solves this by exposing typed, governed tools that an LLM can call directly.

This project proves Claude can securely query live SAP inventory data through Salesforce, using Apex as the typed execution layer.


Architecture

Architecture

How It Works

  1. Claude calls the registered MCP tool SAPInventoryService with a SKU
  2. Request authenticated via OAuth 2.0 JWT Bearer flow through the External Client App
  3. Salesforce MCP Server routes the call to the Apex InvocableMethod
  4. Apex makes an HTTP callout via Named Credential to the SAP endpoint
  5. Response parsed and returned as typed output
  6. Claude composes a natural language answer from the structured data

Live Verified Response

Field Value
SKU IPX-200
Product Industrial Pump X200
Available Qty 850 units
Status In Stock
Warehouse Mumbai WH-1
Lead Time 3 days

Components

Component Type Purpose
SalesforceSAPMCP MCP Server Definition Exposes Apex as MCP tool
Claude_Connect_Salesforce_MCP External Client App OAuth/JWT auth for Claude
SAPInventoryService Apex Class (Invocable) Calls SAP, returns typed result
SAPInventoryServiceTest Apex Test Class Test coverage
SAP_Mock_API Named Credential Secure SAP endpoint URL
SAP_Mock_External External Credential Auth configuration
SAP_Agent_Access Permission Set Apex + object access

Security — JWT Bearer Flow

Step What Happens
1 Claude authenticates using a signed JWT, not username/password
2 Salesforce validates the JWT signature against the registered certificate
3 Salesforce issues a session token scoped to the MCP server's permitted tools
4 No long-lived credentials exposed — every session is token-based and short-lived

Same auth pattern enterprises use for server-to-server integrations, applied here to agent-to-backend communication.

Apex Implementation

@InvocableMethod(
    label='Get SAP Inventory'
    description='Fetches live inventory data from SAP for a given product SKU'
)
global static List<InventoryResult> getInventory(List<InventoryRequest> requests) {
    // Calls SAP_Mock_API named credential
    // Returns typed InventoryResult: productName, availableQty, 
    // warehouse, leadTimeDays, status
}

Typed request/response wrapper classes mean the MCP tool schema is strongly typed — Claude knows exactly what input is required and what shape the response takes.

Problems Faced & How They Were Solved

Problem Root Cause Fix
External Credential access error on Apex callout MCP server's execution user lacked the External Credential principal mapping Added principal mapping to SAP_Agent_Access permission set, assigned to integration user
MCP tool not appearing for Claude Apex method not registered in McpServerDefinition metadata Added tool registration block mapping SAPInventoryService as a callable tool

Prerequisites

Requirement Detail
Salesforce org MCP Server support enabled
External Client App JWT Bearer Flow configured
Salesforce CLI npm install -g @salesforce/cli

Deployment

sf org login web
sf project deploy start --manifest package.xml
sf org assign permset --name SAP_Agent_Access
sf org assign permset --name SAP_Mock_API_Access

Admin Configuration

Step Action
1 External Client App — enable "Issue JWT-based access tokens" under OAuth settings
2 Upload certificate — generate self-signed cert, upload public key to External Client App
3 Permission Set Mapping — map External Credential principal to integration user's permission set
4 MCP Server Definition — verify SAPInventoryService tool is listed and active
5 Connect from claude.ai — add Salesforce MCP connector using the org's My Domain URL, not api.salesforce.com

Demo

Claude calling Salesforce MCP Claude calling Salesforce MCP

Production Considerations

Area Current State Production Fix
SAP endpoint Mock via Beeceptor Update Named Credential URL to real S/4HANA endpoint — no Apex changes needed
Error handling Apex returns success:false with errorMessage on failure Already production-ready — Claude surfaces errors gracefully
Rate limiting Single SKU per call Add governor limit checks for bulk SKU lookups

Key Insight

The agent is a trigger, not an executor. Claude extracts the SKU from natural language and calls a typed Apex method — validation rules, sharing rules, and business logic all still apply. MCP is the contract layer that makes this connection type-safe and secure.

Tech Stack

Layer Technology
AI Connector Claude (claude.ai MCP connector)
Auth OAuth 2.0 JWT Bearer Flow
Backend Logic Apex (@InvocableMethod)
Credential Management Named Credentials + External Credentials
MCP Layer Salesforce MCP Server Definition

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

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

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选