@purplesquirrel/watsonx-mcp-server 1.0.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.
@@ -0,0 +1,21 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 10
8
+ labels:
9
+ - "dependencies"
10
+ commit-message:
11
+ prefix: "chore(deps)"
12
+
13
+ - package-ecosystem: "github-actions"
14
+ directory: "/"
15
+ schedule:
16
+ interval: "weekly"
17
+ labels:
18
+ - "dependencies"
19
+ - "github-actions"
20
+ commit-message:
21
+ prefix: "chore(ci)"
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ node-version: [18.x, 20.x]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Run linter
30
+ run: npm run lint --if-present
31
+
32
+ - name: Run tests
33
+ run: npm test --if-present
34
+
35
+ - name: Build
36
+ run: npm run build --if-present
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Purple Squirrel Media
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,245 @@
1
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
+ [![MCP](https://img.shields.io/badge/MCP-Server-blue)](https://modelcontextprotocol.io)
3
+ [![watsonx](https://img.shields.io/badge/IBM-watsonx-052FAD)](https://www.ibm.com/watsonx)
4
+ [![CI](https://github.com/PurpleSquirrelMedia/watsonx-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/PurpleSquirrelMedia/watsonx-mcp-server/actions/workflows/ci.yml)
5
+
6
+ # watsonx MCP Server
7
+
8
+ MCP server for IBM watsonx.ai integration with Claude Code. Enables Claude to delegate tasks to IBM's foundation models (Granite, Llama, Mistral, etc.).
9
+
10
+ ## Features
11
+
12
+ - **Text Generation** - Generate text using watsonx.ai foundation models
13
+ - **Chat** - Have conversations with watsonx.ai chat models
14
+ - **Embeddings** - Generate text embeddings
15
+ - **Model Listing** - List all available foundation models
16
+
17
+ ## Available Tools
18
+
19
+ | Tool | Description |
20
+ |------|-------------|
21
+ | `watsonx_generate` | Generate text using watsonx.ai models |
22
+ | `watsonx_chat` | Chat with watsonx.ai models |
23
+ | `watsonx_embeddings` | Generate text embeddings |
24
+ | `watsonx_list_models` | List available models |
25
+
26
+ ## Setup
27
+
28
+ ### 1. Install Dependencies
29
+
30
+ ```bash
31
+ cd ~/watsonx-mcp-server
32
+ npm install
33
+ ```
34
+
35
+ ### 2. Configure Environment
36
+
37
+ Set these environment variables:
38
+
39
+ ```bash
40
+ WATSONX_API_KEY=your-ibm-cloud-api-key
41
+ WATSONX_URL=https://us-south.ml.cloud.ibm.com
42
+ WATSONX_SPACE_ID=your-deployment-space-id # Recommended: deployment space
43
+ WATSONX_PROJECT_ID=your-project-id # Alternative: project ID
44
+ ```
45
+
46
+ **Note**: Either `WATSONX_SPACE_ID` or `WATSONX_PROJECT_ID` is required for text generation, embeddings, and chat. Deployment spaces are recommended as they have Watson Machine Learning (WML) pre-configured.
47
+
48
+ ### 3. Add to Claude Code
49
+
50
+ The MCP server is already configured in `~/.claude.json`:
51
+
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "watsonx": {
56
+ "type": "stdio",
57
+ "command": "node",
58
+ "args": ["/Users/matthewkarsten/watsonx-mcp-server/index.js"],
59
+ "env": {
60
+ "WATSONX_API_KEY": "your-api-key",
61
+ "WATSONX_URL": "https://us-south.ml.cloud.ibm.com",
62
+ "WATSONX_SPACE_ID": "your-deployment-space-id"
63
+ }
64
+ }
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ Once configured, Claude can use watsonx.ai tools:
72
+
73
+ ```
74
+ User: Use watsonx to generate a haiku about coding
75
+
76
+ Claude: [Uses watsonx_generate tool]
77
+ Result: Code flows like water
78
+ Bugs arise, then disappear
79
+ Programs come alive
80
+ ```
81
+
82
+ ## Available Models
83
+
84
+ Some notable models available:
85
+
86
+ - `ibm/granite-3-3-8b-instruct` - IBM Granite 3.3 8B (recommended)
87
+ - `ibm/granite-13b-chat-v2` - IBM Granite chat model
88
+ - `ibm/granite-3-8b-instruct` - Granite 3 instruct model
89
+ - `meta-llama/llama-3-70b-instruct` - Meta's Llama 3 70B
90
+ - `mistralai/mistral-large` - Mistral AI large model
91
+ - `ibm/slate-125m-english-rtrvr-v2` - Embedding model
92
+
93
+ Use `watsonx_list_models` to see all available models.
94
+
95
+ ## Architecture
96
+
97
+ ```
98
+ Claude Code (Opus 4.5)
99
+
100
+ └──▶ watsonx MCP Server
101
+
102
+ └──▶ IBM watsonx.ai API
103
+
104
+ ├── Granite Models
105
+ ├── Llama Models
106
+ ├── Mistral Models
107
+ └── Embedding Models
108
+ ```
109
+
110
+ ## Two-Agent System
111
+
112
+ This enables a two-agent architecture where:
113
+
114
+ 1. **Claude (Opus 4.5)** - Primary reasoning agent, handles complex tasks
115
+ 2. **watsonx.ai** - Secondary agent for specific workloads
116
+
117
+ Claude can delegate tasks to watsonx.ai when:
118
+ - IBM-specific model capabilities are needed
119
+ - Running batch inference on enterprise data
120
+ - Using specialized Granite models
121
+ - Generating embeddings for RAG pipelines
122
+
123
+ ## IBM Cloud Resources
124
+
125
+ This MCP server uses:
126
+ - **Service**: watsonx.ai Studio (data-science-experience)
127
+ - **Plan**: Lite (free tier)
128
+ - **Region**: us-south
129
+
130
+ Create your own watsonx.ai project and deployment space in IBM Cloud.
131
+
132
+ ## Integration with IBM Z MCP Server
133
+
134
+ This watsonx MCP server works alongside the IBM Z MCP server:
135
+
136
+ ```
137
+ Claude Code (Opus 4.5)
138
+
139
+ ├──▶ watsonx MCP Server
140
+ │ └── Text generation, embeddings, chat
141
+
142
+ └──▶ ibmz MCP Server
143
+ └── Key Protect HSM, z/OS Connect
144
+ ```
145
+
146
+ Demo scripts in the ibmz-mcp-server:
147
+ - `demo-full-stack.js` - Full 5-service pipeline
148
+ - `demo-rag.js` - RAG with watsonx embeddings + Granite
149
+
150
+ ## Document Analyzer
151
+
152
+ The document analyzer (`document-analyzer.js`) provides powerful tools for analyzing your external drive data using watsonx.ai:
153
+
154
+ ### Commands
155
+
156
+ ```bash
157
+ # View document catalog (9,168 documents)
158
+ node document-analyzer.js catalog
159
+
160
+ # Summarize a document
161
+ node document-analyzer.js summarize 1002519.txt
162
+
163
+ # Analyze document type, topics, entities
164
+ node document-analyzer.js analyze 1002519.txt
165
+
166
+ # Ask questions about a document
167
+ node document-analyzer.js question 1002519.txt 'What AWS credentials are needed?'
168
+
169
+ # Generate embeddings for documents
170
+ node document-analyzer.js embed
171
+
172
+ # Semantic search across documents
173
+ node document-analyzer.js search 'IBM Cloud infrastructure'
174
+ ```
175
+
176
+ ### Features
177
+
178
+ - **Summarization**: Generate concise summaries of any document
179
+ - **Analysis**: Extract document type, topics, entities, and sentiment
180
+ - **Q&A**: Ask natural language questions about document content
181
+ - **Embeddings**: Generate 768-dimensional vectors for semantic search
182
+ - **Semantic Search**: Find similar documents using vector similarity
183
+
184
+ ### Demo
185
+
186
+ Run the full demo:
187
+ ```bash
188
+ ./demo-external-drive.sh
189
+ ```
190
+
191
+ ## Embedding Index & RAG
192
+
193
+ The `embedding-index.js` tool provides semantic search and RAG (Retrieval Augmented Generation):
194
+
195
+ ```bash
196
+ # Build an embedding index (50 documents)
197
+ node embedding-index.js build 50
198
+
199
+ # Semantic search
200
+ node embedding-index.js search 'cloud infrastructure'
201
+
202
+ # RAG query - retrieves relevant docs and generates answer
203
+ node embedding-index.js rag 'How do I set up AWS for Satellite?'
204
+
205
+ # Show index statistics
206
+ node embedding-index.js stats
207
+ ```
208
+
209
+ ## Batch Processor
210
+
211
+ The `batch-processor.js` tool processes multiple documents at once:
212
+
213
+ ```bash
214
+ # Classify documents into categories
215
+ node batch-processor.js classify 20
216
+
217
+ # Extract topics from documents
218
+ node batch-processor.js topics 15
219
+
220
+ # Generate one-line summaries
221
+ node batch-processor.js summarize 10
222
+
223
+ # Full analysis (classify + topics + summary)
224
+ node batch-processor.js full 10
225
+ ```
226
+
227
+ Categories: technical, business, creative, personal, code, legal, marketing, educational, other
228
+
229
+ ## Files
230
+
231
+ - `index.js` - MCP server implementation
232
+ - `document-analyzer.js` - Document analysis CLI tool
233
+ - `embedding-index.js` - Embedding index and RAG tool
234
+ - `batch-processor.js` - Batch document processor
235
+ - `demo-external-drive.sh` - Demo script
236
+ - `package.json` - Dependencies
237
+ - `README.md` - This file
238
+
239
+ ## Author
240
+
241
+ Matthew Karsten
242
+
243
+ ## License
244
+
245
+ MIT
@@ -0,0 +1,176 @@
1
+ # Troubleshooting Guide
2
+
3
+ Common issues and solutions for the watsonx MCP Server.
4
+
5
+ ## Authentication Errors
6
+
7
+ ### `WATSONX_API_KEY not set`
8
+
9
+ **Cause**: The API key environment variable is missing or empty.
10
+
11
+ **Solution**:
12
+ ```bash
13
+ # Set your IBM Cloud API key
14
+ export WATSONX_API_KEY="your-ibm-cloud-api-key"
15
+
16
+ # Or add to your Claude Code MCP config in ~/.claude.json
17
+ ```
18
+
19
+ ### `401 Unauthorized`
20
+
21
+ **Cause**: Invalid or expired API key.
22
+
23
+ **Solutions**:
24
+ 1. Verify your API key is correct in IBM Cloud console
25
+ 2. Generate a new API key if expired
26
+ 3. Ensure the API key has access to watsonx.ai services
27
+
28
+ ### `403 Forbidden`
29
+
30
+ **Cause**: API key lacks permissions for watsonx.ai.
31
+
32
+ **Solutions**:
33
+ 1. Check IAM permissions in IBM Cloud
34
+ 2. Ensure your account has watsonx.ai service enabled
35
+ 3. Verify the API key is associated with the correct account
36
+
37
+ ## Configuration Errors
38
+
39
+ ### `Space ID or Project ID required`
40
+
41
+ **Cause**: Neither `WATSONX_SPACE_ID` nor `WATSONX_PROJECT_ID` is set.
42
+
43
+ **Solution**:
44
+ ```bash
45
+ # Use a deployment space (recommended)
46
+ export WATSONX_SPACE_ID="your-deployment-space-id"
47
+
48
+ # OR use a project
49
+ export WATSONX_PROJECT_ID="your-project-id"
50
+ ```
51
+
52
+ **Finding your Space/Project ID**:
53
+ 1. Go to [IBM watsonx.ai](https://dataplatform.cloud.ibm.com)
54
+ 2. Open your deployment space or project
55
+ 3. Go to Settings/Manage tab
56
+ 4. Copy the Space ID or Project ID
57
+
58
+ ### `Invalid region URL`
59
+
60
+ **Cause**: `WATSONX_URL` points to wrong region or is malformed.
61
+
62
+ **Valid regions**:
63
+ ```bash
64
+ # US South (Dallas)
65
+ WATSONX_URL=https://us-south.ml.cloud.ibm.com
66
+
67
+ # EU Germany (Frankfurt)
68
+ WATSONX_URL=https://eu-de.ml.cloud.ibm.com
69
+
70
+ # EU Great Britain (London)
71
+ WATSONX_URL=https://eu-gb.ml.cloud.ibm.com
72
+
73
+ # Asia Pacific (Tokyo)
74
+ WATSONX_URL=https://jp-tok.ml.cloud.ibm.com
75
+ ```
76
+
77
+ ## Model Errors
78
+
79
+ ### `Model not found`
80
+
81
+ **Cause**: The specified model ID doesn't exist or isn't available.
82
+
83
+ **Solution**:
84
+ 1. Use `watsonx_list_models` to see available models
85
+ 2. Check model ID spelling (case-sensitive)
86
+ 3. Some models require specific deployment space types
87
+
88
+ **Common model IDs**:
89
+ - `ibm/granite-3-3-8b-instruct`
90
+ - `ibm/granite-13b-chat-v2`
91
+ - `meta-llama/llama-3-70b-instruct`
92
+ - `mistralai/mistral-large`
93
+
94
+ ### `Token limit exceeded`
95
+
96
+ **Cause**: Input or output exceeds model's maximum token limit.
97
+
98
+ **Solutions**:
99
+ 1. Reduce input text length
100
+ 2. Set `max_new_tokens` to a lower value
101
+ 3. Use a model with higher token limits
102
+
103
+ **Token limits by model**:
104
+ | Model | Max Input | Max Output |
105
+ |-------|-----------|------------|
106
+ | granite-3-3-8b-instruct | 8192 | 8192 |
107
+ | granite-13b-chat-v2 | 8192 | 4096 |
108
+ | llama-3-70b-instruct | 8192 | 4096 |
109
+
110
+ ## Connection Errors
111
+
112
+ ### `ECONNREFUSED` or `ETIMEDOUT`
113
+
114
+ **Cause**: Cannot reach IBM Cloud endpoints.
115
+
116
+ **Solutions**:
117
+ 1. Check internet connectivity
118
+ 2. Verify no firewall blocking IBM Cloud IPs
119
+ 3. Check IBM Cloud status page for outages
120
+ 4. Try a different region endpoint
121
+
122
+ ### `Rate limit exceeded`
123
+
124
+ **Cause**: Too many API requests in a short period.
125
+
126
+ **Solutions**:
127
+ 1. Add delays between requests
128
+ 2. Implement exponential backoff
129
+ 3. Check your service plan limits
130
+ 4. Upgrade to higher tier if needed
131
+
132
+ ## MCP Server Errors
133
+
134
+ ### Server not appearing in Claude Code
135
+
136
+ **Solutions**:
137
+ 1. Verify `~/.claude.json` syntax is valid JSON
138
+ 2. Check the path to `index.js` is correct
139
+ 3. Restart Claude Code after config changes
140
+ 4. Check server logs: `node /path/to/index.js`
141
+
142
+ ### `Cannot find module` errors
143
+
144
+ **Cause**: Dependencies not installed.
145
+
146
+ **Solution**:
147
+ ```bash
148
+ cd ~/watsonx-mcp-server
149
+ npm install
150
+ ```
151
+
152
+ ## Debugging
153
+
154
+ ### Enable verbose logging
155
+
156
+ ```bash
157
+ # Run server directly to see errors
158
+ node /Users/matthewkarsten/watsonx-mcp-server/index.js
159
+
160
+ # Check for syntax errors
161
+ node --check /Users/matthewkarsten/watsonx-mcp-server/index.js
162
+ ```
163
+
164
+ ### Test API connection
165
+
166
+ ```bash
167
+ # Test with curl
168
+ curl -X GET "https://us-south.ml.cloud.ibm.com/ml/v1/foundation_model_specs?version=2024-01-01" \
169
+ -H "Authorization: Bearer $(ibmcloud iam oauth-tokens | grep IAM | awk '{print $4}')"
170
+ ```
171
+
172
+ ## Getting Help
173
+
174
+ - [IBM watsonx.ai Documentation](https://cloud.ibm.com/docs/watsonx-ai)
175
+ - [IBM Cloud Status](https://cloud.ibm.com/status)
176
+ - [GitHub Issues](https://github.com/PurpleSquirrelMedia/watsonx-mcp-server/issues)