ABAP MCP – AI-Powered SAP Development
An ABAP Model Context Protocol (MCP) server that brings AI-driven coding assistance to SAP ABAP development. Works with VS Code Copilot, Claude Desktop, Cursor, and any MCP-compatible client. Supports multiple LLM backends including GitHub Copilot, OpenAI, Anthropic Claude, Azure OpenAI, and local models via Ollama.
Architecture
┌──────────────────────────────────────────────────────────────────┐
│ VS Code / IDE │
│ │
│ ┌─────────────────────┐ ┌──────────────────────────────────┐ │
│ │ GitHub Copilot Chat│ │ MCP Client (Claude Desktop, │ │
│ │ @abap participant │ │ Cursor, etc.) │ │
│ └──────────┬──────────┘ └──────────────┬───────────────────┘ │
│ │ │ │
│ ┌──────────▼──────────────────────────────▼───────────────────┐ │
│ │ VS Code Extension (abap-mcp-copilot) │ │
│ │ • Copilot @abap chat agent │ │
│ │ • MCP client wrapper │ │
│ │ • Editor commands (analyze, format) │ │
│ └──────────────────────────┬────────────────────────────────--┘ │
└─────────────────────────────│────────────────────────────────────┘
│ stdio / SSE
┌─────────────────────────────▼────────────────────────────────────┐
│ ABAP MCP Server (Node.js) │
│ │
│ Tools: Resources: │
│ • abap_analyze • abap://syntax-reference │
│ • abap_generate • abap://best-practices │
│ • abap_explain │
│ • abap_refactor │
│ • abap_search ◄──────── SAP ADT REST API │
│ • abap_unit_test │
│ • abap_format │
│ • abap_docs │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Generic LLM Provider Layer │ │
│ │ ┌──────────┐ ┌──────────┐ ┌────────────┐ ┌─────────────┐ │ │
│ │ │ OpenAI │ │Anthropic │ │Azure OpenAI│ │ Ollama │ │ │
│ │ │ GPT-4o │ │ Claude │ │ GPT-4o │ │ CodeLlama │ │ │
│ │ └──────────┘ └──────────┘ └────────────┘ └─────────────┘ │ │
│ │ ┌────────────────┐ │ │
│ │ │ GitHub Copilot │ │ │
│ │ └────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
Features
MCP Tools
| Tool | Description |
|---|---|
abap_analyze | Deep code analysis: syntax, performance, security, Clean ABAP, cyclomatic complexity. Optionally integrates SAP Code Inspector via ADT. |
abap_generate | Generate production-ready ABAP from natural language – classes, CDS views, RAP behaviors, OData services, unit tests, and more. |
abap_explain | Plain-English explanation of any ABAP code. Adjustable audience level (beginner → expert). Optional line-by-line annotations. |
abap_refactor | Refactor towards Clean ABAP: extract methods, modernize syntax, improve naming, add error handling, convert to OOP. |
abap_search | Search ABAP repository objects in a connected SAP system (requires ADT credentials). |
abap_unit_test | Generate ABAP Unit Test classes using ABAP Unit + Test Double Framework. Optionally run existing tests via ADT. |
abap_format | Format code: 2-space indentation, uppercase keywords, replace deprecated syntax (MOVE→=, SELECT *→explicit fields). |
abap_docs | Comprehensive documentation for ABAP keywords, statements, classes, and SAP concepts with version-specific notes. |
MCP Resources
| Resource URI | Content |
|---|---|
abap://syntax-reference | ABAP data types, modern 7.4+ syntax, constructor expressions, string templates |
abap://best-practices | Clean ABAP naming, DB access patterns, exception design, unit testing |
VS Code Extension (@abap Copilot Agent)
Use @abap in Copilot Chat with these slash commands:
@abap /analyze ← analyze the current file
@abap /generate a CDS view for sales order header with customer join
@abap /explain ← explain selected code or whole file
@abap /refactor ← clean up current file
@abap /test ← generate unit tests for current class
@abap /docs FOR ALL ENTRIES
@abap /format ← format and fix deprecated syntax
@abap how do I implement a BAdi? ← free-form ABAP question
LLM Providers
| Provider | Config | Notes |
|---|---|---|
| GitHub Copilot | LLM_PROVIDER=copilot | Uses your existing Copilot subscription via VS Code |
| OpenAI | LLM_PROVIDER=openai + OPENAI_API_KEY | GPT-4o recommended |
| Anthropic | LLM_PROVIDER=anthropic + ANTHROPIC_API_KEY | Claude Sonnet 4.6 recommended |
| Azure OpenAI | LLM_PROVIDER=azure-openai + endpoint/key | Enterprise deployments |
| Ollama | LLM_PROVIDER=ollama | Local inference with CodeLlama, DeepSeek-Coder |
Quick Start
1. Install dependencies
npm install
2. Configure environment
cp config/example.env .env
# Edit .env with your LLM credentials and optional SAP connection
3. Build and run
npm run build
npm start # stdio mode (for Claude Desktop / Cursor)
4. Connect to Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"abap": {
"command": "node",
"args": ["/path/to/ABAP_MCP/dist/server/index.js"],
"env": {
"LLM_PROVIDER": "openai",
"OPENAI_API_KEY": "sk-..."
}
}
}
}
5. Install the VS Code Extension
cd vscode-extension
npm install
npm run compile
# Press F5 to launch Extension Development Host, or package with vsce
Then in VS Code settings, configure:
{
"abapMcp.llmProvider": "copilot",
"abapMcp.sapBaseUrl": "https://your-sap-system:8000",
"abapMcp.sapUser": "DEVELOPER"
}
SAP System Connection (Optional)
The SAP connection uses the ABAP Development Tools (ADT) REST API, available on any SAP system with ABAP 7.5+ or S/4HANA.
Required SAP authorizations:
S_ADT_RES– ADT resource accessS_DEVELOP– ABAP Workbench authorizationS_CODE_INS– Code Inspector (forrunCodeInspector: true)
Set credentials:
SAP_BASE_URL=https://my-sap.example.com:8000
SAP_USER=DEVELOPER
SAP_PASSWORD=secret
SAP_CLIENT=100
SAP_LANGUAGE=EN
Development
npm run dev # Run server in development mode (tsx, no build)
npm run build:watch # Watch mode TypeScript compilation
npm run typecheck # Type-check without building
npm test # Run unit tests
Project Structure
ABAP_MCP/
├── src/
│ ├── server/
│ │ ├── index.ts # MCP server entry point
│ │ ├── tools/ # MCP tool handlers
│ │ │ ├── analyze.ts # abap_analyze
│ │ │ ├── generate.ts # abap_generate
│ │ │ ├── explain.ts # abap_explain
│ │ │ ├── refactor.ts # abap_refactor
│ │ │ ├── search.ts # abap_search
│ │ │ ├── unit-test.ts # abap_unit_test
│ │ │ ├── format.ts # abap_format
│ │ │ └── docs.ts # abap_docs
│ │ └── resources/ # MCP resources
│ │ ├── abap-syntax.ts # ABAP syntax reference
│ │ └── best-practices.ts # Clean ABAP guidelines
│ ├── sap/
│ │ ├── adt-client.ts # SAP ADT REST API client
│ │ └── types.ts # ABAP domain types
│ ├── llm/
│ │ ├── provider.ts # Generic LLM interface + ABAP system prompt
│ │ ├── factory.ts # Provider factory (reads env config)
│ │ ├── openai.ts # OpenAI adapter
│ │ ├── anthropic.ts # Anthropic adapter
│ │ ├── azure-openai.ts # Azure OpenAI adapter
│ │ ├── copilot.ts # GitHub Copilot adapter
│ │ └── ollama.ts # Ollama (local) adapter
│ └── utils/
│ ├── config.ts # Zod-validated env config
│ └── logger.ts # Winston logger
├── vscode-extension/
│ ├── package.json # VS Code extension manifest
│ └── src/
│ ├── extension.ts # Extension activation, commands
│ ├── copilot-agent.ts # @abap Copilot chat participant
│ └── mcp-client.ts # MCP client wrapper
└── config/
├── example.env # Configuration template
└── mcp.json # MCP server config template
Adding a New LLM Provider
- Create
src/llm/my-provider.tsimplementingLLMProvider:
export class MyProvider implements LLMProvider {
readonly name = 'my-provider';
readonly model: string;
async complete(messages, options) { /* ... */ }
async *stream(messages, options) { /* ... */ }
async healthCheck() { /* ... */ }
}
- Register it in
src/llm/factory.tsunder a newcase. - Add the new provider to the
LLM_PROVIDERenum insrc/utils/config.ts. - Add a VS Code setting entry in
vscode-extension/package.json.
License
MIT