watsonx-mcp-server 1.0.1

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.
package/README.md ADDED
@@ -0,0 +1,240 @@
1
+ # watsonx MCP Server
2
+
3
+ MCP server for IBM watsonx.ai integration with Claude Code. Enables Claude to delegate tasks to IBM's foundation models (Granite, Llama, Mistral, etc.).
4
+
5
+ ## Features
6
+
7
+ - **Text Generation** - Generate text using watsonx.ai foundation models
8
+ - **Chat** - Have conversations with watsonx.ai chat models
9
+ - **Embeddings** - Generate text embeddings
10
+ - **Model Listing** - List all available foundation models
11
+
12
+ ## Available Tools
13
+
14
+ | Tool | Description |
15
+ |------|-------------|
16
+ | `watsonx_generate` | Generate text using watsonx.ai models |
17
+ | `watsonx_chat` | Chat with watsonx.ai models |
18
+ | `watsonx_embeddings` | Generate text embeddings |
19
+ | `watsonx_list_models` | List available models |
20
+
21
+ ## Setup
22
+
23
+ ### 1. Install Dependencies
24
+
25
+ ```bash
26
+ cd ~/watsonx-mcp-server
27
+ npm install
28
+ ```
29
+
30
+ ### 2. Configure Environment
31
+
32
+ Set these environment variables:
33
+
34
+ ```bash
35
+ WATSONX_API_KEY=your-ibm-cloud-api-key
36
+ WATSONX_URL=https://us-south.ml.cloud.ibm.com
37
+ WATSONX_SPACE_ID=your-deployment-space-id # Recommended: deployment space
38
+ WATSONX_PROJECT_ID=your-project-id # Alternative: project ID
39
+ ```
40
+
41
+ **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.
42
+
43
+ ### 3. Add to Claude Code
44
+
45
+ The MCP server is already configured in `~/.claude.json`:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "watsonx": {
51
+ "type": "stdio",
52
+ "command": "node",
53
+ "args": ["/Users/matthewkarsten/watsonx-mcp-server/index.js"],
54
+ "env": {
55
+ "WATSONX_API_KEY": "your-api-key",
56
+ "WATSONX_URL": "https://us-south.ml.cloud.ibm.com",
57
+ "WATSONX_SPACE_ID": "your-deployment-space-id"
58
+ }
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ## Usage
65
+
66
+ Once configured, Claude can use watsonx.ai tools:
67
+
68
+ ```
69
+ User: Use watsonx to generate a haiku about coding
70
+
71
+ Claude: [Uses watsonx_generate tool]
72
+ Result: Code flows like water
73
+ Bugs arise, then disappear
74
+ Programs come alive
75
+ ```
76
+
77
+ ## Available Models
78
+
79
+ Some notable models available:
80
+
81
+ - `ibm/granite-3-3-8b-instruct` - IBM Granite 3.3 8B (recommended)
82
+ - `ibm/granite-13b-chat-v2` - IBM Granite chat model
83
+ - `ibm/granite-3-8b-instruct` - Granite 3 instruct model
84
+ - `meta-llama/llama-3-70b-instruct` - Meta's Llama 3 70B
85
+ - `mistralai/mistral-large` - Mistral AI large model
86
+ - `ibm/slate-125m-english-rtrvr-v2` - Embedding model
87
+
88
+ Use `watsonx_list_models` to see all available models.
89
+
90
+ ## Architecture
91
+
92
+ ```
93
+ Claude Code (Opus 4.5)
94
+
95
+ └──▶ watsonx MCP Server
96
+
97
+ └──▶ IBM watsonx.ai API
98
+
99
+ ├── Granite Models
100
+ ├── Llama Models
101
+ ├── Mistral Models
102
+ └── Embedding Models
103
+ ```
104
+
105
+ ## Two-Agent System
106
+
107
+ This enables a two-agent architecture where:
108
+
109
+ 1. **Claude (Opus 4.5)** - Primary reasoning agent, handles complex tasks
110
+ 2. **watsonx.ai** - Secondary agent for specific workloads
111
+
112
+ Claude can delegate tasks to watsonx.ai when:
113
+ - IBM-specific model capabilities are needed
114
+ - Running batch inference on enterprise data
115
+ - Using specialized Granite models
116
+ - Generating embeddings for RAG pipelines
117
+
118
+ ## IBM Cloud Resources
119
+
120
+ This MCP server uses:
121
+ - **Service**: watsonx.ai Studio (data-science-experience)
122
+ - **Plan**: Lite (free tier)
123
+ - **Region**: us-south
124
+
125
+ Create your own watsonx.ai project and deployment space in IBM Cloud.
126
+
127
+ ## Integration with IBM Z MCP Server
128
+
129
+ This watsonx MCP server works alongside the IBM Z MCP server:
130
+
131
+ ```
132
+ Claude Code (Opus 4.5)
133
+
134
+ ├──▶ watsonx MCP Server
135
+ │ └── Text generation, embeddings, chat
136
+
137
+ └──▶ ibmz MCP Server
138
+ └── Key Protect HSM, z/OS Connect
139
+ ```
140
+
141
+ Demo scripts in the ibmz-mcp-server:
142
+ - `demo-full-stack.js` - Full 5-service pipeline
143
+ - `demo-rag.js` - RAG with watsonx embeddings + Granite
144
+
145
+ ## Document Analyzer
146
+
147
+ The document analyzer (`document-analyzer.js`) provides powerful tools for analyzing your external drive data using watsonx.ai:
148
+
149
+ ### Commands
150
+
151
+ ```bash
152
+ # View document catalog (9,168 documents)
153
+ node document-analyzer.js catalog
154
+
155
+ # Summarize a document
156
+ node document-analyzer.js summarize 1002519.txt
157
+
158
+ # Analyze document type, topics, entities
159
+ node document-analyzer.js analyze 1002519.txt
160
+
161
+ # Ask questions about a document
162
+ node document-analyzer.js question 1002519.txt 'What AWS credentials are needed?'
163
+
164
+ # Generate embeddings for documents
165
+ node document-analyzer.js embed
166
+
167
+ # Semantic search across documents
168
+ node document-analyzer.js search 'IBM Cloud infrastructure'
169
+ ```
170
+
171
+ ### Features
172
+
173
+ - **Summarization**: Generate concise summaries of any document
174
+ - **Analysis**: Extract document type, topics, entities, and sentiment
175
+ - **Q&A**: Ask natural language questions about document content
176
+ - **Embeddings**: Generate 768-dimensional vectors for semantic search
177
+ - **Semantic Search**: Find similar documents using vector similarity
178
+
179
+ ### Demo
180
+
181
+ Run the full demo:
182
+ ```bash
183
+ ./demo-external-drive.sh
184
+ ```
185
+
186
+ ## Embedding Index & RAG
187
+
188
+ The `embedding-index.js` tool provides semantic search and RAG (Retrieval Augmented Generation):
189
+
190
+ ```bash
191
+ # Build an embedding index (50 documents)
192
+ node embedding-index.js build 50
193
+
194
+ # Semantic search
195
+ node embedding-index.js search 'cloud infrastructure'
196
+
197
+ # RAG query - retrieves relevant docs and generates answer
198
+ node embedding-index.js rag 'How do I set up AWS for Satellite?'
199
+
200
+ # Show index statistics
201
+ node embedding-index.js stats
202
+ ```
203
+
204
+ ## Batch Processor
205
+
206
+ The `batch-processor.js` tool processes multiple documents at once:
207
+
208
+ ```bash
209
+ # Classify documents into categories
210
+ node batch-processor.js classify 20
211
+
212
+ # Extract topics from documents
213
+ node batch-processor.js topics 15
214
+
215
+ # Generate one-line summaries
216
+ node batch-processor.js summarize 10
217
+
218
+ # Full analysis (classify + topics + summary)
219
+ node batch-processor.js full 10
220
+ ```
221
+
222
+ Categories: technical, business, creative, personal, code, legal, marketing, educational, other
223
+
224
+ ## Files
225
+
226
+ - `index.js` - MCP server implementation
227
+ - `document-analyzer.js` - Document analysis CLI tool
228
+ - `embedding-index.js` - Embedding index and RAG tool
229
+ - `batch-processor.js` - Batch document processor
230
+ - `demo-external-drive.sh` - Demo script
231
+ - `package.json` - Dependencies
232
+ - `README.md` - This file
233
+
234
+ ## Author
235
+
236
+ Matthew Karsten
237
+
238
+ ## License
239
+
240
+ 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)