Mainframe MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Mainframe MCP Server retrieve the JCL for job PAYROLL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Mainframe MCP Server
A Model Context Protocol (MCP) server for IBM z/OS mainframes. It exposes the RSE (Remote System Explorer) REST API — read datasets and members (COBOL, JCL, PROC, copybooks), manage datasets, and submit and monitor jobs — as MCP tools.
Because it speaks the MCP protocol, the same server works in every MCP-compatible client: VS Code (GitHub Copilot), Cursor, Claude Desktop, Gemini CLI, and more. Configure it once per client.
It ships as a single pure-Python package (httpx, no PowerShell) exposing
31 tools, so it runs anywhere — Linux containers, macOS, Windows — and is
publishable to PyPI and the MCP Registry.
Install (native package)
pip install mainframe-mcp # or, from the mcp-server folder: pip install -e .If public PyPI is blocked, use a mirror, e.g.
pip install --index-url https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com mainframe-mcp
This installs a mainframe-mcp command that speaks MCP over stdio.
Related MCP server: mcp-rs232
Configure (native)
Variable | Required | Default | Purpose |
| yes | — | RSE API hostname |
| no |
| RSE API port |
| no |
| API base path |
| yes | — | TSO user id |
| yes | — | TSO password |
| no | (off) |
|
| no |
| Segment → dataset map for the |
| no | generic names | Per-site segment names ( |
| no | (unset) |
|
| no | (unset) | Comma-separated dataset prefixes; write/destructive tools may only target these |
| no |
| JSONL audit trail (sensitive fields redacted) |
Copy pds_locations.sample.txt to pds_locations.txt and edit it for your site.
Client configuration
The native package installs a mainframe-mcp command. Point your client at it
and pass the endpoint + credentials via env.
VS Code (GitHub Copilot)
Add to .vscode/mcp.json in your workspace:
{
"servers": {
"mainframe": {
"type": "stdio",
"command": "mainframe-mcp",
"env": {
"MF_HOSTNAME": "your.host.example.com",
"MF_USERNAME": "${input:mf_username}",
"MF_PASSWORD": "${input:mf_password}"
}
}
}
}Cursor
Add to ~/.cursor/mcp.json (or .cursor/mcp.json in the project):
{
"mcpServers": {
"mainframe": {
"command": "mainframe-mcp",
"env": {
"MF_HOSTNAME": "your.host.example.com",
"MF_USERNAME": "you",
"MF_PASSWORD": "..."
}
}
}
}Claude Desktop
Add to claude_desktop_config.json
(%APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"mainframe": {
"command": "mainframe-mcp",
"env": {
"MF_HOSTNAME": "your.host.example.com",
"MF_USERNAME": "you",
"MF_PASSWORD": "..."
}
}
}
}Available tools (31)
Retrieval: get_cobol, get_copybook, get_ct1, get_jcl, get_proc,
get_job_docs, get_content, scan_source
Datasets: get_dataset_list, get_dataset_members, get_gdg_versions,
search_seq_datasets, create_dataset, create_dataset_like, delete_dataset,
rename_dataset, recall_dataset, copy_member, modify_module, upload_member
Jobs: submit_job, submit_jcl_string, get_job_status,
get_job_steps, get_job_files, get_job_file_content, get_job_jcl,
get_job_notification, get_spool_details, export_spool_to_dataset
TSO: run_tso_command
Architecture
Components:
Layer | File | Role |
Transport / entry |
| Registers tools, speaks MCP over stdio |
Safety layer |
| Intent annotations, read-only mode, confirm guards, scope allowlist, audit |
RSE client |
| Pure-Python |
Config | env + | Endpoint, credentials, segment → dataset map |
What happens on a tool call:
sequenceDiagram
participant C as MCP client
participant S as server_native (FastMCP)
participant W as mf_tool + _run
participant SF as Safety (mcp_common)
participant R as RSEClient (httpx)
participant MF as RSE API
C->>S: tools/call get_cobol(["PROG1"])
S->>W: dispatch tool
W->>SF: _dsn_allowed? / _needs_confirmation?
alt blocked
SF-->>C: {status:"error"|"needs_confirmation"}
else allowed
W->>W: _client() builds creds (MF_* env)
W->>R: client.read_member(dsn)
R->>MF: GET /datasets/{dsn}/content (Basic auth, TLS)
MF-->>R: 200 + records
R-->>W: unwrap_records()
W->>SF: _audit(tool, args, "success", ms)
W-->>C: {status:"success", data:{...}}
endSafety gates, in order:
Registration filter —
MF_READ_ONLY=1means the 10 write + 4 destructive tools are never registered (clients see only the 20 read tools).Scope allowlist —
MF_ALLOWED_DSNrejects out-of-scope datasets before any network call.Confirm guard — destructive tools return
needs_confirmationunless called withconfirm=true.Per-session credentials — creds come from
MF_*env (or a per-session override); missing creds return a clean error.Audit — every call appends a redacted JSONL line (tool, args, status, duration).
The safety layer (mcp_common.py) and RSE client (rse_client.py) are
transport-agnostic, so the same tool bodies can be reused behind another
transport (e.g. an HTTP/OAuth front end) without changing the mainframe logic.
Deploy
python -m build # -> dist/mainframe_mcp-<ver>-py3-none-any.whl + .tar.gz
twine upload dist/* # publish to PyPIThen submit server.json to the MCP Registry. Users install with
pip install mainframe-mcp and point their MCP client at the mainframe-mcp
command with MF_HOSTNAME / MF_USERNAME / MF_PASSWORD set (see above).
Hosting over HTTP (Render, Cloud Run, ...)
To run as a hosted service instead of stdio, server_http.py serves the same
tools over MCP streamable-HTTP at /mcp, guarded by a bearer token.
Local:
pip install -e ".[http]"
$env:MF_MCP_TOKEN="secret"; $env:MF_HOSTNAME="..."; $env:MF_USERNAME="..."; $env:MF_PASSWORD="..."
python server_http.py # clients connect to http://localhost:8000/mcp
# with header: Authorization: Bearer secretRender: a Dockerfile and render.yaml are included. In Render →
New → Blueprint / Web Service from the (private) repo — it reads
render.yaml, generates MF_MCP_TOKEN, and you set MF_HOSTNAME /
MF_USERNAME / MF_PASSWORD in the dashboard. Endpoint:
https://<your-app>.onrender.com/mcp.
Security: these tools can modify datasets and submit jobs. Keep
MF_MCP_TOKEN set, serve only over HTTPS (Render terminates TLS), and prefer
MF_READ_ONLY=1 (the render.yaml default). The host must also be able to
reach your mainframe's RSE API — a public host cannot reach an internal
z/OS system without a tunnel or VPN.
Available Tools
30 toolscopy_memberC
Copy a member from one dataset to another (DATASET(MEMBER) notation).
Inputs: source_dataset (required), destination_dataset (required). Returns: result
create_datasetC
Create a new mainframe dataset.
Inputs: name (required), primary, dsn_type, secondary, +12 more. Returns: result
create_dataset_likeB
Allocate a new dataset with the same attributes as an existing one.
Inputs: new_dataset (required), source_dataset (required), primary, secondary, +3 more. Returns: result
delete_datasetADestructive
Delete a mainframe dataset. IRREVERSIBLE. Requires confirm=true.
Inputs: dataset_name (required), confirm. Returns: result
export_spool_to_datasetC
Export a job's spool file (by file id) to a mainframe dataset.
Inputs: job_id (required), file_id (required), job_name (required), destination_dataset (required), +1 more. Returns: result
get_cobolBRead-only
Retrieve COBOL programs by searching the configured COBOL PDS locations.
Inputs: prog_names (required). Returns: result
get_contentBRead-only
Fetch dataset/member content. Provide dataset (+optional member), or a comma/space-separated pds_list to search for a member. max_rows truncates.
Inputs: member, dataset, max_rows, pds_list. Returns: result
get_copybookARead-only
Retrieve copybook members from the configured copybook PDS locations.
Inputs: copybook_names (required). Returns: result
get_ct1BRead-only
Retrieve control-card (CT1) members from the configured CT1 PDS locations.
Inputs: ct1_names (required). Returns: result
get_dataset_listARead-only
List datasets matching a pattern/filter.
Inputs: dataset_pattern (required). Returns: result
get_gdg_versionsBRead-only
List generations of a GDG base (via LISTCAT).
Inputs: gdg_base (required). Returns: result
get_jclBRead-only
Retrieve JCL members from the configured JCL PDS locations.
Inputs: job_names (required). Returns: result
get_job_docsARead-only
Retrieve job documentation members from the configured job-doc locations.
Inputs: job_names (required). Returns: result
get_job_file_contentCRead-only
Read a specific spool file of a job by file id.
Inputs: job_id (required), file_id (required), job_name (required). Returns: result
get_job_filesBRead-only
List spool/output files (DD names) for a job.
Inputs: job_id (required), job_name (required). Returns: result
get_job_jclBRead-only
Retrieve the JCL used for a submitted/completed job.
Inputs: job_id (required), job_name (required). Returns: result
get_job_notificationBRead-only
Check completion-notification status for a job id.
Inputs: job_id (required). Returns: result
get_job_statusBRead-only
Get the status of a job by name and JES id.
Inputs: job_id (required), job_name (required). Returns: result
get_job_stepsBRead-only
Get step-level details/return codes for a job.
Inputs: job_id (required), job_name (required). Returns: result
get_procBRead-only
Retrieve PROC members from the configured PROC PDS locations.
Inputs: proc_names (required). Returns: result
get_spool_detailsARead-only
List jobs (and spool details) matching an optional job-name prefix.
Inputs: job_prefix. Returns: result
modify_moduleADestructive
Overwrite a dataset member's content. IRREVERSIBLE. Requires confirm=true.
Inputs: content (required), dataset_name (required), confirm. Returns: result
recall_datasetB
Recall a migrated dataset from tape/HSM back to disk.
Inputs: dataset_name (required). Returns: result
rename_datasetADestructive
Rename a mainframe dataset. IRREVERSIBLE. Requires confirm=true.
Inputs: new_name (required), old_name (required), confirm. Returns: result
run_tso_commandADestructive
Execute an arbitrary TSO command. Can be destructive. Requires confirm=true.
Inputs: command (required), confirm. Returns: result
scan_sourceBRead-only
Scan a mainframe source path to detect language and references.
Inputs: path (required). Returns: result
search_seq_datasetsCRead-only
Search sequential datasets matching filter for optional content.
Inputs: filter (required), content, max_results, regex_content, +1 more. Returns: result
submit_jcl_stringC
Submit raw JCL text directly to JES.
Inputs: jcl_text (required). Returns: result
submit_jobB
Submit a JCL job from a PDS member (DATASET(MEMBER)).
Inputs: dataset_member (required), no_notification. Returns: result
upload_memberA
Upload text to a PDS member or sequential dataset. Provide content
(preferred for remote use) or a server-side local_file path.
Inputs: target_dataset (required), content, local_file, member_name. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 30 tools
Many tools follow a clear get_<artifact> pattern (COBOL, copybook, CT1, JCL, PROC), and the job-status/spool tools are distinct. However, generic get_content overlaps heavily with the specialized getters, and get_jcl vs get_job_jcl plus upload_member vs modify_module create potential confusion.
Tool names overwhelmingly use snake_case verb_noun, with clear verbs like get, submit, create, delete. Minor inconsistencies exist (get_cobol vs get_content, search_seq_datasets uses an abbreviation, create_dataset_like) but the pattern is predictable.
At 30 tools, the server is over-scoped for a coherent set. Many specialized getters could be consolidated into get_content, and the job-spool area has four overlapping tools. A more focused set of 15-20 would be stronger.
The set covers dataset lifecycle (create, delete, rename, recall, copy, modify), source retrieval, and full job submission/status/spool flow. Missing member-level deletion and a direct list-members operation are minor gaps.
Related MCP Connectors
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Cloud-hosted MCP server for secure AI access to enterprise data sources via CData Connect AI.
2,000+ MCP servers read at source level. Know what one does before you connect. Free, no key.
Related MCP Servers
- AlicenseBqualityDmaintenanceMCP server for Redmine project management, enabling tools for managing projects, issues, users, time entries, groups, memberships, versions, wiki, news, attachments, search, and Agile sprints via the Redmine REST API.891MIT
- AlicenseAqualityDmaintenanceAn MCP server that exposes RS232 serial port connectivity, enabling listing, opening, reading, and writing to serial ports via tools and resources.617 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to interact with IBM i AS/400 source members for source code management, compilation, and development workflows.7MIT
- FlicenseNot gradedqualityCmaintenanceMulti-system MCP server for reading and writing ABAP source via SAP ADT, with write safety controls and a local web admin.2-