Skip to main content
Glama

pyrfc-mcp

CI Python 3.11 License: MIT

MCP server exposing SAP RFC-enabled function modules (BAPIs/RFCs) to AI agents through a discovery-first interface, built on SAP's pyrfc connector — plus automatic ABAP source reading (ADT when reachable, transparent RFC fallback otherwise, see docs/adt_rfc_integration_plan.md).

It is deny-by-default: discovering an RFC does not authorize calling it. Function allowlists, mutating-name deny rules, sensitive-table guards, result limits, and connection-affine transactions remain enforced at the server.

Try it without SAP

The supported demo backend uses deterministic synthetic RFC metadata and business records. It exercises the real discovery, validation, authorization, result-limiting, and MCP tool layers; only the final SAP transport is replaced.

python -m pip install pyrfc-mcp
rfc-mcp doctor --demo --connect
rfc-mcp --demo

No SAP account, PyRFC installation, or SAP NW RFC SDK is needed for demo mode. Configure an MCP client with the included .mcp.json.example to explore it immediately.

Related MCP server: SAP MCP Server

Setup

See docs/setup.md for the SAP NW RFC SDK + Python 3.11 prerequisites (required before real SAP calls work) and docs/architecture.md for the layer overview, including the read/write policy model, the generic-table-reader guard, and audit logging.

For a real system, install the proprietary SDK prerequisites, then:

uv sync --extra dev
copy .env.example .env    # fill in connection + policy settings
uv run rfc-mcp doctor     # validates config and native dependencies, no SAP call
uv run rfc-mcp doctor --connect  # explicitly performs a live SAP ping
uv run pytest             # unit tests, synthetic backend, no SAP needed
uv run mcp dev src/rfc_mcp/mcp/server.py

Real SAP connectivity additionally requires the proprietary SAP NW RFC SDK and the archived/yanked pyrfc==3.3.1 connector. Read the support warning and installation steps in docs/setup.md before running uv sync --extra sap or the smoke test.

doctor intentionally redacts connection and credential values. It does not contact SAP unless --connect is present, and it also supports --json for automation.

Tools

  • search_rfc_functions(pattern, group=None, limit=50)

  • get_rfc_function_interface(function_name)

  • call_rfc_function(function_name, parameters, mode="read"|"write", transaction_id=None)

  • commit_rfc_transaction(transaction_id, wait=False)

  • rollback_rfc_transaction(transaction_id)

  • read_abap_source(object_type, object_name, function_group=None) — one tool, no transport choice exposed to the caller; see docs/architecture.md.

ABAP knowledge skill

.claude/skills/sap-abap/ vendors the third-party sap-abap Claude Skill so an agent using this server also has accurate ABAP language knowledge on hand. It's licensed separately (GPL-3.0, its own LICENSE/NOTICE.md) from the rest of this project — see below.

Scope

Foundation, connection layer, discovery, execution, and MCP integration are built and tested, including a deny-by-default read/write policy, a table-level guard against the generic-table-reader injection surface (RFC_READ_TABLE et al.), fail-closed RFC response limits, and audit logging of every policy decision and call outcome. Not built: multi-tenant auth/RBAC beyond the single server-wide policy, rate limiting, metrics/tracing, and deployment packaging — see docs/architecture.md's "Out of scope" section for what’s deliberately deferred and why.

Write calls return an opaque transaction_id. Reuse it for related writes, then pass it to commit or rollback. This pins the entire SAP LUW to one RFC connection; abandoned transactions expire and roll back automatically.

Security posture

  • Reads and writes are denied unless their function names match explicit allowlists. The example configuration only permits discovery, source reading, and the harmless STFC_CONNECTION smoke test.

  • MCP tool annotations describe read/write risk for capable clients, but are advisory metadata—not an authorization boundary. Server policy and the SAP service account's S_RFC/table authorizations remain mandatory.

  • Stdio credentials come from the environment and are never placed in MCP tool arguments. Do not expose the server over HTTP without implementing the MCP authorization specification and deployment-level rate limiting.

  • RFC results are rejected rather than silently truncated when their cumulative nested table rows or serialized UTF-8 JSON size exceed RFC_MCP_RESULT_MAX_TABLE_ROWS or RFC_MCP_RESULT_MAX_SERIALIZED_BYTES. These limits protect MCP consumers; they cannot reduce work already performed inside SAP.

  • See SECURITY.md for reporting and deployment guidance.

License

MIT (see LICENSE), with one carved-out exception: .claude/skills/sap-abap/ is vendored third-party content under GPL-3.0 — see its own LICENSE and NOTICE.md. Including that directory does not place the rest of the project under GPL-3.0.

Available Tools

6 tools
call_rfc_functionA
Destructive

Invoke a SAP RFC-enabled function module with JSON parameters. Call get_rfc_function_interface first to know what parameters are required. mode='write' is required for functions classified as mutating and is rejected unless the server's policy explicitly allows writes for that function. A write returns a transaction_id tied to its SAP connection; reuse it for related writes, then pass it to commit_rfc_transaction or rollback_rfc_transaction. Writes are never auto-committed.

Inputs: parameters (required), function_name (required), mode, transaction_id. Returns: result, function_name, transaction_id

commit_rfc_transactionA
Destructive

Persist changes staged by prior write call_rfc_function calls in the identified SAP transaction (BAPI_TRANSACTION_COMMIT). Only available when the server policy mode is read_write.

Inputs: transaction_id (required), wait. Returns: action, result, transaction_id

get_rfc_function_interfaceA
Read-only

Return the full IMPORT/EXPORT/TABLES/CHANGING parameter interface (including resolved structure fields) and documented exceptions for a function module. Always call this before call_rfc_function to know exactly what parameters are required and how they're shaped.

Inputs: function_name (required). Returns: Full introspected interface of a function module.

read_abap_sourceA
Read-only

Read the full ABAP source of a program, class, or function module. Automatically uses ADT (one call, most reliable — especially for classes, which need several RFC calls otherwise) when it's enabled and reachable, and transparently falls back to RFC (RPY_PROGRAM_READ / RPY_FUNCTIONMODULE_READ) otherwise — including on a live ADT failure, not just when it's disabled. You never need to choose the transport yourself; check the returned via field if you want to know which one actually served the read. function_group is required when object_type='function_module'.

Inputs: object_name (required), object_type (required), function_group. Returns: via, source, object_name, object_type, +1 more

rollback_rfc_transactionA
Destructive

Discard changes staged by prior write call_rfc_function calls in the identified SAP transaction (BAPI_TRANSACTION_ROLLBACK). Only available when the server policy mode is read_write.

Inputs: transaction_id (required). Returns: action, result, transaction_id

search_rfc_functionsA
Read-only

Search SAP for remote-enabled function modules (BAPIs/RFCs) by name pattern (supports '' wildcards, e.g. 'BAPI_CUSTOMER_'). Call this first to discover available functions before get_rfc_function_interface or call_rfc_function.

Inputs: pattern (required), group, limit. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct phase: search_rfc_functions discovers, get_rfc_function_interface inspects the signature, call_rfc_function executes, commit/rollback manage the transaction, and read_abap_source reads source. The descriptions reinforce the ordering (call search first, then get interface, then call), leaving no realistic basis for misselection.

    Naming Consistency5/5

    All six names follow a consistent snake_case verb_noun pattern (search_, get_, call_, commit_, rollback_, read_). No camelCase or stylistic mixing; the shared 'rfc' token further groups the related operations.

    Tool Count5/5

    Six tools is well-scoped for a single-domain RFC client, and each one earns its place by covering a distinct step of the discover-inspect-execute-commit lifecycle. Nothing redundant or trivial is present.

    Completeness4/5

    The surface covers the core lifecycle from discovery through read/write execution and transaction commit/rollback, plus ABAP source inspection. Minor gaps exist, such as no bulk/atomic multi-function call or dedicated structure/schema explorer, but agents can work around these via the interface tool.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to integrate with SAP systems via OData REST APIs for querying entity sets, performing CRUD operations, and executing function imports. It features automatic service discovery, CSRF token management, and smart connection handling without requiring the SAP RFC SDK.
      11
      13
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to securely connect with SAP ABAP and BTP services, allowing execution of function modules, BAPIs, table reads, and various BTP operations through MCP.
      1
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to read, write, activate, and transport ABAP code in SAP systems via ABAP ADT REST API, without needing SAP GUI.
      24
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants and n8n workflows to interact with SAP S/4HANA and ECC systems via OData, IDoc, and RFC/BAPI, with governed read-only-by-default access and multiple authentication types.
      3
      ISC