使用说明
watsonx MCP服务器
MCP服务器,用于IBM watsonx.ai与Claude Code的集成。使Claude能够将任务委托给IBM的基础模型(Granite、Llama、Mistral等)。
特性
- 文本生成 -使用watsonx.ai基础模型生成文本
- 聊天 -与watsonx.ai聊天模特进行对话
- 嵌入 -生成文本嵌入
- 模型列表 -列出所有可用的基础型号
可用工具
| 工具 | 说明 |
|---|---|
watsonx_generate |
使用watsonx.ai模型生成文本 |
watsonx_chat |
与watsonx.ai模特聊天 |
watsonx_embeddings |
生成文本嵌入 |
watsonx_list_models |
列出可用型号 |
设置
1.安装依赖项
cd ~/watsonx-mcp-server
npm install
2.配置环境
设置这些环境变量:
WATSONX_API_KEY=your-ibm-cloud-api-key
WATSONX_URL=https://us-south.ml.cloud.ibm.com
WATSONX_SPACE_ID=your-deployment-space-id # Recommended: deployment space
WATSONX_PROJECT_ID=your-project-id # Alternative: project ID
备注:要么 WATSONX_SPACE_ID 或 WATSONX_PROJECT_ID 是文本生成、嵌入和聊天所必需的。建议使用部署空间,因为它们预先配置了Watson机器学习(WML)。
3.添加到克劳德代码
MCP服务器已在中配置 ~/.claude.json:
{
"mcpServers": {
"watsonx": {
"type": "stdio",
"command": "node",
"args": ["/Users/matthewkarsten/watsonx-mcp-server/index.js"],
"env": {
"WATSONX_API_KEY": "your-api-key",
"WATSONX_URL": "https://us-south.ml.cloud.ibm.com",
"WATSONX_SPACE_ID": "your-deployment-space-id"
}
}
}
}
用法
配置后,Claude可以使用watsonx.ai工具:
User: Use watsonx to generate a haiku about coding
Claude: [Uses watsonx_generate tool]
Result: Code flows like water
Bugs arise, then disappear
Programs come alive
可用模型
一些值得注意的型号:
ibm/granite-3-3-8b-instruct-IBM Granite 3.3 8B(推荐)ibm/granite-13b-chat-v2-IBM Granite聊天模型ibm/granite-3-8b-instruct-花岗岩3指示模型meta-llama/llama-3-70b-instruct-梅塔的Llama 3 70Bmistralai/mistral-large-Mistral AI大型模型ibm/slate-125m-english-rtrvr-v2-嵌入模型
使用 watsonx_list_models 查看所有可用型号。
建筑
Claude Code (Opus 4.5)
│
└──▶ watsonx MCP Server
│
└──▶ IBM watsonx.ai API
│
├── Granite Models
├── Llama Models
├── Mistral Models
└── Embedding Models
双代理系统
这实现了双代理架构,其中:
- 克劳德(作品4.5) -主要推理代理,处理复杂任务
- 沃森 -特定工作负载的辅助代理
在以下情况下,Claude可以将任务委托给watsonx.ai:
- 需要IBM特定的模型功能
- 对企业数据进行批量推理
- 使用专门的花岗岩模型
- 为RAG管道生成嵌入
IBM云资源
此MCP服务器使用:
- 服务:watsonx.ai工作室(数据科学体验)
- 计划:精简版(免费版)
- 区域:美国南部
在IBM Cloud中创建自己的watsonx.ai项目和部署空间。
与IBM Z MCP服务器集成
此Watson MCP服务器与IBM Z MCP服务器协同工作:
Claude Code (Opus 4.5)
│
├──▶ watsonx MCP Server
│ └── Text generation, embeddings, chat
│
└──▶ ibmz MCP Server
└── Key Protect HSM, z/OS Connect
ibmz mcp服务器中的演示脚本:
demo-full-stack.js-全5服务管道demo-rag.js-RAG,镶嵌Watson+花岗岩
文档分析器
文档分析器(document-analyzer.js)提供了使用watsonx.ai分析外部驱动器数据的强大工具:
命令
# View document catalog (9,168 documents)
node document-analyzer.js catalog
# Summarize a document
node document-analyzer.js summarize 1002519.txt
# Analyze document type, topics, entities
node document-analyzer.js analyze 1002519.txt
# Ask questions about a document
node document-analyzer.js question 1002519.txt 'What AWS credentials are needed?'
# Generate embeddings for documents
node document-analyzer.js embed
# Semantic search across documents
node document-analyzer.js search 'IBM Cloud infrastructure'
特性
- 摘要:生成任何文档的简明摘要
- 分析:提取文档类型、主题、实体和情感
- 问答:询问有关文档内容的自然语言问题
- 嵌入:生成768个维度向量用于语义搜索
- 语义搜索:使用向量相似度查找相似文档
演示
运行完整演示:
./demo-external-drive.sh
嵌入索引和RAG
这 embedding-index.js 该工具提供语义搜索和RAG(检索增强生成):
# Build an embedding index (50 documents)
node embedding-index.js build 50
# Semantic search
node embedding-index.js search 'cloud infrastructure'
# RAG query - retrieves relevant docs and generates answer
node embedding-index.js rag 'How do I set up AWS for Satellite?'
# Show index statistics
node embedding-index.js stats
批处理器
这 batch-processor.js 该工具一次处理多个文档:
# Classify documents into categories
node batch-processor.js classify 20
# Extract topics from documents
node batch-processor.js topics 15
# Generate one-line summaries
node batch-processor.js summarize 10
# Full analysis (classify + topics + summary)
node batch-processor.js full 10
分类:技术、商业、创意、个人、代码、法律、营销、教育、其他
文件
index.js-MCP服务器实现document-analyzer.js-文档分析CLI工具embedding-index.js-嵌入索引和RAG工具batch-processor.js-批处理文档处理器demo-external-drive.sh-演示脚本package.json-依赖关系README.md-此文件
作者
马修·卡斯滕
许可证
麻省理工学院
