python-mcp-as400

python-mcp-as400

Enables AI assistants to securely interact with IBM i (AS/400) systems via ODBC, supporting SQL queries, CL commands, source code reading, compilation, and spoolfile analysis.

Category
Visit Server

README

AS/400 MCP Server

Python 3.10+ License: MIT MCP Compatible

Servidor MCP (Model Context Protocol) que conecta asistentes de IA con sistemas AS/400 (IBM i) de forma segura via ODBC.

Permite que un asistente de IA consulte bases de datos, lea codigo fuente, compile programas y analice spoolfiles en un IBM i — todo con controles de seguridad estrictos que impiden operaciones destructivas.


Herramientas disponibles

Herramienta Descripcion Ejemplo
execute_sql Ejecuta consultas SQL de solo lectura SELECT * FROM QSYS2.SYSTABLES FETCH FIRST 5 ROWS ONLY
execute_cl_command Ejecuta comandos CL permitidos (whitelist) DSPFD FILE(MYLIB/MYFILE) OUTPUT(*OUTFILE) OUTFILE(QTEMP/FDA)
read_source_member Lee el codigo fuente de un miembro biblioteca='MYLIB', archivo_fuente='QRPGLESRC', miembro='MYPGM'
compile_program Compila un programa (RPG, CL, COBOL, C) library='MYLIB', member='MYPGM', command='CRTBNDRPG'
read_spoolfile Lee spoolfiles (resultados de compilacion) Sin parametros lista los 10 mas recientes

Seguridad

Este servidor esta disenado para que la IA ayude sin riesgo. La filosofia es: analisis y compilacion si, destruccion nunca.

SQL — Solo lectura

  • Solo se permiten SELECT, WITH y VALUES
  • Se bloquean ; (statement stacking), SELECT INTO, CALL
  • Se eliminan comentarios SQL antes de evaluar
  • Si no se especifica limite, se agrega FETCH FIRST 1000 ROWS ONLY automaticamente

Comandos CL — Whitelist estricta

Solo se permiten comandos especificos. Todo lo demas es rechazado.

Permitidos:

Categoria Comandos
Visualizacion DSP* (DSPFD, DSPFFD, DSPPGMREF, DSPJOBLOG, DSPOBJD, DSPDBR, etc.)
Verificacion CHKOBJ
Compilacion CRTBNDRPG, CRTRPGMOD, CRTBNDCL, CRTSQLRPGI, CRTPGM, CRTSRVPGM, CRTBNDCBL, CRTSQLCBLI, CRTCMOD, CRTBNDC
Sesion ADDLIBLE, RMVLIBLE, CHGCURLIB
Overrides OVRDBF, DLTOVR

Bloqueados (ejemplos): DLTOBJ, DLTF, DLTLIB, CLRPFM, CHGOBJ, GRTOBJAUT, RVKOBJAUT, CALL, SBMJOB, CPYF, MOVOBJ, RNMOBJ, RUNSQLSTM y cualquier otro comando no listado arriba.

Identificadores validados

Todos los nombres de biblioteca, archivo y miembro se validan contra el patron AS/400: 1-10 caracteres, alfanumerico + #, @, $. Esto previene inyeccion SQL en sentencias DDL.

Errores sanitizados

Los mensajes de error nunca exponen credenciales, connection strings ni rutas internas del sistema.


Prerequisitos

  • Python 3.10 o superior
  • IBM i Access ODBC Driver instalado (descargar de IBM)
  • Acceso a un sistema IBM i (AS/400) con usuario y contrasena

Instalacion

1. Clonar el repositorio

git clone https://github.com/tu-usuario/as400-mcp-server.git
cd as400-mcp-server

2. Crear entorno virtual e instalar dependencias

python -m venv venv
source venv/bin/activate        # Linux/Mac
# venv\Scripts\activate         # Windows

pip install -e .

3. Configurar credenciales

cp .env.example .env
# Editar .env con tus credenciales de IBM i

4. Probar que funciona

python server.py

El servidor arranca via stdio esperando mensajes MCP (JSON-RPC).


Configuracion con Claude Desktop

Agrega lo siguiente a tu archivo de configuracion de Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "as400": {
      "command": "python",
      "args": ["C:/ruta/a/tu/as400-mcp-server/server.py"],
      "env": {
        "DB_HOST": "tu-host-ibmi.com",
        "DB_USER": "TU_USUARIO",
        "DB_PASS": "TU_PASSWORD"
      }
    }
  }
}

Nota: Tambien podes definir las variables en .env en vez de en el JSON.


Ejemplos de uso

Consultar tablas del sistema

"Mostrame las primeras 10 tablas de la biblioteca MYLIB"
→ execute_sql("SELECT TABLE_NAME, TABLE_TYPE FROM QSYS2.SYSTABLES WHERE TABLE_SCHEMA = 'MYLIB' FETCH FIRST 10 ROWS ONLY")

Ver estructura de un archivo

"Que campos tiene el archivo CUSTOMERS en MYLIB?"
→ execute_cl_command("DSPFFD FILE(MYLIB/CUSTOMERS) OUTPUT(*OUTFILE) OUTFILE(QTEMP/FLD)")
→ execute_sql("SELECT * FROM QTEMP.FLD")

Leer codigo fuente

"Mostrame el codigo del programa CALCPRICE"
→ read_source_member(biblioteca='MYLIB', archivo_fuente='QRPGLESRC', miembro='CALCPRICE')

Compilar y ver errores

"Compila el programa CALCPRICE y decime si hay errores"
→ compile_program(library='MYLIB', source_file='QRPGLESRC', member='CALCPRICE')
→ read_spoolfile()

Estructura del proyecto

as400-mcp-server/
├── server.py           # Servidor MCP principal
├── .env.example        # Template de configuracion
├── .gitignore          # Archivos excluidos de git
├── pyproject.toml      # Metadata del proyecto Python
├── LICENSE             # Licencia MIT
└── README.md           # Esta documentacion

Variables de entorno

Variable Descripcion Requerida
DB_HOST Hostname o IP del sistema IBM i Si
DB_USER Usuario de IBM i Si
DB_PASS Contrasena de IBM i Si

Contribuir

Las contribuciones son bienvenidas. Si queres agregar un comando CL a la whitelist o una nueva herramienta:

  1. Fork del repositorio
  2. Crea una branch (git checkout -b feature/mi-feature)
  3. Commit de tus cambios (git commit -m 'Agregar mi feature')
  4. Push a la branch (git push origin feature/mi-feature)
  5. Abri un Pull Request

Licencia

Este proyecto esta bajo la Licencia MIT.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured