@ibm/ibmi-mcp-server 0.1.2 โ†’ 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/README.md +2178 -46
  2. package/dist/config/index.d.ts +2 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/index.js +57 -24
  5. package/dist/config/index.js.map +1 -1
  6. package/dist/config/resolver.d.ts.map +1 -1
  7. package/dist/config/resolver.js.map +1 -1
  8. package/dist/ibmi-mcp-server/auth/httpAuthEndpoint.js +1 -1
  9. package/dist/ibmi-mcp-server/services/connectionPool.js +2 -2
  10. package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts +80 -0
  11. package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts.map +1 -0
  12. package/dist/ibmi-mcp-server/tools/executeSql.tool.js +356 -0
  13. package/dist/ibmi-mcp-server/tools/executeSql.tool.js.map +1 -0
  14. package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts +36 -0
  15. package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts.map +1 -0
  16. package/dist/ibmi-mcp-server/tools/generateSql.tool.js +281 -0
  17. package/dist/ibmi-mcp-server/tools/generateSql.tool.js.map +1 -0
  18. package/dist/ibmi-mcp-server/tools/index.d.ts +85 -0
  19. package/dist/ibmi-mcp-server/tools/index.d.ts.map +1 -0
  20. package/dist/ibmi-mcp-server/tools/index.js +21 -0
  21. package/dist/ibmi-mcp-server/tools/index.js.map +1 -0
  22. package/dist/ibmi-mcp-server/utils/config/configParser.d.ts +9 -0
  23. package/dist/ibmi-mcp-server/utils/config/configParser.d.ts.map +1 -1
  24. package/dist/ibmi-mcp-server/utils/config/configParser.js +58 -0
  25. package/dist/ibmi-mcp-server/utils/config/configParser.js.map +1 -1
  26. package/dist/ibmi-mcp-server/utils/config/toolConfigBuilder.js +1 -1
  27. package/dist/ibmi-mcp-server/utils/config/toolConfigBuilder.js.map +1 -1
  28. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts +4 -4
  29. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts.map +1 -1
  30. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js +7 -8
  31. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js.map +1 -1
  32. package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts +0 -8
  33. package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts.map +1 -1
  34. package/dist/ibmi-mcp-server/utils/config/toolFactory.js +0 -31
  35. package/dist/ibmi-mcp-server/utils/config/toolFactory.js.map +1 -1
  36. package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts +1 -1
  37. package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts.map +1 -1
  38. package/dist/ibmi-mcp-server/utils/config/toolsetManager.js +2 -2
  39. package/dist/ibmi-mcp-server/utils/config/toolsetManager.js.map +1 -1
  40. package/dist/ibmi-mcp-server/utils/language/document.d.ts +26 -0
  41. package/dist/ibmi-mcp-server/utils/language/document.d.ts.map +1 -0
  42. package/dist/ibmi-mcp-server/utils/language/document.js +318 -0
  43. package/dist/ibmi-mcp-server/utils/language/document.js.map +1 -0
  44. package/dist/ibmi-mcp-server/utils/language/statement.d.ts +43 -0
  45. package/dist/ibmi-mcp-server/utils/language/statement.d.ts.map +1 -0
  46. package/dist/ibmi-mcp-server/utils/language/statement.js +796 -0
  47. package/dist/ibmi-mcp-server/utils/language/statement.js.map +1 -0
  48. package/dist/ibmi-mcp-server/utils/language/tokens.d.ts +32 -0
  49. package/dist/ibmi-mcp-server/utils/language/tokens.d.ts.map +1 -0
  50. package/dist/ibmi-mcp-server/utils/language/tokens.js +532 -0
  51. package/dist/ibmi-mcp-server/utils/language/tokens.js.map +1 -0
  52. package/dist/ibmi-mcp-server/utils/language/types.d.ts +138 -0
  53. package/dist/ibmi-mcp-server/utils/language/types.d.ts.map +1 -0
  54. package/dist/ibmi-mcp-server/utils/language/types.js +93 -0
  55. package/dist/ibmi-mcp-server/utils/language/types.js.map +1 -0
  56. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts +48 -0
  57. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts.map +1 -0
  58. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js +93 -0
  59. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js.map +1 -0
  60. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts +35 -59
  61. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts.map +1 -1
  62. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js +108 -288
  63. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js.map +1 -1
  64. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts +54 -0
  65. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts.map +1 -0
  66. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js +91 -0
  67. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js.map +1 -0
  68. package/dist/index.js +4 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/mcp-server/tools/index.d.ts +13 -2
  71. package/dist/mcp-server/tools/index.d.ts.map +1 -1
  72. package/dist/mcp-server/tools/index.js +29 -9
  73. package/dist/mcp-server/tools/index.js.map +1 -1
  74. package/dist/mcp-server/tools/utils/index.d.ts +7 -0
  75. package/dist/mcp-server/tools/utils/index.d.ts.map +1 -0
  76. package/dist/mcp-server/tools/utils/index.js +7 -0
  77. package/dist/mcp-server/tools/utils/index.js.map +1 -0
  78. package/dist/mcp-server/tools/utils/tool-factory.d.ts +129 -0
  79. package/dist/mcp-server/tools/utils/tool-factory.d.ts.map +1 -0
  80. package/dist/mcp-server/tools/utils/tool-factory.js +179 -0
  81. package/dist/mcp-server/tools/utils/tool-factory.js.map +1 -0
  82. package/dist/mcp-server/tools/utils/types.d.ts +117 -0
  83. package/dist/mcp-server/tools/utils/types.d.ts.map +1 -0
  84. package/dist/mcp-server/tools/utils/types.js +11 -0
  85. package/dist/mcp-server/tools/utils/types.js.map +1 -0
  86. package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts +26 -0
  87. package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts.map +1 -0
  88. package/dist/mcp-server/transports/core/cleanupTransformStream.js +60 -0
  89. package/dist/mcp-server/transports/core/cleanupTransformStream.js.map +1 -0
  90. package/dist/mcp-server/transports/core/statefulTransportManager.d.ts +1 -1
  91. package/dist/mcp-server/transports/core/statefulTransportManager.d.ts.map +1 -1
  92. package/dist/mcp-server/transports/core/statefulTransportManager.js +50 -40
  93. package/dist/mcp-server/transports/core/statefulTransportManager.js.map +1 -1
  94. package/dist/mcp-server/transports/core/statelessTransportManager.d.ts +2 -13
  95. package/dist/mcp-server/transports/core/statelessTransportManager.d.ts.map +1 -1
  96. package/dist/mcp-server/transports/core/statelessTransportManager.js +35 -62
  97. package/dist/mcp-server/transports/core/statelessTransportManager.js.map +1 -1
  98. package/dist/mcp-server/transports/core/transportRequest.d.ts +1 -2
  99. package/dist/mcp-server/transports/core/transportRequest.d.ts.map +1 -1
  100. package/dist/mcp-server/transports/http/mcpTransportMiddleware.d.ts.map +1 -1
  101. package/dist/mcp-server/transports/http/mcpTransportMiddleware.js +1 -3
  102. package/dist/mcp-server/transports/http/mcpTransportMiddleware.js.map +1 -1
  103. package/dist/utils/internal/logger.d.ts +5 -0
  104. package/dist/utils/internal/logger.d.ts.map +1 -1
  105. package/dist/utils/internal/logger.js +65 -36
  106. package/dist/utils/internal/logger.js.map +1 -1
  107. package/package.json +29 -23
  108. package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts +0 -9
  109. package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts.map +0 -1
  110. package/dist/ibmi-mcp-server/tools/executeSql/index.js +0 -9
  111. package/dist/ibmi-mcp-server/tools/executeSql/index.js.map +0 -1
  112. package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts +0 -51
  113. package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts.map +0 -1
  114. package/dist/ibmi-mcp-server/tools/executeSql/logic.js +0 -179
  115. package/dist/ibmi-mcp-server/tools/executeSql/logic.js.map +0 -1
  116. package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts +0 -52
  117. package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts.map +0 -1
  118. package/dist/ibmi-mcp-server/tools/executeSql/registration.js +0 -161
  119. package/dist/ibmi-mcp-server/tools/executeSql/registration.js.map +0 -1
  120. package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts +0 -13
  121. package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts.map +0 -1
  122. package/dist/ibmi-mcp-server/tools/generateSql/index.js +0 -13
  123. package/dist/ibmi-mcp-server/tools/generateSql/index.js.map +0 -1
  124. package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts +0 -64
  125. package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts.map +0 -1
  126. package/dist/ibmi-mcp-server/tools/generateSql/logic.js +0 -190
  127. package/dist/ibmi-mcp-server/tools/generateSql/logic.js.map +0 -1
  128. package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts +0 -18
  129. package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts.map +0 -1
  130. package/dist/ibmi-mcp-server/tools/generateSql/registration.js +0 -64
  131. package/dist/ibmi-mcp-server/tools/generateSql/registration.js.map +0 -1
  132. package/dist/mcp-server/tools/catFactFetcher/index.d.ts +0 -8
  133. package/dist/mcp-server/tools/catFactFetcher/index.d.ts.map +0 -1
  134. package/dist/mcp-server/tools/catFactFetcher/index.js +0 -8
  135. package/dist/mcp-server/tools/catFactFetcher/index.js.map +0 -1
  136. package/dist/mcp-server/tools/catFactFetcher/logic.d.ts +0 -52
  137. package/dist/mcp-server/tools/catFactFetcher/logic.d.ts.map +0 -1
  138. package/dist/mcp-server/tools/catFactFetcher/logic.js +0 -95
  139. package/dist/mcp-server/tools/catFactFetcher/logic.js.map +0 -1
  140. package/dist/mcp-server/tools/catFactFetcher/registration.d.ts +0 -9
  141. package/dist/mcp-server/tools/catFactFetcher/registration.d.ts.map +0 -1
  142. package/dist/mcp-server/tools/catFactFetcher/registration.js +0 -43
  143. package/dist/mcp-server/tools/catFactFetcher/registration.js.map +0 -1
  144. package/dist/mcp-server/tools/echoTool/index.d.ts +0 -13
  145. package/dist/mcp-server/tools/echoTool/index.d.ts.map +0 -1
  146. package/dist/mcp-server/tools/echoTool/index.js +0 -13
  147. package/dist/mcp-server/tools/echoTool/index.js.map +0 -1
  148. package/dist/mcp-server/tools/echoTool/logic.d.ts +0 -69
  149. package/dist/mcp-server/tools/echoTool/logic.d.ts.map +0 -1
  150. package/dist/mcp-server/tools/echoTool/logic.js +0 -119
  151. package/dist/mcp-server/tools/echoTool/logic.js.map +0 -1
  152. package/dist/mcp-server/tools/echoTool/registration.d.ts +0 -9
  153. package/dist/mcp-server/tools/echoTool/registration.d.ts.map +0 -1
  154. package/dist/mcp-server/tools/echoTool/registration.js +0 -45
  155. package/dist/mcp-server/tools/echoTool/registration.js.map +0 -1
  156. package/dist/mcp-server/tools/imageTest/index.d.ts +0 -7
  157. package/dist/mcp-server/tools/imageTest/index.d.ts.map +0 -1
  158. package/dist/mcp-server/tools/imageTest/index.js +0 -7
  159. package/dist/mcp-server/tools/imageTest/index.js.map +0 -1
  160. package/dist/mcp-server/tools/imageTest/logic.d.ts +0 -27
  161. package/dist/mcp-server/tools/imageTest/logic.d.ts.map +0 -1
  162. package/dist/mcp-server/tools/imageTest/logic.js +0 -44
  163. package/dist/mcp-server/tools/imageTest/logic.js.map +0 -1
  164. package/dist/mcp-server/tools/imageTest/registration.d.ts +0 -9
  165. package/dist/mcp-server/tools/imageTest/registration.d.ts.map +0 -1
  166. package/dist/mcp-server/tools/imageTest/registration.js +0 -49
  167. package/dist/mcp-server/tools/imageTest/registration.js.map +0 -1
  168. package/dist/mcp-server/tools/utils/tool-utils.d.ts +0 -43
  169. package/dist/mcp-server/tools/utils/tool-utils.d.ts.map +0 -1
  170. package/dist/mcp-server/tools/utils/tool-utils.js +0 -44
  171. package/dist/mcp-server/tools/utils/tool-utils.js.map +0 -1
  172. package/dist/mcp-server/transports/core/headerUtils.d.ts +0 -27
  173. package/dist/mcp-server/transports/core/headerUtils.d.ts.map +0 -1
  174. package/dist/mcp-server/transports/core/headerUtils.js +0 -53
  175. package/dist/mcp-server/transports/core/headerUtils.js.map +0 -1
  176. package/dist/mcp-server/transports/core/honoNodeBridge.d.ts +0 -77
  177. package/dist/mcp-server/transports/core/honoNodeBridge.d.ts.map +0 -1
  178. package/dist/mcp-server/transports/core/honoNodeBridge.js +0 -150
  179. package/dist/mcp-server/transports/core/honoNodeBridge.js.map +0 -1
  180. package/dist/services/duck-db/duckDBConnectionManager.d.ts +0 -55
  181. package/dist/services/duck-db/duckDBConnectionManager.d.ts.map +0 -1
  182. package/dist/services/duck-db/duckDBConnectionManager.js +0 -184
  183. package/dist/services/duck-db/duckDBConnectionManager.js.map +0 -1
  184. package/dist/services/duck-db/duckDBQueryExecutor.d.ts +0 -18
  185. package/dist/services/duck-db/duckDBQueryExecutor.d.ts.map +0 -1
  186. package/dist/services/duck-db/duckDBQueryExecutor.js +0 -115
  187. package/dist/services/duck-db/duckDBQueryExecutor.js.map +0 -1
  188. package/dist/services/duck-db/duckDBService.d.ts +0 -27
  189. package/dist/services/duck-db/duckDBService.d.ts.map +0 -1
  190. package/dist/services/duck-db/duckDBService.js +0 -151
  191. package/dist/services/duck-db/duckDBService.js.map +0 -1
  192. package/dist/services/duck-db/types.d.ts +0 -135
  193. package/dist/services/duck-db/types.d.ts.map +0 -1
  194. package/dist/services/duck-db/types.js +0 -6
  195. package/dist/services/duck-db/types.js.map +0 -1
  196. package/dist/services/llm-providers/openRouterProvider.d.ts +0 -36
  197. package/dist/services/llm-providers/openRouterProvider.d.ts.map +0 -1
  198. package/dist/services/llm-providers/openRouterProvider.js +0 -235
  199. package/dist/services/llm-providers/openRouterProvider.js.map +0 -1
  200. package/dist/services/supabase/supabaseClient.d.ts +0 -25
  201. package/dist/services/supabase/supabaseClient.d.ts.map +0 -1
  202. package/dist/services/supabase/supabaseClient.js +0 -68
  203. package/dist/services/supabase/supabaseClient.js.map +0 -1
  204. package/dist/storage/duckdbExample.d.ts +0 -8
  205. package/dist/storage/duckdbExample.d.ts.map +0 -1
  206. package/dist/storage/duckdbExample.js +0 -197
  207. package/dist/storage/duckdbExample.js.map +0 -1
package/README.md CHANGED
@@ -1,88 +1,2220 @@
1
1
  # IBM i MCP Server
2
2
 
3
- The Model Context Protocol (MCP) server for IBM i systems.
3
+ <details>
4
4
 
5
- ## Quick Start
5
+ <summary><strong>Table of Contents</strong></summary>
6
+
7
+ - [IBM i MCP Server](#ibm-i-mcp-server)
8
+ - [โšก Quickstart](#-quickstart)
9
+ - [1. Create Configuration File](#1-create-configuration-file)
10
+ - [2. Create a Simple SQL Tool](#2-create-a-simple-sql-tool)
11
+ - [3. Set Configuration Path](#3-set-configuration-path)
12
+ - [4. Run the Server](#4-run-the-server)
13
+ - [5. Verify Server is Running](#5-verify-server-is-running)
14
+ - [6. Test with Python Client (Optional)](#6-test-with-python-client-optional)
15
+ - [๐ŸŽฏ What's Next?](#-whats-next)
16
+ - [CLI Reference](#cli-reference)
17
+ - [Basic Usage](#basic-usage)
18
+ - [Available Options](#available-options)
19
+ - [๐Ÿ”Œ Installing in MCP Clients](#-installing-in-mcp-clients)
20
+ - [Prerequisites: Local Installation](#prerequisites-local-installation)
21
+ - [Remote Server Setup](#remote-server-setup)
22
+ - [Client Configurations](#client-configurations)
23
+ - [๐Ÿงฉ SQL Tool Configuration](#-sql-tool-configuration)
24
+ - [Sources](#sources)
25
+ - [Tools](#tools)
26
+ - [Toolsets](#toolsets)
27
+ - [๐Ÿค– IBM i Agents](#-ibm-i-agents)
28
+ - [Key Features](#key-features)
29
+ - [Getting Started](#getting-started)
30
+ - [โš™๏ธ Configuration](#๏ธ-configuration)
31
+ - [General Authentication](#general-authentication)
32
+ - [JWT Authentication](#jwt-authentication)
33
+ - [OAuth Authentication](#oauth-authentication)
34
+ - [IBM i HTTP Authentication](#ibm-i-http-authentication)
35
+ - [Tool Loading](#tool-loading)
36
+ - [Configuration Merging](#configuration-merging)
37
+ - [Configuration Best Practices](#configuration-best-practices)
38
+ - [๐Ÿ” IBM i HTTP Authentication (Beta)](#-ibm-i-http-authentication-beta)
39
+ - [Authentication Flow](#authentication-flow)
40
+ - [Configuration](#configuration)
41
+ - [Getting Access Tokens](#getting-access-tokens)
42
+ - [Option 1: Using the Token Script (Recommended)](#option-1-using-the-token-script-recommended)
43
+ - [Sequence Overview](#sequence-overview)
44
+ - [Client Integration](#client-integration)
45
+ - [Security Considerations](#security-considerations)
46
+ - [Authentication Endpoints](#authentication-endpoints)
47
+ - [๐Ÿ› ๏ธ Running the Server (Development)](#๏ธ-running-the-server-development)
48
+ - [Building from Source](#building-from-source)
49
+ - [Transport Modes](#transport-modes)
50
+ - [HTTP Transport (Recommended for Development)](#http-transport-recommended-for-development)
51
+ - [Stdio Transport (for CLI tools and MCP Inspector)](#stdio-transport-for-cli-tools-and-mcp-inspector)
52
+ - [Session Modes (HTTP Only)](#session-modes-http-only)
53
+ - [CLI Options](#cli-options)
54
+ - [Common Development Scenarios](#common-development-scenarios)
55
+ - [Development Tips](#development-tips)
56
+ - [Troubleshooting](#troubleshooting)
57
+ - [๐Ÿ•ต๏ธโ€โ™‚๏ธ MCP Inspector](#๏ธ๏ธ-mcp-inspector)
58
+ - [Deployment](#deployment)
59
+ - [๐Ÿ—๏ธ Built With MCP TypeScript Template](#๏ธ-built-with-mcp-typescript-template)
60
+ - [Template Features Used](#template-features-used)
61
+ - [Why This Template?](#why-this-template)
62
+ - [Customizations for IBM i](#customizations-for-ibm-i)
63
+ - [Get Started with the Template](#get-started-with-the-template)
64
+
65
+ </details>
66
+
67
+ ---
68
+
69
+ ## โšก Quickstart
70
+
71
+ Get started with the IBM i MCP Server using the official npm package.
72
+
73
+ ### 1. Create Configuration File
74
+
75
+ Create a `.env` file with your IBM i connection details:
76
+
77
+ ```bash
78
+ cat > .env << 'EOF'
79
+ # IBM i DB2 for i Connection Settings
80
+ DB2i_HOST=your-ibmi-host.com
81
+ DB2i_USER=your-username
82
+ DB2i_PASS=your-password
83
+ DB2i_PORT=8076
84
+ DB2i_IGNORE_UNAUTHORIZED=true
85
+
86
+ # MCP Server Settings
87
+ MCP_TRANSPORT_TYPE=http
88
+ MCP_HTTP_PORT=3010
89
+ MCP_LOG_LEVEL=info
90
+
91
+ # Tools Configuration
92
+ TOOLS_YAML_PATH=./tools
93
+ EOF
94
+ ```
95
+
96
+ > **๐Ÿ“– Configuration Guide:** See the complete [Configuration](#โš™๏ธ-configuration) section for all available settings.
97
+
98
+ ### 2. Create a Simple SQL Tool
99
+
100
+ Create a `tools` directory and a basic tool configuration file:
101
+
102
+ ```bash
103
+ mkdir -p tools
104
+ ```
105
+
106
+ <details>
107
+ <summary><strong>๐Ÿ“„ Click to copy: tools/quickstart.yaml</strong></summary>
108
+
109
+ ```yaml
110
+ sources:
111
+ ibmi-system:
112
+ host: ${DB2i_HOST}
113
+ user: ${DB2i_USER}
114
+ password: ${DB2i_PASS}
115
+ port: 8076
116
+ ignore-unauthorized: true
117
+
118
+ tools:
119
+ system_status:
120
+ source: ibmi-system
121
+ description: "Overall system performance statistics with CPU, memory, and I/O metrics"
122
+ parameters: []
123
+ statement: |
124
+ SELECT * FROM TABLE(QSYS2.SYSTEM_STATUS(RESET_STATISTICS=>'YES',DETAILED_INFO=>'ALL')) X
125
+
126
+ system_activity:
127
+ source: ibmi-system
128
+ description: "Current system activity information including active jobs and resource utilization"
129
+ parameters: []
130
+ statement: |
131
+ SELECT * FROM TABLE(QSYS2.SYSTEM_ACTIVITY_INFO())
132
+
133
+ active_job_info:
134
+ source: ibmi-system
135
+ description: "Find the top 10 consumers of CPU in the QUSRWRK and QSYSWRK subsystems"
136
+ parameters:
137
+ - name: limit
138
+ type: integer
139
+ default: 10
140
+ description: "Number of top CPU consumers to return"
141
+ statement: |
142
+ SELECT CPU_TIME, A.* FROM
143
+ TABLE(QSYS2.ACTIVE_JOB_INFO(SUBSYSTEM_LIST_FILTER => 'QUSRWRK,QSYSWRK')) A
144
+ ORDER BY CPU_TIME DESC
145
+ FETCH FIRST :limit ROWS ONLY
146
+
147
+ toolsets:
148
+ performance:
149
+ tools:
150
+ - system_status
151
+ - system_activity
152
+ - active_job_info
153
+ ```
154
+
155
+ </details>
156
+
157
+ Create the file:
158
+
159
+ ```bash
160
+ cat > tools/quickstart.yaml << 'EOF'
161
+ sources:
162
+ ibmi-system:
163
+ host: ${DB2i_HOST}
164
+ user: ${DB2i_USER}
165
+ password: ${DB2i_PASS}
166
+ port: 8076
167
+ ignore-unauthorized: true
168
+
169
+ tools:
170
+ system_status:
171
+ source: ibmi-system
172
+ description: "Overall system performance statistics with CPU, memory, and I/O metrics"
173
+ parameters: []
174
+ statement: |
175
+ SELECT * FROM TABLE(QSYS2.SYSTEM_STATUS(RESET_STATISTICS=>'YES',DETAILED_INFO=>'ALL')) X
176
+
177
+ system_activity:
178
+ source: ibmi-system
179
+ description: "Current system activity information including active jobs and resource utilization"
180
+ parameters: []
181
+ statement: |
182
+ SELECT * FROM TABLE(QSYS2.SYSTEM_ACTIVITY_INFO())
183
+
184
+ active_job_info:
185
+ source: ibmi-system
186
+ description: "Find the top 10 consumers of CPU in the QUSRWRK and QSYSWRK subsystems"
187
+ parameters:
188
+ - name: limit
189
+ type: integer
190
+ default: 10
191
+ description: "Number of top CPU consumers to return"
192
+ statement: |
193
+ SELECT CPU_TIME, A.* FROM
194
+ TABLE(QSYS2.ACTIVE_JOB_INFO(SUBSYSTEM_LIST_FILTER => 'QUSRWRK,QSYSWRK')) A
195
+ ORDER BY CPU_TIME DESC
196
+ FETCH FIRST :limit ROWS ONLY
197
+
198
+ toolsets:
199
+ performance:
200
+ tools:
201
+ - system_status
202
+ - system_activity
203
+ - active_job_info
204
+ EOF
205
+ ```
206
+
207
+ This creates three tools:
208
+ - **`system_status`** - System performance metrics
209
+ - **`system_activity`** - Current activity information
210
+ - **`active_job_info`** - Top CPU consumers (with customizable limit parameter)
211
+
212
+ > [!NOTE]
213
+ > **๐Ÿ“– More Tools:** The repository includes many ready-to-use tools in the [`tools/`](../tools/) directory covering performance monitoring, security, job management, and more. See [SQL Tool Configuration](#-sql-tool-configuration) to create your own custom tools.
214
+
215
+ ### 3. Set Configuration Path
216
+
217
+ Point the server to your configuration file using the `MCP_SERVER_CONFIG` environment variable:
218
+
219
+ ```bash
220
+ # Set configuration file path
221
+ export MCP_SERVER_CONFIG=.env
222
+ ```
223
+
224
+ > **Note:** CLI arguments override settings in the configuration file.
225
+
226
+ ### 4. Run the Server
227
+
228
+ Start the server in HTTP mode with your new tools:
229
+
230
+ ```bash
231
+ # Start the server with HTTP transport
232
+ npx -y @ibm/ibmi-mcp-server@latest --transport http --tools ./tools/quckstart.yaml
233
+ ```
234
+
235
+ The server will:
236
+ - Load configuration from `.env` (via `MCP_SERVER_CONFIG`)
237
+ - Connect to your IBM i system via Mapepire
238
+ - Start on `http://localhost:3010/mcp`
239
+ - Load the SQL tools from `tools/quickstart.yaml`
240
+
241
+
242
+
243
+ ### 5. Verify Server is Running
244
+
245
+ Test the server endpoint:
246
+
247
+ ```bash
248
+ # Check health
249
+ curl http://localhost:3010/healthz
250
+
251
+ # List available tools (requires running server)
252
+ curl -X POST http://localhost:3010/mcp \
253
+ -H "Content-Type: application/json" \
254
+ -d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":1}'
255
+ ```
256
+
257
+ ### 6. Test with Python Client (Optional)
258
+
259
+ Install and run the example Python client:
260
+
261
+ ```bash
262
+ # Navigate to client directory
263
+ cd client/
264
+
265
+ # Install dependencies with uv
266
+ uv sync
267
+
268
+ # List available tools
269
+ uv run mcp_client.py
270
+
271
+ # Run agent with LLM (requires API key)
272
+ export OPENAI_API_KEY=your-api-key
273
+ uv run agent.py -p "What is my system status?"
274
+ ```
275
+
276
+ > **๐Ÿ“– Client Documentation:** See [client/README.md](../client/README.md) for detailed setup instructions.
277
+
278
+ > [!TIP]
279
+ > **Explore More SQL Tools:** The `tools/` directory contains many ready-to-use SQL tool configurations for common IBM i tasks. Browse the collection and customize them for your needs. See the [Tools Guide](../tools/README.md) for more details.
280
+
281
+ ---
282
+
283
+ ## ๐ŸŽฏ What's Next?
284
+
285
+ Choose your path based on what you want to accomplish:
286
+
287
+ | Path | Guide | Description |
288
+ |------|-------|-------------|
289
+ | **MCP Client Integration** | [Installing in MCP Clients](#-installing-in-mcp-clients) | Connect to Claude Desktop, VSCode, Cursor, and other MCP clients |
290
+ | **Custom SQL Tools** | [SQL Tool Configuration](#-sql-tool-configuration) | Create YAML-based SQL tools for your IBM i use cases |
291
+ | **Server Configuration** | [Configuration Guide](#๏ธ-configuration) | Explore authentication, transport modes, and environment variables |
292
+ | **Production Deployment** | [Deployment Options](../deployment/README.md) | Deploy with Docker, Podman, or OpenShift |
293
+ | **AI Agent Development** | [IBM i Agents](#-ibm-i-agents) | Build custom AI agents that interact with IBM i systems |
294
+ | **Development & Contributing** | [Running the Server (Development)](#๏ธ-running-the-server-development) | Build from source, run tests, and contribute |
295
+
296
+ ---
297
+
298
+ ## CLI Reference
299
+
300
+ The IBM i MCP Server provides a command-line interface with flexible options for running and configuring the server.
301
+
302
+ ### Basic Usage
303
+
304
+ ```bash
305
+ npx -y @ibm/ibmi-mcp-server@latest [options]
306
+ ```
307
+
308
+ > **Note:** The `-y` flag automatically accepts the npm package installation prompt.
309
+
310
+ ### Available Options
311
+
312
+ | Option | Description |
313
+ |--------|-------------|
314
+ | `--tools <path>` | Path to YAML tools (file, directory, or glob pattern) |
315
+ | `--toolsets <list>` | Comma-separated list of toolsets to load |
316
+ | `--list-toolsets` | List all available toolsets and exit |
317
+ | `--transport <type>` | Transport type: `stdio` (default) or `http` |
318
+ | `--help` | Show help message |
319
+
320
+ <details>
321
+ <summary><strong>Common Examples</strong></summary>
322
+
323
+ **Run server with stdio transport (for MCP clients):**
324
+ ```bash
325
+ npx -y @ibm/ibmi-mcp-server@latest --transport stdio --tools ./tools
326
+ ```
327
+
328
+ **Run HTTP server for testing:**
329
+ ```bash
330
+ npx -y @ibm/ibmi-mcp-server@latest --transport http --tools ./tools
331
+ ```
332
+
333
+ **Load specific toolsets only:**
334
+ ```bash
335
+ npx -y @ibm/ibmi-mcp-server@latest --toolsets performance,security
336
+ ```
337
+
338
+ **List available toolsets:**
339
+ ```bash
340
+ npx -y @ibm/ibmi-mcp-server@latest --list-toolsets --tools ./tools
341
+ ```
342
+
343
+ **Use custom tools directory:**
344
+ ```bash
345
+ npx -y @ibm/ibmi-mcp-server@latest --tools /absolute/path/to/custom-tools
346
+ ```
347
+
348
+ </details>
349
+
350
+ ---
351
+
352
+ ## ๐Ÿ”Œ Installing in MCP Clients
353
+
354
+ This server can be integrated into any MCP-compatible client using either **local** (stdio) or **remote** (HTTP) connections.
355
+
356
+ ### Prerequisites: Local Installation
357
+
358
+ The server is available as an npm package and can be used directly with `npx`:
359
+
360
+ ```bash
361
+ # Test the server is available
362
+ npx -y @ibm/ibmi-mcp-server@latest --help
363
+ ```
364
+
365
+ > **Note:** The `-y` flag automatically accepts the npm package installation prompt.
366
+ > `TOOLS_YAML_PATH` must be an **absolute path** to your tools configuration directory (e.g., `/full/path/to/tools`).
367
+
368
+ ### Remote Server Setup
369
+
370
+ For HTTP remote connections, you need to:
371
+
372
+ 1. **Start the server with IBM i authentication enabled:**
373
+
374
+ ```bash
375
+ # Ensure your .env has these settings:
376
+ MCP_AUTH_MODE=ibmi
377
+ IBMI_HTTP_AUTH_ENABLED=true
378
+ IBMI_AUTH_ALLOW_HTTP=true # For development only!
379
+
380
+ npm run start:http
381
+ ```
382
+
383
+ 2. **Obtain an access token:**
384
+
385
+ ```bash
386
+ # Use the token script to authenticate
387
+ node get-access-token.js --verbose
388
+
389
+ # Or set it directly in your environment
390
+ export IBMI_MCP_ACCESS_TOKEN="your-token-here"
391
+ ```
392
+
393
+ See [IBM i HTTP Authentication](#ibm-i-http-authentication-beta) for detailed authentication setup.
394
+
395
+ 3. **Configure your client** with the server URL and Bearer token (examples below).
396
+
397
+ > **โš ๏ธ Production Note:** Replace `http://localhost:3010` with your production endpoint URL and ensure HTTPS is enabled (`IBMI_AUTH_ALLOW_HTTP=false`).
398
+
399
+ In production environments, it is strongly recommended to deploy the MCP server behind a reverse proxy server such as Nginx, HAProxy, or Caddy. The reverse proxy server can provide TLS/SSL termination for the MCP server to handle HTTPS connections and SSL/TLS certificate management. Below is an example of an Nginx configuration. You may need to adjust it according to your specific networking configuration and security requirements.
400
+
401
+ ```
402
+ pid /run/nginx.pid;
403
+ events {}
404
+ http {
405
+ server {
406
+ listen 443 ssl;
407
+ ssl_certificate <path_to_certificate>;
408
+ ssl_certificate_key <path_to_privatekey>;
409
+ ssl_protocols TLSv1.3;
410
+ ssl_ciphers HIGH:!aNULL:!MD5;
411
+ ssl_session_cache shared:SSL:50m;
412
+ ssl_prefer_server_ciphers on;
413
+ # This is needed for getting access token when IBM i HTTP authentication enabled with HTTPS only
414
+ proxy_set_header X-Forwarded-Proto https;
415
+ location / {
416
+ proxy_pass http://mcp_server;
417
+ }
418
+ }
419
+ upstream mcp_server {
420
+ server 127.0.0.1:3010;
421
+ }
422
+ }
423
+ ```
424
+
425
+ ---
426
+
427
+ ### Client Configurations
428
+
429
+ <details>
430
+ <summary><strong>Claude Code</strong></summary>
431
+
432
+ Claude Code supports both local (stdio) and remote (HTTP) MCP server connections. You can configure servers using the CLI or by editing `.mcp.json` directly.
433
+
434
+ #### Option 1: Local Stdio Server (Recommended)
435
+
436
+ **Using CLI:**
437
+ ```bash
438
+ # Add local stdio server
439
+ claude mcp add ibmi-mcp \
440
+ --env DB2i_HOST=your-ibmi-host.com \
441
+ --env DB2i_USER=your-username \
442
+ --env DB2i_PASS=your-password \
443
+ --env DB2i_PORT=8076 \
444
+ --env MCP_TRANSPORT_TYPE=stdio \
445
+ -- npx -y @ibm/ibmi-mcp-server@latest --transport stdio --tools /absolute/path/to/tools
446
+ ```
447
+
448
+ **Using `.mcp.json`:**
449
+ ```json
450
+ {
451
+ "mcpServers": {
452
+ "ibmi-mcp": {
453
+ "command": "npx",
454
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
455
+ "env": {
456
+ "DB2i_HOST": "your-ibmi-host.com",
457
+ "DB2i_USER": "your-username",
458
+ "DB2i_PASS": "your-password",
459
+ "DB2i_PORT": "8076",
460
+ "NODE_OPTIONS": "--no-deprecation"
461
+ }
462
+ }
463
+ }
464
+ }
465
+ ```
466
+
467
+ #### Option 2: Remote HTTP Server
468
+
469
+ **Using CLI:**
470
+ ```bash
471
+ # Add remote HTTP server with authentication
472
+ claude mcp add --transport http ibmi-mcp http://localhost:3010/mcp \
473
+ --header "Authorization: Bearer YOUR_ACCESS_TOKEN_HERE"
474
+ ```
475
+
476
+ **Using `.mcp.json`:**
477
+ ```json
478
+ {
479
+ "mcpServers": {
480
+ "ibmi-mcp": {
481
+ "url": "http://localhost:3010/mcp",
482
+ "type": "http",
483
+ "headers": {
484
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
485
+ }
486
+ }
487
+ }
488
+ }
489
+ ```
490
+
491
+ #### Environment Variable Expansion
492
+
493
+ Claude Code supports environment variable expansion in `.mcp.json` files, allowing you to keep credentials secure:
494
+
495
+ ```json
496
+ {
497
+ "mcpServers": {
498
+ "ibmi-mcp": {
499
+ "command": "npx",
500
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "${IBMI_TOOLS_PATH}"],
501
+ "env": {
502
+ "DB2i_HOST": "${DB2i_HOST}",
503
+ "DB2i_USER": "${DB2i_USER}",
504
+ "DB2i_PASS": "${DB2i_PASS}",
505
+ "DB2i_PORT": "${DB2i_PORT:-8076}"
506
+ }
507
+ }
508
+ }
509
+ }
510
+ ```
511
+
512
+ **Supported syntax:**
513
+ - `${VAR}` - Expands to the value of environment variable `VAR`
514
+ - `${VAR:-default}` - Expands to `VAR` if set, otherwise uses `default`
515
+
516
+ #### Managing Servers
517
+
518
+ ```bash
519
+ # List configured servers
520
+ claude mcp list
521
+
522
+ # Get server details
523
+ claude mcp get ibmi-mcp
524
+
525
+ # Remove a server
526
+ claude mcp remove ibmi-mcp
527
+
528
+ # Check server status in Claude Code
529
+ /mcp
530
+ ```
531
+
532
+ > ๐Ÿ“– [Claude Code MCP Documentation](https://docs.claude.com/en/docs/claude-code/mcp)
533
+
534
+ </details>
535
+
536
+ <details>
537
+ <summary><strong>Claude Desktop</strong></summary>
538
+
539
+ #### Local (Stdio)
540
+
541
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
542
+
543
+ ```json
544
+ {
545
+ "mcpServers": {
546
+ "ibmi-mcp": {
547
+ "command": "npx",
548
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
549
+ "env": {
550
+ "DB2i_HOST": "your-ibmi-host.com",
551
+ "DB2i_USER": "your-username",
552
+ "DB2i_PASS": "your-password",
553
+ "DB2i_PORT": "8076"
554
+ }
555
+ }
556
+ }
557
+ }
558
+ ```
559
+
560
+ #### Remote (HTTP)
561
+
562
+ ```json
563
+ {
564
+ "mcpServers": {
565
+ "ibmi-mcp": {
566
+ "url": "http://localhost:3010/mcp",
567
+ "type": "http",
568
+ "headers": {
569
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
570
+ }
571
+ }
572
+ }
573
+ }
574
+ ```
575
+
576
+ > ๐Ÿ“– [Claude Desktop MCP Setup](https://modelcontextprotocol.io/quickstart/user)
577
+
578
+ </details>
579
+
580
+ <details>
581
+ <summary><strong>VSCode</strong></summary>
582
+
583
+ VSCode supports MCP servers through Copilot Chat. You can configure servers at the user or workspace level using configuration files or the CLI.
584
+
585
+ **Prerequisites:** Ensure [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) is installed and enabled.
586
+
587
+ #### Configuration File Locations
588
+
589
+ - **Workspace:** `.vscode/mcp.json` (shared with team via version control)
590
+ - **User:** `mcp.json` in your user profile directory
591
+ - macOS/Linux: `~/.config/Code/User/globalStorage/modelcontextprotocol.mcp/mcp.json`
592
+ - Windows: `%APPDATA%\Code\User\globalStorage\modelcontextprotocol.mcp\mcp.json`
593
+
594
+ #### Option 1: Local Stdio Server
595
+
596
+ **Using CLI:**
597
+ ```bash
598
+ # Add local stdio server
599
+ code --add-mcp '{
600
+ "name": "ibmiMcp",
601
+ "type": "stdio",
602
+ "command": "npx",
603
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
604
+ "env": {
605
+ "DB2i_HOST": "your-ibmi-host.com",
606
+ "DB2i_USER": "your-username",
607
+ "DB2i_PASS": "your-password",
608
+ "DB2i_PORT": "8076"
609
+ }
610
+ }'
611
+ ```
612
+
613
+ **Using `mcp.json`:**
614
+ ```json
615
+ {
616
+ "servers": {
617
+ "ibmiMcp": {
618
+ "type": "stdio",
619
+ "command": "npx",
620
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
621
+ "env": {
622
+ "DB2i_HOST": "your-ibmi-host.com",
623
+ "DB2i_USER": "your-username",
624
+ "DB2i_PASS": "your-password",
625
+ "DB2i_PORT": "8076"
626
+ }
627
+ }
628
+ }
629
+ }
630
+ ```
631
+
632
+ #### Option 2: Remote HTTP Server
633
+
634
+ **Using CLI:**
635
+ ```bash
636
+ # Add remote HTTP server
637
+ code --add-mcp '{
638
+ "name": "ibmiMcp",
639
+ "type": "http",
640
+ "url": "http://localhost:3010/mcp",
641
+ "headers": {
642
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
643
+ }
644
+ }'
645
+ ```
646
+
647
+ **Using `mcp.json`:**
648
+ ```json
649
+ {
650
+ "servers": {
651
+ "ibmiMcp": {
652
+ "type": "http",
653
+ "url": "http://localhost:3010/mcp",
654
+ "headers": {
655
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
656
+ }
657
+ }
658
+ }
659
+ }
660
+ ```
661
+
662
+ #### Secure Credentials with Input Variables
663
+
664
+ VSCode supports input variables to avoid hardcoding sensitive credentials:
665
+
666
+ ```json
667
+ {
668
+ "inputs": [
669
+ {
670
+ "id": "db2iHost",
671
+ "type": "promptString",
672
+ "description": "IBM i DB2 host address"
673
+ },
674
+ {
675
+ "id": "db2iUser",
676
+ "type": "promptString",
677
+ "description": "IBM i username"
678
+ },
679
+ {
680
+ "id": "db2iPass",
681
+ "type": "promptString",
682
+ "description": "IBM i password",
683
+ "password": true
684
+ }
685
+ ],
686
+ "servers": {
687
+ "ibmiMcp": {
688
+ "type": "stdio",
689
+ "command": "npx",
690
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
691
+ "env": {
692
+ "DB2i_HOST": "${input:db2iHost}",
693
+ "DB2i_USER": "${input:db2iUser}",
694
+ "DB2i_PASS": "${input:db2iPass}",
695
+ "DB2i_PORT": "8076"
696
+ }
697
+ }
698
+ }
699
+ }
700
+ ```
701
+
702
+ VSCode will prompt for these values when the server starts, keeping credentials secure.
703
+
704
+ #### Managing Servers
705
+
706
+ - **View servers:** Check the Copilot Chat view in the Activity Bar
707
+ - **Restart server:** Use Command Palette (`Cmd/Ctrl+Shift+P`) โ†’ "MCP: Restart Server"
708
+ - **Disable server:** Remove from `mcp.json` or disable in settings
709
+
710
+ > ๐Ÿ“– [VSCode MCP Documentation](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)
711
+
712
+ </details>
713
+
714
+ <details>
715
+ <summary><strong>Cursor</strong></summary>
716
+
717
+ #### Local (Stdio)
718
+
719
+ Add to Cursor settings or `.cursor/mcp.json`:
720
+
721
+ ```json
722
+ {
723
+ "mcpServers": {
724
+ "ibmi-mcp": {
725
+ "command": "npx",
726
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
727
+ "env": {
728
+ "DB2i_HOST": "your-ibmi-host.com",
729
+ "DB2i_USER": "your-username",
730
+ "DB2i_PASS": "your-password",
731
+ "DB2i_PORT": "8076"
732
+ }
733
+ }
734
+ }
735
+ }
736
+ ```
737
+
738
+ #### Remote (HTTP)
739
+
740
+ ```json
741
+ {
742
+ "mcpServers": {
743
+ "ibmi-mcp": {
744
+ "url": "http://localhost:3010/mcp",
745
+ "type": "http",
746
+ "headers": {
747
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
748
+ }
749
+ }
750
+ }
751
+ }
752
+ ```
753
+
754
+ > ๐Ÿ“– [Cursor MCP Documentation](https://docs.cursor.com/context/model-context-protocol)
755
+
756
+ </details>
757
+
758
+ <details>
759
+ <summary><strong>Windsurf</strong></summary>
760
+
761
+ #### Local (Stdio)
762
+
763
+ Add to Windsurf configuration:
764
+
765
+ ```json
766
+ {
767
+ "mcpServers": {
768
+ "ibmi-mcp": {
769
+ "command": "npx",
770
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
771
+ "env": {
772
+ "DB2i_HOST": "your-ibmi-host.com",
773
+ "DB2i_USER": "your-username",
774
+ "DB2i_PASS": "your-password",
775
+ "DB2i_PORT": "8076"
776
+ }
777
+ }
778
+ }
779
+ }
780
+ ```
781
+
782
+ #### Remote (HTTP)
783
+
784
+ ```json
785
+ {
786
+ "mcpServers": {
787
+ "ibmi-mcp": {
788
+ "url": "http://localhost:3010/mcp",
789
+ "type": "http",
790
+ "headers": {
791
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
792
+ }
793
+ }
794
+ }
795
+ }
796
+ ```
797
+
798
+ > ๐Ÿ“– [Windsurf MCP Documentation](https://docs.windsurf.com/windsurf/cascade/mcp)
799
+
800
+ </details>
801
+
802
+ <details>
803
+ <summary><strong>Roo Code</strong></summary>
804
+
805
+ #### Local (Stdio)
806
+
807
+ Configure in Roo Code settings:
808
+
809
+ ```json
810
+ {
811
+ "mcpServers": {
812
+ "ibmi-mcp": {
813
+ "command": "npx",
814
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
815
+ "env": {
816
+ "DB2i_HOST": "your-ibmi-host.com",
817
+ "DB2i_USER": "your-username",
818
+ "DB2i_PASS": "your-password",
819
+ "DB2i_PORT": "8076"
820
+ }
821
+ }
822
+ }
823
+ }
824
+ ```
825
+
826
+ #### Remote (HTTP)
827
+
828
+ ```json
829
+ {
830
+ "mcpServers": {
831
+ "ibmi-mcp": {
832
+ "url": "http://localhost:3010/mcp",
833
+ "type": "http",
834
+ "headers": {
835
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
836
+ }
837
+ }
838
+ }
839
+ }
840
+ ```
841
+
842
+ > ๐Ÿ“– [Roo Code MCP Documentation](https://docs.roocode.com/features/mcp/using-mcp-in-roo)
843
+
844
+ </details>
845
+
846
+ <details>
847
+ <summary><strong>LM Studio</strong></summary>
848
+
849
+ #### Local (Stdio)
850
+
851
+ ```json
852
+ {
853
+ "mcpServers": {
854
+ "ibmi-mcp": {
855
+ "command": "npx",
856
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
857
+ "env": {
858
+ "DB2i_HOST": "your-ibmi-host.com",
859
+ "DB2i_USER": "your-username",
860
+ "DB2i_PASS": "your-password",
861
+ "DB2i_PORT": "8076",
862
+ "NODE_OPTIONS": "--no-deprecation"
863
+ }
864
+ }
865
+ }
866
+ }
867
+ ```
868
+
869
+ #### Remote (HTTP)
870
+
871
+ ```json
872
+ {
873
+ "mcpServers": {
874
+ "ibmi-mcp": {
875
+ "url": "http://localhost:3010/mcp",
876
+ "type": "http",
877
+ "headers": {
878
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
879
+ }
880
+ }
881
+ }
882
+ }
883
+ ```
884
+
885
+ > ๐Ÿ“– [LM Studio MCP Support](https://lmstudio.ai/blog/lmstudio-v0.3.17)
886
+
887
+ </details>
888
+
889
+ <details>
890
+ <summary><strong>OpenCode</strong></summary>
891
+
892
+ #### Local (Stdio)
893
+
894
+ Add local MCP servers using "type": "local" within the MCP object. Multiple MCP servers can be added. The key string for each server can be any arbitrary name.
895
+
896
+ **opencode.json**:
897
+ ```json
898
+ {
899
+ "$schema": "https://opencode.ai/config.json",
900
+ "mcp": {
901
+ "ibmi-mcp": {
902
+ "type": "local",
903
+ "enabled": true,
904
+ "command": ["npx", "@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
905
+ "environment": {
906
+ "DB2i_HOST": "your-ibmi-host.com",
907
+ "DB2i_USER": "your-username",
908
+ "DB2i_PASS": "your-password",
909
+ "DB2i_PORT": "8076"
910
+ },
911
+ "enabled": true
912
+ }
913
+ }
914
+ }
915
+ ```
916
+
917
+ You can also disable a server by setting enabled to false. This is useful if you want to temporarily disable a server without removing it from your config.
918
+
919
+ #### Remote (HTTP)
920
+
921
+ ```json
922
+ {
923
+ "$schema": "https://opencode.ai/config.json",
924
+ "mcp": {
925
+ "ibmi-mcp": {
926
+ "type": "remote",
927
+ "enabled": true,
928
+ "url": "http://localhost:3010/mcp",
929
+ "headers": {
930
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
931
+ }
932
+ }
933
+ }
934
+ }
935
+ ```
936
+
937
+ > ๐Ÿ“– [OpenCode MCP Documentation](https://opencode.ai/docs/mcp-servers)
938
+
939
+ </details>
940
+
941
+ <details>
942
+ <summary><strong>Gemini CLI</strong></summary>
943
+
944
+ See [Gemini CLI Configuration](https://google-gemini.github.io/gemini-cli/docs/tools/mcp-server.html) for details.
945
+ 1. Open the Gemini CLI settings file. The location is `~/.gemini/settings.json` (where `~` is your home directory).
946
+ 2. Add the following to the `mcpServers` object in your `settings.json` file:
947
+
948
+ #### Local (Stdio)
949
+
950
+ Configure in Gemini CLI settings:
951
+
952
+ ```json
953
+ {
954
+ "mcpServers": {
955
+ "ibmi-mcp": {
956
+ "command": "npx",
957
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
958
+ "env": {
959
+ "DB2i_HOST": "your-ibmi-host.com",
960
+ "DB2i_USER": "your-username",
961
+ "DB2i_PASS": "your-password",
962
+ "DB2i_PORT": "8076"
963
+ }
964
+ }
965
+ }
966
+ }
967
+ ```
968
+
969
+ #### Remote (HTTP)
970
+
971
+ ```json
972
+ {
973
+ "mcpServers": {
974
+ "ibmi-mcp": {
975
+ "url": "http://localhost:3010/mcp",
976
+ "type": "http",
977
+ "headers": {
978
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
979
+ }
980
+ }
981
+ }
982
+ }
983
+ ```
984
+
985
+ > ๐Ÿ“– [Gemini CLI MCP Documentation](https://google-gemini.github.io/gemini-cli/docs/tools/mcp-server.html)
986
+
987
+ </details>
988
+
989
+ <details>
990
+ <summary><strong>Cline</strong></summary>
991
+
992
+ Cline supports MCP servers through both the marketplace and manual configuration.
993
+
994
+ **Prerequisites:** Ensure [Cline](https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev) is installed in VSCode.
995
+
996
+ #### Option 1: Manual Configuration
997
+
998
+ **For Local (Stdio) Server:**
999
+
1000
+ 1. Open **Cline**
1001
+ 2. Click the hamburger menu icon (โ˜ฐ) โ†’ **MCP Servers**
1002
+ 3. Choose **Local Servers** tab
1003
+ 4. Click **Edit Configuration**
1004
+ 5. Add the configuration:
1005
+
1006
+ ```json
1007
+ {
1008
+ "mcpServers": {
1009
+ "ibmi-mcp": {
1010
+ "command": "npx",
1011
+ "args": ["@ibm/ibmi-mcp-server@latest", "-y", "--transport", "stdio", "--tools", "/absolute/path/to/tools"],
1012
+ "env": {
1013
+ "DB2i_HOST": "your-ibmi-host.com",
1014
+ "DB2i_USER": "your-username",
1015
+ "DB2i_PASS": "your-password",
1016
+ "DB2i_PORT": "8076"
1017
+ }
1018
+ }
1019
+ }
1020
+ }
1021
+ ```
1022
+
1023
+ **For Remote (HTTP) Server:**
1024
+
1025
+ 1. Open **Cline**
1026
+ 2. Click the hamburger menu icon (โ˜ฐ) โ†’ **MCP Servers**
1027
+ 3. Choose **Remote Servers** tab
1028
+ 4. Click **Edit Configuration**
1029
+ 5. Add the configuration:
1030
+
1031
+ ```json
1032
+ {
1033
+ "mcpServers": {
1034
+ "ibmi-mcp": {
1035
+ "url": "http://localhost:3010/mcp",
1036
+ "type": "streamableHttp",
1037
+ "headers": {
1038
+ "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
1039
+ }
1040
+ }
1041
+ }
1042
+ }
1043
+ ```
1044
+
1045
+ > ๐Ÿ“– [Cline MCP Documentation](https://docs.cline.bot/mcp/mcp-overview#mcp-overview) | [Cline MCP Marketplace](https://cline.bot/mcp-marketplace)
1046
+
1047
+ </details>
1048
+
1049
+ <details>
1050
+ <summary><strong>Python Clients (Agno, Official MCP SDK)</strong></summary>
1051
+
1052
+ #### Remote (HTTP) with Agno
1053
+
1054
+ ```python
1055
+ import asyncio
1056
+ import os
1057
+ from agno.agent import Agent
1058
+ from agno.tools.mcp import MCPTools, StreamableHTTPClientParams
1059
+
1060
+ # Get access token from environment
1061
+ token = os.environ.get('IBMI_MCP_ACCESS_TOKEN')
1062
+ if not token:
1063
+ raise ValueError("IBMI_MCP_ACCESS_TOKEN not set")
1064
+
1065
+ url = "http://localhost:3010/mcp"
1066
+ server_params = StreamableHTTPClientParams(
1067
+ url=url,
1068
+ headers={"Authorization": f"Bearer {token}"}
1069
+ )
1070
+
1071
+ async def main():
1072
+ async with MCPTools(
1073
+ url=url,
1074
+ server_params=server_params,
1075
+ transport="streamable-http"
1076
+ ) as tools:
1077
+ # List available tools
1078
+ result = await tools.session.list_tools()
1079
+ print(f"Available tools: {[t.name for t in result.tools]}")
1080
+
1081
+ # Create agent
1082
+ agent = Agent(
1083
+ model="openai:gpt-4o", # or your preferred model
1084
+ tools=[tools],
1085
+ name="ibmi-agent",
1086
+ show_tool_calls=True
1087
+ )
1088
+
1089
+ # Run query
1090
+ await agent.aprint_response("What is the system status?")
1091
+
1092
+ if __name__ == "__main__":
1093
+ asyncio.run(main())
1094
+ ```
1095
+
1096
+ #### Remote (HTTP) with Official MCP SDK
1097
+
1098
+ ```python
1099
+ import asyncio
1100
+ import os
1101
+ from mcp import ClientSession
1102
+ from mcp.client.streamable_http import streamablehttp_client
1103
+
1104
+ async def main():
1105
+ token = os.environ.get('IBMI_MCP_ACCESS_TOKEN')
1106
+ if not token:
1107
+ raise ValueError("IBMI_MCP_ACCESS_TOKEN not set")
1108
+
1109
+ headers = {"Authorization": f"Bearer {token}"}
1110
+
1111
+ async with streamablehttp_client(
1112
+ "http://localhost:3010/mcp",
1113
+ headers=headers
1114
+ ) as (read_stream, write_stream, _):
1115
+ async with ClientSession(read_stream, write_stream) as session:
1116
+ await session.initialize()
1117
+
1118
+ # List tools
1119
+ tools = await session.list_tools()
1120
+ print(f"Tools: {[t.name for t in tools.tools]}")
1121
+
1122
+ # Execute a tool
1123
+ result = await session.call_tool("system_status", {})
1124
+ print(result)
1125
+
1126
+ if __name__ == "__main__":
1127
+ asyncio.run(main())
1128
+ ```
1129
+
1130
+ > ๐Ÿ“– [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) | [Agno Framework](https://github.com/agno-agi/agno)
1131
+
1132
+ </details>
1133
+
1134
+ ---
1135
+
1136
+ ## ๐Ÿงฉ SQL Tool Configuration
1137
+
1138
+ The primary way to configure tools used by this MCP server is through `tools.yaml` files (see `tools/` for examples). There are 3 main sections to each yaml file: `sources`, `tools`, and `toolsets`. Below is a breakdown of each section.
1139
+
1140
+ ### Sources
1141
+
1142
+ The sources section of your `tools.yaml` defines the data sources the MCP server has access to:
1143
+
1144
+ ```yaml
1145
+ sources:
1146
+ ibmi-system:
1147
+ host: ${DB2i_HOST}
1148
+ user: ${DB2i_USER}
1149
+ password: ${DB2i_PASS}
1150
+ port: 8076
1151
+ ignore-unauthorized: true
1152
+ ```
1153
+
1154
+ > [!NOTE]
1155
+ > The environment variables `DB2i_HOST`, `DB2i_USER`, `DB2i_PASS`, and `DB2i_PORT` can be set in the server `.env` file. See [Configuration](#๏ธ-configuration) for all available settings.
1156
+
1157
+ ### Tools
1158
+
1159
+ The tools section of your `tools.yaml` defines the actions your agent can take: what kind of tool it is, which source(s) it affects, what parameters it uses, etc.
1160
+
1161
+ ```yaml
1162
+ tools:
1163
+ system_status:
1164
+ source: ibmi-system
1165
+ description: "Overall system performance statistics with CPU, memory, and I/O metrics"
1166
+ parameters: []
1167
+ statement: |
1168
+ SELECT * FROM TABLE(QSYS2.SYSTEM_STATUS(RESET_STATISTICS=>'YES',DETAILED_INFO=>'ALL')) X
1169
+ ```
1170
+
1171
+ ### Toolsets
1172
+
1173
+ The toolsets section of your `tools.yaml` allows you to define groups of tools that you want to be able to load together. This can be useful for defining different sets for different agents or different applications.
1174
+
1175
+ ```yaml
1176
+ toolsets:
1177
+ performance:
1178
+ tools:
1179
+ - system_status
1180
+ - system_activity
1181
+ - remote_connections
1182
+ - memory_pools
1183
+ - temp_storage_buckets
1184
+ - unnamed_temp_storage
1185
+ - http_server
1186
+ - system_values
1187
+ - collection_services
1188
+ - collection_categories
1189
+ - active_job_info
1190
+ ```
1191
+
1192
+ > [!TIP]
1193
+ > **Advanced Tool Configuration:** For detailed documentation on creating custom SQL tools, parameter validation, advanced queries, and more, see [tools/README.md](../tools/README.md).
1194
+
1195
+ ---
1196
+
1197
+ ## ๐Ÿค– IBM i Agents
1198
+
1199
+ IBM i Agents are specialized components designed to interact with the IBM i system, providing capabilities such as monitoring, management, and automation.
1200
+
1201
+ ### Key Features
1202
+ - **Integration with IBM i:** Seamless integration with IBM i system APIs and tools.
1203
+ - **Modular Architecture:** Easily extendable and customizable to fit specific use cases.
1204
+ - **Real-time Monitoring:** Continuous monitoring of system performance and health.
1205
+
1206
+ ### Getting Started
1207
+
1208
+ Navigate to the `agents` directory and follow the setup instructions in the [README](../agents/README.md). This includes details on configuration, running agents, and examples. Most agent examples require the MCP server to be running in HTTP mode. Read the docs for each agent example for details.
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+ ## โš™๏ธ Configuration
1215
+
1216
+ The server is configured using environment variables, typically set in a `.env` file at the project root. Configuration is organized into logical groups for easier management.
1217
+
1218
+ **Quick Start:**
1219
+ ```bash
1220
+ cp .env.example .env
1221
+ code .env # Edit with your settings
1222
+ ```
1223
+
1224
+ ---
1225
+
1226
+ <details>
1227
+ <summary><strong>๐Ÿ–ฅ๏ธ MCP Server Settings</strong></summary>
1228
+
1229
+ Core server configuration including server identity, transport mode, and logging.
1230
+
1231
+ | Variable | Description | Default | Required |
1232
+ |----------|-------------|---------|----------|
1233
+ | `MCP_SERVER_NAME` | Server name identifier for MCP protocol | Package name from `package.json` | No |
1234
+ | `MCP_SERVER_VERSION` | Server version for MCP protocol | Version from `package.json` | No |
1235
+ | `MCP_TRANSPORT_TYPE` | Transport protocol: `stdio` (local) or `http` (remote) | `stdio` | No |
1236
+ | `MCP_LOG_LEVEL` | Logging verbosity: `error`, `warn`, `info`, `debug` | `debug` | No |
1237
+ | `LOGS_DIR` | Directory for log files (relative to project root) | `logs` | No |
1238
+ | `NODE_ENV` | Node environment: `development`, `production`, `test` | `development` | No |
1239
+
1240
+ **Examples:**
1241
+ ```bash
1242
+ # Development with verbose logging
1243
+ MCP_SERVER_NAME=ibmi-mcp-dev
1244
+ MCP_TRANSPORT_TYPE=http
1245
+ MCP_LOG_LEVEL=debug
1246
+ NODE_ENV=development
1247
+
1248
+ # Production with minimal logging
1249
+ MCP_SERVER_NAME=ibmi-mcp-prod
1250
+ MCP_TRANSPORT_TYPE=stdio
1251
+ MCP_LOG_LEVEL=warn
1252
+ NODE_ENV=production
1253
+ ```
1254
+
1255
+ </details>
1256
+
1257
+ <details>
1258
+ <summary><strong>๐ŸŒ HTTP Transport Settings</strong></summary>
1259
+
1260
+ Configuration for HTTP transport mode, including network settings, session management, and CORS.
1261
+
1262
+ | Variable | Description | Default | Required |
1263
+ |----------|-------------|---------|----------|
1264
+ | `MCP_HTTP_PORT` | HTTP server port | `3010` | No |
1265
+ | `MCP_HTTP_HOST` | HTTP server bind address | `127.0.0.1` | No |
1266
+ | `MCP_HTTP_ENDPOINT_PATH` | MCP endpoint path | `/mcp` | No |
1267
+ | `MCP_SESSION_MODE` | Session handling: `stateless`, `stateful`, or `auto` | `auto` | No |
1268
+ | `MCP_STATEFUL_SESSION_STALE_TIMEOUT_MS` | Timeout for idle stateful sessions (milliseconds) | `1800000` (30 min) | No |
1269
+ | `MCP_HTTP_MAX_PORT_RETRIES` | Max attempts to find available port if default is in use | `15` | No |
1270
+ | `MCP_HTTP_PORT_RETRY_DELAY_MS` | Delay between port retry attempts (milliseconds) | `50` | No |
1271
+ | `MCP_ALLOWED_ORIGINS` | Comma-separated CORS allowed origins | None (all origins blocked) | No |
1272
+
1273
+ **Session Modes:**
1274
+ - **`auto`**: Automatically detects client capabilities and uses the best session mode
1275
+ - **`stateful`**: Maintains persistent sessions with connection state (best for long-running interactions)
1276
+ - **`stateless`**: Each request is independent (best for load balancing and horizontal scaling)
1277
+
1278
+ **Examples:**
1279
+ ```bash
1280
+ # Development server with CORS for local web clients
1281
+ MCP_HTTP_PORT=3010
1282
+ MCP_HTTP_HOST=0.0.0.0 # Listen on all interfaces
1283
+ MCP_SESSION_MODE=auto
1284
+ MCP_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
1285
+
1286
+ # Production server with strict security
1287
+ MCP_HTTP_PORT=443
1288
+ MCP_HTTP_HOST=0.0.0.0
1289
+ MCP_SESSION_MODE=stateful
1290
+ MCP_ALLOWED_ORIGINS=https://app.example.com,https://dashboard.example.com
1291
+ MCP_STATEFUL_SESSION_STALE_TIMEOUT_MS=3600000 # 1 hour
1292
+ ```
1293
+
1294
+ </details>
1295
+
1296
+ <details>
1297
+ <summary><strong>๐Ÿ” Authentication & Authorization</strong></summary>
1298
+
1299
+ Security configuration for protecting the MCP server and authenticating clients.
1300
+
1301
+ ### General Authentication
1302
+
1303
+ | Variable | Description | Default | Required |
1304
+ |----------|-------------|---------|----------|
1305
+ | `MCP_AUTH_MODE` | Authentication mode: `none`, `jwt`, `oauth`, `ibmi` | `none` | No |
1306
+
1307
+ ### JWT Authentication
1308
+
1309
+ Required when `MCP_AUTH_MODE=jwt`.
1310
+
1311
+ | Variable | Description | Default | Required |
1312
+ |----------|-------------|---------|----------|
1313
+ | `MCP_AUTH_SECRET_KEY` | Secret key for signing/verifying JWT tokens (min 32 characters) | None | โœ… Yes (for JWT mode) |
1314
+
1315
+ ### OAuth Authentication
1316
+
1317
+ Required when `MCP_AUTH_MODE=oauth`.
1318
+
1319
+ | Variable | Description | Default | Required |
1320
+ |----------|-------------|---------|----------|
1321
+ | `OAUTH_ISSUER_URL` | OAuth authorization server issuer URL | None | โœ… Yes (for OAuth mode) |
1322
+ | `OAUTH_JWKS_URI` | OAuth JWKS endpoint for public key verification | None | No |
1323
+ | `OAUTH_AUDIENCE` | Expected audience identifier for this MCP server | None | โœ… Yes (for OAuth mode) |
1324
+
1325
+ ### IBM i HTTP Authentication
1326
+
1327
+ Required when `MCP_AUTH_MODE=ibmi`. See [IBM i HTTP Authentication](#ibm-i-http-authentication-beta) for detailed setup.
1328
+
1329
+ | Variable | Description | Default | Required |
1330
+ |----------|-------------|---------|----------|
1331
+ | `IBMI_HTTP_AUTH_ENABLED` | Enable IBM i authentication endpoints | `false` | โœ… Yes (for IBM i mode) |
1332
+ | `IBMI_AUTH_ALLOW_HTTP` | Allow HTTP (non-HTTPS) authentication requests | `false` | No |
1333
+ | `IBMI_AUTH_TOKEN_EXPIRY_SECONDS` | Token lifetime in seconds | `3600` (1 hour) | No |
1334
+ | `IBMI_AUTH_CLEANUP_INTERVAL_SECONDS` | How often to clean up expired tokens (seconds) | `300` (5 minutes) | No |
1335
+ | `IBMI_AUTH_MAX_CONCURRENT_SESSIONS` | Maximum concurrent authenticated sessions | `100` | No |
1336
+ | `IBMI_AUTH_PRIVATE_KEY_PATH` | Path to RSA private key for encryption | None | โœ… Yes (for IBM i mode) |
1337
+ | `IBMI_AUTH_PUBLIC_KEY_PATH` | Path to RSA public key for encryption | None | โœ… Yes (for IBM i mode) |
1338
+ | `IBMI_AUTH_KEY_ID` | Identifier for the RSA keypair | None | โœ… Yes (for IBM i mode) |
1339
+
1340
+ **Examples:**
1341
+ ```bash
1342
+ # No authentication (development only)
1343
+ MCP_AUTH_MODE=none
1344
+
1345
+ # JWT authentication
1346
+ MCP_AUTH_MODE=jwt
1347
+ MCP_AUTH_SECRET_KEY="your-very-secret-key-at-least-32-characters-long"
1348
+
1349
+ # OAuth authentication
1350
+ MCP_AUTH_MODE=oauth
1351
+ OAUTH_ISSUER_URL=https://auth.example.com
1352
+ OAUTH_AUDIENCE=https://api.example.com/mcp
1353
+ OAUTH_JWKS_URI=https://auth.example.com/.well-known/jwks.json
1354
+
1355
+ # IBM i authentication (see docs for keypair generation)
1356
+ MCP_AUTH_MODE=ibmi
1357
+ IBMI_HTTP_AUTH_ENABLED=true
1358
+ IBMI_AUTH_KEY_ID=production
1359
+ IBMI_AUTH_PRIVATE_KEY_PATH=secrets/private.pem
1360
+ IBMI_AUTH_PUBLIC_KEY_PATH=secrets/public.pem
1361
+ IBMI_AUTH_ALLOW_HTTP=false # HTTPS only in production
1362
+ IBMI_AUTH_TOKEN_EXPIRY_SECONDS=7200 # 2 hours
1363
+ ```
1364
+
1365
+ **โš ๏ธ Security Notes:**
1366
+ - **Never** use `MCP_AUTH_MODE=none` in production
1367
+ - **Always** use `IBMI_AUTH_ALLOW_HTTP=false` in production (requires HTTPS)
1368
+ - Generate strong secret keys (32+ characters) for JWT mode
1369
+ - Rotate keys regularly for enhanced security
1370
+
1371
+ </details>
1372
+
1373
+ <details>
1374
+ <summary><strong>๐Ÿ—„๏ธ IBM i Database Connection</strong></summary>
1375
+
1376
+ Configuration for connecting to IBM i Db2 for i databases via Mapepire.
1377
+
1378
+ | Variable | Description | Default | Required |
1379
+ |----------|-------------|---------|----------|
1380
+ | `DB2i_HOST` | IBM i system hostname or IP address | None | โœ… Yes (for SQL tools) |
1381
+ | `DB2i_USER` | IBM i user profile for database connections | None | โœ… Yes (for SQL tools) |
1382
+ | `DB2i_PASS` | Password for IBM i user profile | None | โœ… Yes (for SQL tools) |
1383
+ | `DB2i_PORT` | Mapepire daemon/gateway port | `8076` | No |
1384
+ | `DB2i_IGNORE_UNAUTHORIZED` | Skip TLS certificate verification (for self-signed certs) | `true` | No |
1385
+
1386
+ **Connection Flow:**
1387
+ 1. Server connects to Mapepire daemon/gateway at `DB2i_HOST:DB2i_PORT`
1388
+ 2. Authenticates using `DB2i_USER` and `DB2i_PASS`
1389
+ 3. Executes SQL tools through authenticated connection pool
1390
+
1391
+ **Examples:**
1392
+ ```bash
1393
+ # Development connection with self-signed certs
1394
+ DB2i_HOST=ibmi-dev.example.com
1395
+ DB2i_USER=DEVUSER
1396
+ DB2i_PASS=devpassword
1397
+ DB2i_PORT=8076
1398
+ DB2i_IGNORE_UNAUTHORIZED=true
1399
+
1400
+ # Production connection with verified SSL
1401
+ DB2i_HOST=ibmi-prod.example.com
1402
+ DB2i_USER=PRODUSER
1403
+ DB2i_PASS=strongProductionPassword123
1404
+ DB2i_PORT=8076
1405
+ DB2i_IGNORE_UNAUTHORIZED=false # Require valid SSL cert
1406
+
1407
+ # Connecting to Mapepire gateway
1408
+ DB2i_HOST=mapepire-gateway.example.com
1409
+ DB2i_USER=APIUSER
1410
+ DB2i_PASS=apiPassword456
1411
+ DB2i_PORT=443 # Gateway on HTTPS
1412
+ DB2i_IGNORE_UNAUTHORIZED=false
1413
+ ```
1414
+
1415
+ **โš ๏ธ Security Notes:**
1416
+ - Store credentials securely (use secrets management in production)
1417
+ - Use read-only accounts when possible
1418
+ - Set `DB2i_IGNORE_UNAUTHORIZED=false` with valid SSL certificates in production
1419
+ - Consider using IBM i authentication mode for per-user connection pooling
1420
+
1421
+ </details>
1422
+
1423
+ <details>
1424
+ <summary><strong>๐Ÿงฉ SQL YAML Tool Configuration</strong></summary>
1425
+
1426
+ Settings for loading and managing SQL tools defined in YAML configuration files. See [Tools Documentation](../tools/README.md) for YAML tool development.
1427
+
1428
+ ### Tool Loading
1429
+
1430
+ | Variable | Description | Default | Required |
1431
+ |----------|-------------|---------|----------|
1432
+ | `TOOLS_YAML_PATH` | Path to YAML tool configurations (file, directory, or glob) | None | No |
1433
+ | `SELECTED_TOOLSETS` | Comma-separated list of toolsets to load (filters available tools) | None (load all) | No |
1434
+ | `YAML_AUTO_RELOAD` | Automatically reload tools when YAML files change | `true` | No |
1435
+
1436
+ ### Configuration Merging
1437
+
1438
+ When loading multiple YAML files, these settings control merge behavior:
1439
+
1440
+ | Variable | Description | Default | Required |
1441
+ |----------|-------------|---------|----------|
1442
+ | `YAML_MERGE_ARRAYS` | Merge arrays from multiple files (`true`) or replace them (`false`) | `true` | No |
1443
+ | `YAML_ALLOW_DUPLICATE_TOOLS` | Allow duplicate tool names across files | `false` | No |
1444
+ | `YAML_ALLOW_DUPLICATE_SOURCES` | Allow duplicate source names across files | `false` | No |
1445
+ | `YAML_VALIDATE_MERGED` | Validate merged configuration before loading tools | `true` | No |
1446
+
1447
+ **Path Resolution:**
1448
+ - **File**: `TOOLS_YAML_PATH=tools/performance.yaml`
1449
+ - **Directory**: `TOOLS_YAML_PATH=tools/` (loads all .yaml/.yml files)
1450
+ - **Glob pattern**: `TOOLS_YAML_PATH=tools/**/*.yaml`
1451
+ - **Multiple sources**: Use CLI `--tools` to override at runtime
1452
+
1453
+ **Examples:**
1454
+ ```bash
1455
+ # Load all tools from a directory
1456
+ TOOLS_YAML_PATH=tools/
1457
+ YAML_AUTO_RELOAD=true # Hot reload on file changes
1458
+
1459
+ # Load specific tools file
1460
+ TOOLS_YAML_PATH=tools/performance-tools.yaml
1461
+ SELECTED_TOOLSETS=monitoring,diagnostics
1462
+
1463
+ # Advanced merging (multiple config sources)
1464
+ TOOLS_YAML_PATH=tools/
1465
+ YAML_MERGE_ARRAYS=true # Combine toolsets from multiple files
1466
+ YAML_ALLOW_DUPLICATE_TOOLS=false # Enforce unique tool names
1467
+ YAML_VALIDATE_MERGED=true # Validate after merging
1468
+
1469
+ # Production: disable hot reload
1470
+ TOOLS_YAML_PATH=/opt/mcp-tools/production.yaml
1471
+ YAML_AUTO_RELOAD=false
1472
+ ```
1473
+
1474
+ **CLI Override:**
1475
+ ```bash
1476
+ # Override TOOLS_YAML_PATH at runtime
1477
+ npx ibmi-mcp-server --tools ./my-custom-tools
1478
+
1479
+ # Load specific toolsets only
1480
+ npx ibmi-mcp-server --toolsets performance,security
1481
+ ```
1482
+
1483
+ </details>
1484
+
1485
+ <details>
1486
+ <summary><strong>๐Ÿ› ๏ธ Built-in Tools Configuration</strong></summary>
1487
+
1488
+ Settings for controlling built-in MCP tools compiled into the server. These are separate from YAML-defined tools.
1489
+
1490
+ ## Built-in Tools Overview
1491
+
1492
+ The IBM i MCP Server includes two built-in tools for database operations:
1493
+
1494
+ | Tool | Status | Purpose | Configuration |
1495
+ |------|--------|---------|---------------|
1496
+ | `describe_sql_object` | โœ… Always enabled | Generate DDL for database objects | None (always available) |
1497
+ | `execute_sql` | โš ๏ธ Disabled by default | Execute ad-hoc SQL queries (readonly by default) | `IBMI_ENABLE_EXECUTE_SQL`<br/>`IBMI_EXECUTE_SQL_READONLY` |
1498
+
1499
+ ---
1500
+
1501
+ ### Describe SQL Object Tool
1502
+
1503
+ The `describe_sql_object` tool generates SQL DDL (Data Definition Language) statements for IBM i database objects using the `QSYS2.GENERATE_SQL` procedure. This tool is **always enabled** and extremely useful for providing AI models with detailed object structure information.
1504
+
1505
+ **Features:**
1506
+ - Generates CREATE statements with full DDL syntax
1507
+ - Supports all major database object types (TABLE, VIEW, INDEX, PROCEDURE, FUNCTION, etc.)
1508
+ - Read-only operation - only describes objects, never modifies them
1509
+ - Returns complete DDL including columns, constraints, indexes, and object-specific properties
1510
+
1511
+ **Supported Object Types:**
1512
+ ALIAS, CONSTRAINT, FUNCTION, INDEX, MASK, PERMISSION, PROCEDURE, SCHEMA, SEQUENCE, TABLE, TRIGGER, TYPE, VARIABLE, VIEW, XSR
1513
+
1514
+ **Use Cases:**
1515
+ - **Schema Discovery**: Help AI understand database structure before generating queries
1516
+ - **Documentation**: Generate CREATE statements for version control or documentation
1517
+ - **Migration**: Capture object definitions for recreating in other environments
1518
+ - **Debugging**: Understand object structure when troubleshooting issues
1519
+
1520
+ **Example Usage:**
1521
+ ```json
1522
+ {
1523
+ "object_name": "CUSTOMER",
1524
+ "object_library": "SALES",
1525
+ "object_type": "TABLE"
1526
+ }
1527
+ ```
1528
+
1529
+ **Returns:**
1530
+ ```sql
1531
+ CREATE TABLE SALES.CUSTOMER (
1532
+ CUSTID INTEGER NOT NULL,
1533
+ CUSTNAME VARCHAR(100),
1534
+ EMAIL VARCHAR(255),
1535
+ CREATED_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
1536
+ PRIMARY KEY (CUSTID)
1537
+ );
1538
+ ```
1539
+
1540
+ > **Note:** This tool has no configuration - it's always available as a safe, read-only operation.
1541
+
1542
+ ---
1543
+
1544
+ ### Execute SQL Tool
1545
+
1546
+ The `execute_sql` tool allows MCP clients to run ad-hoc SQL queries against your IBM i Db2 database. This tool is **disabled by default** for security reasons.
1547
+
1548
+ | Variable | Description | Type | Default | Required |
1549
+ |----------|-------------|------|---------|----------|
1550
+ | `IBMI_ENABLE_EXECUTE_SQL` | Enable the built-in `execute_sql` tool | boolean | `false` | No |
1551
+ | `IBMI_EXECUTE_SQL_READONLY` | Control readonly mode (only SELECT queries) | boolean | `true` | No |
1552
+
1553
+ **Security Features:**
1554
+ The execute_sql tool includes multiple layers of protection:
1555
+ - **Read-only by default**: When `IBMI_EXECUTE_SQL_READONLY=true` (default), only SELECT/QUERY statements are allowed
1556
+ - **PARSE_STATEMENT validation**: Uses IBM i's native SQL parser (`QSYS2.PARSE_STATEMENT`) to validate query syntax and statement types
1557
+ - **AST/Regex validation**: Fast pattern matching to catch dangerous SQL keywords before execution
1558
+ - **Write operations opt-in**: Set `IBMI_EXECUTE_SQL_READONLY=false` to explicitly enable INSERT, UPDATE, DELETE, and other write operations
1559
+ - **Query length limit**: Maximum 10,000 characters per query
1560
+ - **Fail-closed security**: All validation failures result in query rejection
1561
+ - **Connection pooling**: Uses existing database connection pool with configured credentials
1562
+
1563
+ **When to Enable:**
1564
+ - โœ… **Development (readonly)**: Enable with `IBMI_EXECUTE_SQL_READONLY=true` for rapid prototyping and debugging with SELECT queries
1565
+ - โœ… **Development (write)**: Enable with `IBMI_EXECUTE_SQL_READONLY=false` only when you explicitly need INSERT/UPDATE/DELETE operations
1566
+ - โœ… **Trusted environments**: Enable when all MCP clients are trusted
1567
+ - โœ… **Read-only use cases**: Safe to enable with default readonly mode for ad-hoc query capabilities
1568
+ - โŒ **Production**: Consider using YAML-defined tools with explicit, curated queries instead
1569
+ - โŒ **Untrusted clients**: Keep disabled if any client might abuse query capabilities
1570
+ - โŒ **Write access in production**: Never enable write mode (`IBMI_EXECUTE_SQL_READONLY=false`) in production without strict authentication and authorization
1571
+
1572
+ **Examples:**
1573
+
1574
+ ```bash
1575
+ # Development: Enable ad-hoc SELECT queries (readonly mode)
1576
+ IBMI_ENABLE_EXECUTE_SQL=true
1577
+ IBMI_EXECUTE_SQL_READONLY=true # Default - only SELECT queries allowed
1578
+ DB2i_HOST=ibmi-dev.local
1579
+ DB2i_USER=DEVUSER
1580
+ DB2i_PASS=devpass
1581
+
1582
+ # Development: Enable write operations (INSERT/UPDATE/DELETE)
1583
+ IBMI_ENABLE_EXECUTE_SQL=true
1584
+ IBMI_EXECUTE_SQL_READONLY=false # Allow write operations
1585
+ DB2i_HOST=ibmi-dev.local
1586
+ DB2i_USER=DEVUSER
1587
+ DB2i_PASS=devpass
1588
+
1589
+ # Production: Use YAML tools instead (more controlled)
1590
+ IBMI_ENABLE_EXECUTE_SQL=false
1591
+ TOOLS_YAML_PATH=/opt/mcp-tools/production.yaml
1592
+ ```
1593
+
1594
+ > **โš ๏ธ Security Recommendation:** Keep `IBMI_EXECUTE_SQL_READONLY=true` (default) unless you explicitly need write operations. For production use cases requiring write access, consider using YAML-defined tools with parameterized queries instead of ad-hoc SQL.
1595
+
1596
+ ---
1597
+
1598
+ ### Comparison: Built-in Tools vs YAML Tools
1599
+
1600
+ | Feature | Built-in Tools | YAML SQL Tools |
1601
+ |---------|----------------|----------------|
1602
+ | **Definition** | Compiled into server (TypeScript) | Defined in YAML files |
1603
+ | **Queries** | Ad-hoc (client provides SQL) or fixed logic | Pre-defined (curated by admin) |
1604
+ | **Control** | Feature flag + readonly mode | Full query + parameter control |
1605
+ | **Security** | PARSE_STATEMENT + AST/Regex validation | Explicit whitelist of queries |
1606
+ | **Use Case** | Development & exploration | Production & controlled access |
1607
+ | **Configuration** | Environment variables | `TOOLS_YAML_PATH` |
1608
+ | **Examples** | `execute_sql`, `describe_sql_object` | Custom performance monitoring, security checks |
1609
+
1610
+ **Recommendation:**
1611
+ - Use **`describe_sql_object`** freely - it's safe and helps AI understand your database schema
1612
+ - Use **`execute_sql`** in development for quick exploration
1613
+ - Use **YAML tools** in production for controlled, curated query access
1614
+
1615
+ YAML tools allow you to:
1616
+ - Curate specific queries with documentation
1617
+ - Control parameters and validation
1618
+ - Organize tools into logical toolsets
1619
+ - Provide explicit descriptions for each query
1620
+
1621
+ See [Tools Documentation](../tools/README.md) for creating YAML SQL tools.
1622
+
1623
+ </details>
1624
+
1625
+ <details>
1626
+ <summary><strong>๐Ÿ“Š OpenTelemetry (Observability)</strong></summary>
1627
+
1628
+ Configuration for distributed tracing and metrics using OpenTelemetry.
1629
+
1630
+ | Variable | Description | Default | Required |
1631
+ |----------|-------------|---------|----------|
1632
+ | `OTEL_ENABLED` | Enable OpenTelemetry instrumentation | `false` | No |
1633
+ | `OTEL_SERVICE_NAME` | Service name for telemetry data | `MCP_SERVER_NAME` or package name | No |
1634
+ | `OTEL_SERVICE_VERSION` | Service version for telemetry data | `MCP_SERVER_VERSION` or package version | No |
1635
+ | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | OTLP endpoint for trace export | None (logs to file) | No |
1636
+ | `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` | OTLP endpoint for metrics export | None (not exported) | No |
1637
+ | `OTEL_TRACES_SAMPLER_ARG` | Trace sampling ratio (0.0 to 1.0, where 1.0 = sample all) | `1.0` (100%) | No |
1638
+ | `OTEL_LOG_LEVEL` | OTel internal diagnostic log level | `INFO` | No |
1639
+
1640
+ **Supported OTEL_LOG_LEVEL values:** `NONE`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `VERBOSE`, `ALL`
1641
+
1642
+ **Examples:**
1643
+ ```bash
1644
+ # Development: local file logging only
1645
+ OTEL_ENABLED=true
1646
+ OTEL_SERVICE_NAME=ibmi-mcp-dev
1647
+ OTEL_LOG_LEVEL=DEBUG
1648
+ # Traces written to logs/traces/ directory
1649
+
1650
+ # Production: export to Jaeger
1651
+ OTEL_ENABLED=true
1652
+ OTEL_SERVICE_NAME=ibmi-mcp-prod
1653
+ OTEL_SERVICE_VERSION=1.9.1
1654
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://jaeger:4318/v1/traces
1655
+ OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://jaeger:4318/v1/metrics
1656
+ OTEL_TRACES_SAMPLER_ARG=0.1 # Sample 10% of traces
1657
+ OTEL_LOG_LEVEL=WARN
1658
+
1659
+ # Production: export to cloud provider
1660
+ OTEL_ENABLED=true
1661
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://otlp.example.com/v1/traces
1662
+ OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://otlp.example.com/v1/metrics
1663
+ OTEL_TRACES_SAMPLER_ARG=1.0 # Sample all traces
1664
+ ```
1665
+
1666
+ **Instrumentation Coverage:**
1667
+ - All MCP tool executions
1668
+ - HTTP requests and responses
1669
+ - Database queries (SQL tools)
1670
+ - Authentication flows
1671
+ - Custom spans for critical operations
1672
+
1673
+ </details>
1674
+
1675
+ <details>
1676
+ <summary><strong>๐Ÿ”Œ OAuth Proxy (Advanced)</strong></summary>
1677
+
1678
+ Configuration for OAuth proxy endpoints (advanced use cases).
1679
+
1680
+ | Variable | Description | Default | Required |
1681
+ |----------|-------------|---------|----------|
1682
+ | `OAUTH_PROXY_AUTHORIZATION_URL` | OAuth authorization endpoint URL | None | No |
1683
+ | `OAUTH_PROXY_TOKEN_URL` | OAuth token endpoint URL | None | No |
1684
+ | `OAUTH_PROXY_REVOCATION_URL` | OAuth token revocation endpoint URL | None | No |
1685
+ | `OAUTH_PROXY_ISSUER_URL` | OAuth issuer URL for proxy | None | No |
1686
+ | `OAUTH_PROXY_SERVICE_DOCUMENTATION_URL` | Service documentation URL | None | No |
1687
+ | `OAUTH_PROXY_DEFAULT_CLIENT_REDIRECT_URIS` | Comma-separated default redirect URIs | None | No |
1688
+
1689
+ **Example:**
1690
+ ```bash
1691
+ OAUTH_PROXY_AUTHORIZATION_URL=https://auth.example.com/oauth/authorize
1692
+ OAUTH_PROXY_TOKEN_URL=https://auth.example.com/oauth/token
1693
+ OAUTH_PROXY_REVOCATION_URL=https://auth.example.com/oauth/revoke
1694
+ OAUTH_PROXY_ISSUER_URL=https://auth.example.com
1695
+ OAUTH_PROXY_SERVICE_DOCUMENTATION_URL=https://docs.example.com/oauth
1696
+ OAUTH_PROXY_DEFAULT_CLIENT_REDIRECT_URIS=http://localhost:3000/callback,https://app.example.com/callback
1697
+ ```
1698
+
1699
+ > **Note:** OAuth proxy features are for advanced integration scenarios. Most users should use standard OAuth authentication via `MCP_AUTH_MODE=oauth`.
1700
+
1701
+ </details>
1702
+
1703
+ ---
1704
+
1705
+ ### Configuration Best Practices
1706
+
1707
+ **Development:**
1708
+ ```bash
1709
+ # Recommended development .env
1710
+ MCP_TRANSPORT_TYPE=http
1711
+ MCP_HTTP_PORT=3010
1712
+ MCP_SESSION_MODE=auto
1713
+ MCP_LOG_LEVEL=debug
1714
+ MCP_AUTH_MODE=none # Or ibmi with allow HTTP
1715
+ NODE_ENV=development
1716
+
1717
+ DB2i_HOST=ibmi-dev.local
1718
+ DB2i_USER=DEVUSER
1719
+ DB2i_PASS=devpass
1720
+ DB2i_IGNORE_UNAUTHORIZED=true
1721
+
1722
+ TOOLS_YAML_PATH=tools/
1723
+ YAML_AUTO_RELOAD=true
1724
+ OTEL_ENABLED=true
1725
+ ```
1726
+
1727
+ **Production:**
1728
+ ```bash
1729
+ # Recommended production .env
1730
+ MCP_TRANSPORT_TYPE=http
1731
+ MCP_HTTP_PORT=3010
1732
+ MCP_SESSION_MODE=auto
1733
+ MCP_LOG_LEVEL=warn
1734
+ MCP_AUTH_MODE=ibmi # Or jwt/oauth
1735
+ NODE_ENV=production
1736
+
1737
+ DB2i_HOST=ibmi-prod.example.com
1738
+ DB2i_USER=PRODUSER
1739
+ DB2i_PASS=${SECURE_PASSWORD_FROM_VAULT}
1740
+ DB2i_IGNORE_UNAUTHORIZED=false # Require valid SSL
1741
+
1742
+ TOOLS_YAML_PATH=/opt/mcp-tools/production.yaml
1743
+ YAML_AUTO_RELOAD=false
1744
+ YAML_VALIDATE_MERGED=true
1745
+
1746
+ IBMI_HTTP_AUTH_ENABLED=true
1747
+ IBMI_AUTH_ALLOW_HTTP=false # HTTPS only
1748
+ IBMI_AUTH_PRIVATE_KEY_PATH=/opt/secrets/private.pem
1749
+ IBMI_AUTH_PUBLIC_KEY_PATH=/opt/secrets/public.pem
1750
+
1751
+ OTEL_ENABLED=true
1752
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://otlp.example.com/v1/traces
1753
+ ```
1754
+
1755
+ **Security Checklist:**
1756
+ - โœ… Never commit `.env` files to version control
1757
+ - โœ… Use secrets management (Vault, AWS Secrets Manager, etc.) in production
1758
+ - โœ… Rotate credentials and keys regularly
1759
+ - โœ… Use HTTPS/TLS in production (`IBMI_AUTH_ALLOW_HTTP=false`)
1760
+ - โœ… Enable authentication (`MCP_AUTH_MODE != none`)
1761
+ - โœ… Use strong passwords (12+ characters, mixed case, numbers, symbols)
1762
+ - โœ… Restrict `MCP_ALLOWED_ORIGINS` to known domains
1763
+ - โœ… Set appropriate `IBMI_AUTH_MAX_CONCURRENT_SESSIONS` limits
1764
+
1765
+ ## ๐Ÿ” IBM i HTTP Authentication (Beta)
1766
+
1767
+ The server supports IBM i HTTP authentication that allows clients to obtain access tokens for authenticated SQL tool execution. This enables per-user connection pooling and secure access to IBM i resources.
1768
+
1769
+ ### Authentication Flow
1770
+
1771
+ 1. **Client Authentication**: Clients authenticate with IBM i credentials via HTTP Basic Auth
1772
+ 2. **Token Generation**: Server creates a secure Bearer token and establishes a dedicated connection pool
1773
+ 3. **Tool Execution**: Subsequent tool calls use the Bearer token for authenticated execution
1774
+ 4. **Pool Management**: Each token maintains its own connection pool for isolation and security
1775
+
1776
+ ### Configuration
1777
+
1778
+ To enable IBM i HTTP authentication, we need to set up Encryption keys and configure the server environment. To protect IBM i credentials during transmission, the authentication flow uses RSA and AES encryption. You need to generate an RSA keypair for the server:
1779
+
1780
+ ```bash
1781
+ mkdir -p secrets
1782
+ openssl genpkey -algorithm RSA -out secrets/private.pem -pkeyopt rsa_keygen_bits:2048
1783
+ openssl rsa -pubout -in secrets/private.pem -out secrets/public.pem
1784
+ ```
1785
+
1786
+ Create or update your `.env` file with the following settings:
1787
+
1788
+ ```ini
1789
+ # Enable IBM i authentication system
1790
+ IBMI_HTTP_AUTH_ENABLED=true
1791
+ MCP_AUTH_MODE=ibmi
1792
+
1793
+ # IBM i authentication settings
1794
+ IBMI_AUTH_KEY_ID=development
1795
+ IBMI_AUTH_PRIVATE_KEY_PATH=secrets/private.pem
1796
+ IBMI_AUTH_PUBLIC_KEY_PATH=secrets/public.pem
1797
+
1798
+ # Security settings
1799
+ IBMI_AUTH_ALLOW_HTTP=true # Development only - use HTTPS in production
1800
+ IBMI_AUTH_TOKEN_EXPIRY_SECONDS=3600 # Token lifetime (1 hour)
1801
+
1802
+ # Resource management
1803
+ IBMI_AUTH_MAX_CONCURRENT_SESSIONS=100
1804
+ IBMI_AUTH_CLEANUP_INTERVAL_SECONDS=300
1805
+
1806
+ # IBM i connection details
1807
+ DB2i_HOST=your-ibmi-host
1808
+ DB2i_USER=your-username
1809
+ DB2i_PASS=your-password
1810
+ ```
1811
+
1812
+
1813
+ ### Getting Access Tokens
1814
+
1815
+ #### Option 1: Using the Token Script (Recommended)
1816
+
1817
+ Use the included `get-access-token.js` script to obtain authentication tokens:
1818
+
1819
+ ```bash
1820
+ # Using credentials from .env file
1821
+ node get-access-token.js --verbose
1822
+
1823
+ # Using CLI arguments (overrides .env)
1824
+ node get-access-token.js --user myuser --password mypass --host my-ibmi-host
1825
+
1826
+ # Quiet mode for shell evaluation
1827
+ eval $(node get-access-token.js --quiet)
1828
+ echo $IBMI_MCP_ACCESS_TOKEN
1829
+ ```
1830
+
1831
+ The script automatically:
1832
+
1833
+ - Loads IBM i credentials from `.env` with CLI fallback
1834
+ - Fetches the server's public key
1835
+ - Encrypts credentials client-side
1836
+ - Requests an access token
1837
+ - Sets `IBMI_MCP_ACCESS_TOKEN` environment variable
1838
+ - Provides copy-paste export commands
1839
+
1840
+ #### Sequence Overview
1841
+
1842
+ ```mermaid
1843
+ sequenceDiagram
1844
+ participant CLI as Client CLI
1845
+ participant Auth as MCP Server (/api/v1/auth)
1846
+ participant IBM as IBM i
1847
+
1848
+ CLI->>Auth: GET /api/v1/auth/public-key
1849
+ Auth-->>CLI: { keyId, publicKey }
1850
+
1851
+ CLI->>CLI: Generate AES-256-GCM session key + IV
1852
+ CLI->>CLI: Encrypt credentials + request body with session key
1853
+ CLI->>CLI: Encrypt session key with server public key (RSA-OAEP)
1854
+
1855
+ CLI->>Auth: POST /api/v1/auth { keyId, encryptedSessionKey, iv, authTag, ciphertext }
1856
+ Auth->>Auth: Look up keyId, decrypt session key with private key
1857
+ Auth->>Auth: Decrypt ciphertext, validate GCM tag, validate payload
1858
+
1859
+ Auth->>IBM: Authenticate against IBM i with decrypted credentials
1860
+ IBM-->>Auth: Success/Failure
1861
+
1862
+ Auth->>Auth: Generate access token, provision pool session
1863
+ Auth-->>CLI: 201 JSON { access_token, expires_in, ... }
1864
+ ```
1865
+
1866
+ ### Client Integration
1867
+
1868
+ Once you have a token, use it in your MCP client to authenticate requests:
1869
+
1870
+ ```python
1871
+ import asyncio
1872
+ import os
1873
+ from mcp import ClientSession
1874
+ from mcp.client.streamable_http import streamablehttp_client
1875
+
1876
+ async def main():
1877
+ # Get the access token from environment
1878
+ token = os.environ.get('IBMI_MCP_ACCESS_TOKEN')
1879
+ if not token:
1880
+ raise ValueError("IBMI_MCP_ACCESS_TOKEN environment variable not set")
1881
+
1882
+ # Set up authentication headers
1883
+ headers = {"Authorization": f"Bearer {token}"}
1884
+
1885
+ # Connect to the IBM i MCP server with authentication
1886
+ async with streamablehttp_client(
1887
+ "http://localhost:3010/mcp",
1888
+ headers=headers
1889
+ ) as (read_stream, write_stream, _):
1890
+ # Create a session using the authenticated streams
1891
+ async with ClientSession(read_stream, write_stream) as session:
1892
+ # Initialize the connection
1893
+ await session.initialize()
1894
+
1895
+ # List available tools (now authenticated with your IBM i credentials)
1896
+ tools = await session.list_tools()
1897
+ print(f"Available tools: {[tool.name for tool in tools.tools]}")
1898
+
1899
+ # Execute a tool with authenticated IBM i access
1900
+ result = await session.call_tool("system_status", {})
1901
+ print(f"System status result: {result}")
1902
+
1903
+ if __name__ == "__main__":
1904
+ asyncio.run(main())
1905
+ ```
1906
+
1907
+ ### Security Considerations
1908
+
1909
+ **Development Environment:**
1910
+
1911
+ - `IBMI_AUTH_ALLOW_HTTP=true` allows HTTP for testing
1912
+ - Use localhost/trusted networks only
1913
+ - Shorter token lifetimes for testing
1914
+
1915
+ **Production Environment:**
1916
+
1917
+ - `IBMI_AUTH_ALLOW_HTTP=false` enforces HTTPS
1918
+ - Use proper TLS certificates
1919
+ - Longer token lifetimes for stability
1920
+ - Network security and access controls
1921
+ - Monitor `IBMI_AUTH_MAX_CONCURRENT_SESSIONS` for resource usage
1922
+
1923
+ ### Authentication Endpoints
1924
+
1925
+ When enabled (`IBMI_HTTP_AUTH_ENABLED=true`), the server provides these endpoints:
1926
+
1927
+ | Endpoint | Method | Description |
1928
+ | -------------- | ------ | ------------------------------------------------------------ |
1929
+ | `/api/v1/auth` | POST | Authenticate with IBM i credentials and receive Bearer token |
1930
+
1931
+
1932
+
1933
+ ## ๐Ÿ› ๏ธ Running the Server (Development)
1934
+
1935
+ For development and contributions, you can build and run the server from source.
1936
+
1937
+ ### Building from Source
1938
+
1939
+ **1. Clone and Install:**
6
1940
 
7
1941
  ```bash
8
- # Install dependencies
1942
+ git clone https://github.com/IBM/ibmi-mcp-server.git
1943
+ cd ibmi-mcp-server
9
1944
  npm install
1945
+ ```
10
1946
 
11
- # Build
1947
+ **2. Build the Project:**
1948
+
1949
+ ```bash
1950
+ # Build TypeScript to JavaScript
12
1951
  npm run build
13
1952
 
14
- # Run server (HTTP mode)
1953
+ # Or clean rebuild
1954
+ npm run rebuild
1955
+ ```
1956
+
1957
+ **3. Configure Environment:**
1958
+
1959
+ ```bash
1960
+ # Copy example configuration
1961
+ cp .env.example .env
1962
+
1963
+ # Edit with your IBM i connection details
1964
+ code .env
1965
+ ```
1966
+
1967
+ **4. Run Development Server:**
1968
+
1969
+ ```bash
1970
+ # Start in HTTP mode
15
1971
  npm run start:http
16
1972
 
17
- # Run server (stdio mode)
1973
+ # Start in stdio mode
18
1974
  npm run start:stdio
1975
+ ```
19
1976
 
20
- # Run tests
1977
+ **5. Run Tests:**
1978
+
1979
+ ```bash
1980
+ # Run all tests
21
1981
  npm test
1982
+
1983
+ # Run in watch mode
1984
+ npm run test:watch
1985
+
1986
+ # Generate coverage report
1987
+ npm run test:coverage
22
1988
  ```
23
1989
 
24
- ## Configuration
1990
+ ---
25
1991
 
26
- Create a `.env` file in the **root of the monorepo** (parent directory):
1992
+ ### Transport Modes
1993
+
1994
+ #### HTTP Transport (Recommended for Development)
1995
+
1996
+ ```bash
1997
+ # Basic HTTP server
1998
+ npm run start:http
1999
+
2000
+ # HTTP with custom tools path
2001
+ npm run start:http -- --tools ./my-configs
2002
+
2003
+ # HTTP with specific toolsets
2004
+ npm run start:http -- --toolsets performance,monitoring
2005
+ ```
2006
+
2007
+ #### Stdio Transport (for CLI tools and MCP Inspector)
27
2008
 
28
2009
  ```bash
29
- cp ../.env.example ../.env
2010
+ # Basic stdio transport
2011
+ npm run start:stdio
2012
+
2013
+ # Stdio with custom tools path
2014
+ npm run start:stdio -- --tools ./my-custom-tools
30
2015
  ```
31
2016
 
32
- The server will automatically detect configuration in:
2017
+ > Make sure that to use the absolute path for tools
33
2018
 
34
- 1. Current working directory (for production deployments)
35
- 2. Parent directory (for monorepo development)
36
- 3. Server directory (for local overrides)
2019
+ ### Session Modes (HTTP Only)
37
2020
 
38
- ## Tool Configuration
2021
+ The `MCP_SESSION_MODE` environment variable controls how the HTTP server handles client sessions:
39
2022
 
40
- By default, the server loads SQL tools from `../tools/`. Override with:
2023
+ - **`auto` (default)**: Automatically detects client capabilities and uses the best session mode
2024
+ - **`stateful`**: Maintains persistent sessions with connection state
2025
+ - **`stateless`**: Each request is independent, no session state maintained
41
2026
 
42
2027
  ```bash
43
- TOOLS_YAML_PATH=../tools npm run start:http
2028
+ # Set session mode via environment variable
2029
+ MCP_SESSION_MODE=stateful npm run start:http
2030
+
2031
+ # Or set in .env file
2032
+ echo "MCP_SESSION_MODE=stateful" >> .env
2033
+ npm run start:http
44
2034
  ```
45
2035
 
46
- Or set in your `.env` file:
2036
+ ### CLI Options
47
2037
 
48
- ```ini
49
- TOOLS_YAML_PATH=tools
2038
+ Both transport modes support these command-line options:
2039
+
2040
+ > **Note**: CLI arguments override corresponding settings in `.env` file when provided.
2041
+
2042
+ | Option | Short | Description | Example |
2043
+ | -------------------- | ----- | ----------------------------------------------------------------------------- | --------------------------------- |
2044
+ | `--tools <path>` | | Override YAML tools configuration path (overrides `TOOLS_YAML_PATH`) | `--tools ./custom-configs` |
2045
+ | `--toolsets <list>` | `-ts` | Load only specific toolsets (comma-separated) (overrides `SELECTED_TOOLSETS`) | `--toolsets performance,security` |
2046
+ | `--transport <type>` | `-t` | Force transport type (`http` or `stdio`) (overrides `MCP_TRANSPORT_TYPE`) | `--transport http` |
2047
+ | `--help` | `-h` | Show help information | `--help` |
2048
+ | `--list-toolsets` | | List available toolsets from YAML configuration | `--list-toolsets` |
2049
+
2050
+ ### Common Development Scenarios
2051
+
2052
+ **1. Standard Development Server**
2053
+
2054
+ ```bash
2055
+ npm run start:http
2056
+ # Server: http://localhost:3010/mcp
2057
+ # Tools: tools/ (from .env)
2058
+ # Session: auto-detected
2059
+ ```
2060
+
2061
+ **2. Custom Tools Path**
2062
+
2063
+ ```bash
2064
+ npm run start:http -- --tools ./my-tools
2065
+ # Server: http://localhost:3010/mcp (port from .env or default)
2066
+ # Tools: ./my-tools
2067
+ ```
2068
+
2069
+ **3. Specific Toolsets Only**
2070
+
2071
+ ```bash
2072
+ npm run start:http -- --toolsets performance,monitoring
2073
+ # Only loads tools from 'performance' and 'monitoring' toolsets
2074
+ ```
2075
+
2076
+ ### Development Tips
2077
+
2078
+ - **Hot Reloading**: Enable `YAML_AUTO_RELOAD=true` in `.env` for automatic tool configuration updates
2079
+ - **Verbose Logging**: Set `MCP_LOG_LEVEL=debug` for detailed operation logs
2080
+ - **CORS**: Configure `MCP_ALLOWED_ORIGINS` for web-based clients
2081
+ - **Authentication**: Use `MCP_AUTH_MODE=ibmi` with IBM i HTTP auth for token-based access
2082
+
2083
+ ### Troubleshooting
2084
+
2085
+ **Port Already in Use**
2086
+
2087
+ ```bash
2088
+ # Configure port in .env file
2089
+ echo "MCP_HTTP_PORT=3011" >> .env
2090
+ npm run start:http
2091
+ ```
2092
+
2093
+ **Tools Not Loading**
2094
+
2095
+ ```bash
2096
+ # Check tools path
2097
+ npm run start:http -- --tools ./tools
2098
+
2099
+ # List available toolsets first
2100
+ npm run start:http -- --list-toolsets --tools ./tools
2101
+
2102
+ # Get help
2103
+ npm run start:http -- --help
50
2104
  ```
51
2105
 
52
- ## Documentation
2106
+ ## ๐Ÿ•ต๏ธโ€โ™‚๏ธ MCP Inspector
2107
+
2108
+ The MCP Inspector is a tool for exploring and debugging the MCP server's capabilities. It provides a user-friendly interface for interacting with the server, viewing available tools, and testing queries.
2109
+
2110
+ Here are the steps to run the MCP Inspector:
2111
+
2112
+ 1. Make sure to build the server
2113
+ ```bash
2114
+ cd ibmi-mcp-server/
2115
+ npm run build
2116
+ ```
2117
+ 2. Create an `mcp.json` file:
2118
+
2119
+ ```bash
2120
+ cp template_mcp.json mcp.json
2121
+ ```
2122
+
2123
+ Fill out the connection details in `mcp.json` with your IBM i system information. You should use the same credentials as in your `.env` file:
2124
+
2125
+ ```json
2126
+ {
2127
+ "mcpServers": {
2128
+ "default-server": {
2129
+ "command": "node",
2130
+ "args": ["dist/index.js", "--transport", "stdio", "--tools", "tools"],
2131
+ "env": {
2132
+ "NODE_OPTIONS": "--no-deprecation",
2133
+ "DB2i_HOST": "<DB2i_HOST>",
2134
+ "DB2i_USER": "<DB2i_USER>",
2135
+ "DB2i_PASS": "<DB2i_PASS>",
2136
+ "DB2i_PORT": "<DB2i_PORT>"
2137
+ }
2138
+ }
2139
+ }
2140
+ }
2141
+ ```
53
2142
 
54
- See the [root README](../README.md) for complete documentation and deployment guides.
2143
+ 3. Start the MCP Inspector
2144
+ ```bash
2145
+ npm run mcp-inspector
2146
+ ```
2147
+ 4. Click on the URL displayed in the terminal to open the MCP Inspector in your web browser.
55
2148
 
56
- ## Development
2149
+ ```bash
2150
+ Starting MCP inspector...
2151
+ โš™๏ธ Proxy server listening on 127.0.0.1:6277
2152
+ ๐Ÿ”‘ Session token: EXAMPLE_TOKEN
2153
+ Use this token to authenticate requests or set DANGEROUSLY_OMIT_AUTH=true to disable auth
57
2154
 
58
- This is the main server package within the monorepo. All server development happens here.
2155
+ ๐Ÿ”— Open inspector with token pre-filled:
2156
+ http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=EXAMPLE_TOKEN
59
2157
 
60
- - **Source**: `src/`
61
- - **Tests**: `tests/`
62
- - **Scripts**: `scripts/`
63
- - **Build Output**: `dist/`
2158
+ ๐Ÿ” MCP Inspector is up and running at http://127.0.0.1:6274 ๐Ÿš€
2159
+ ```
64
2160
 
65
- ### Available Scripts
2161
+ ![alt text](../docs/images/inspector.png)
66
2162
 
67
- - `npm run build` - Build the server
68
- - `npm run rebuild` - Clean and rebuild
69
- - `npm run start:http` - Start in HTTP mode
70
- - `npm run start:stdio` - Start in stdio mode
71
- - `npm test` - Run tests
72
- - `npm run test:watch` - Run tests in watch mode
73
- - `npm run test:coverage` - Run tests with coverage
74
- - `npm run lint` - Lint code
75
- - `npm run format` - Format code with Prettier
76
- - `npm run validate` - Validate tool configurations
2163
+ 5. Use the MCP Inspector to explore and test your MCP server's capabilities
2164
+ - View available tools and their parameters
2165
+ - Test queries against the server
2166
+ - Debug issues with tool execution
77
2167
 
78
- ### Architecture
2168
+ ---
79
2169
 
80
- See [CLAUDE.md](../CLAUDE.md) for architectural standards and development guidelines.
2170
+ ## Deployment
81
2171
 
82
- ## Monorepo Structure
2172
+ For production deployments with Docker, Podman, or OpenShift, see the [Deployment Guide](../deployment/README.md).
83
2173
 
84
- This server is part of a monorepo:
2174
+ ---
85
2175
 
86
- - `../tools/` - SQL tool YAML configurations
87
- - `../agents/` - Agent implementations and examples
88
- - `../apps/` - Deployment configurations (Docker, Gateway, n8n)
2176
+ ## ๐Ÿ—๏ธ Built With MCP TypeScript Template
2177
+
2178
+ This server was built using the [MCP TypeScript Template](https://github.com/cyanheads/mcp-ts-template), a production-ready foundation for building Model Context Protocol servers.
2179
+
2180
+ ### Template Features Used
2181
+
2182
+ The template provided essential infrastructure that accelerated development:
2183
+
2184
+ - **๐Ÿ”Œ Transport Layer** - Pre-built stdio and HTTP (Hono) transports with session management
2185
+ - **๐Ÿ”ญ Observability** - OpenTelemetry integration for distributed tracing and metrics
2186
+ - **๐Ÿ”’ Security** - Authentication middleware (JWT, OAuth, custom), input sanitization, rate limiting
2187
+ - **โš™๏ธ Error Handling** - Structured error categorization with `BaseErrorCode` and centralized `ErrorHandler`
2188
+ - **๐Ÿ“Š Type Safety** - TypeScript + Zod validation throughout the stack
2189
+ - **๐Ÿงช Testing Infrastructure** - Vitest integration with coverage reporting
2190
+
2191
+ ### Why This Template?
2192
+
2193
+ The MCP TypeScript Template provided a solid architectural foundation that allowed us to focus on IBM i-specific functionality rather than building MCP infrastructure from scratch. Key benefits:
2194
+
2195
+ 1. **Production-Ready Patterns**: "Logic Throws, Handler Catches" pattern ensures consistent error handling
2196
+ 2. **Modular Design**: Clear separation between core logic, handlers, and transports
2197
+ 3. **Enterprise Features**: Built-in observability, security, and performance monitoring
2198
+ 4. **Developer Experience**: Hot reloading, structured logging, and comprehensive tooling
2199
+
2200
+ ### Customizations for IBM i
2201
+
2202
+ While the template provided the foundation, we added IBM i-specific capabilities:
2203
+
2204
+ - **Mapepire Integration** - WebSocket-based Db2 for i connectivity
2205
+ - **SQL YAML Tool Configuration** - Declarative SQL tool definitions with merge capabilities
2206
+ - **IBM i HTTP Authentication** - RSA/AES encrypted credential flow with connection pooling
2207
+ - **SQL Tool Execution** - Parameterized query execution with result formatting
2208
+ - **Toolset Management** - Dynamic tool loading and filtering by toolset
2209
+
2210
+ ### Get Started with the Template
2211
+
2212
+ If you're building your own MCP server, check out the template:
2213
+
2214
+ ```bash
2215
+ # Use the template to create your own MCP server
2216
+ npx degit cyanheads/mcp-ts-template my-mcp-server
2217
+ cd my-mcp-server
2218
+ npm install
2219
+ npm run build
2220
+ ```