ZAI MCP Server
A Model Context Protocol (MCP) server that provides web search, content fetching, and AI-powered summarization capabilities using ZAI's GLM-4.7-Flash model.
Features
- Web Search: Search the web using DuckDuckGo
- Content Fetching: Clean and extract text from any website
- AI Summarization: Summarize web content using GLM-4.7-Flash
- Combined Workflows: Search, fetch, and summarize in one operation
- Fast & Efficient: Uses flash model for quick responses
Tools
`search_web`
Search the web for information.
Parameters:
query(string, required): Search querynum_results(number, optional): Number of results (1-10, default: 5)
Returns:
{
"query": "search term",
"count": 5,
"results": [
{
"title": "Result Title",
"url": "https://example.com",
"snippet": "Brief snippet of the content..."
}
]
}
`fetch_and_summarize`
Fetch a website URL and summarize its content.
Parameters:
url(string, required): Website URL to fetchmax_content_length(number, optional): Max content length to process (default: 10000)
Returns:
{
"url": "https://example.com/article",
"title": "Article Title",
"summary": "AI-generated summary of the content...",
"content_length": 5000
}
`search_and_summarize`
Search the web, fetch the top result, and summarize it.
Parameters:
query(string, required): Search queryresult_index(number, optional): Which search result to fetch (1-10, default: 1)
Returns:
{
"query": "search term",
"result_index": 1,
"url": "https://example.com/article",
"title": "Article Title",
"summary": "AI-generated summary...",
"total_results": 10
}
Installation
Prerequisites
- Python 3.8 or higher
- ZAI API key (get one at https://z.ai/model-api)
- pip package manager
Install from source
# Clone the repository
git clone https://github.com/yourusername/zai-mcp-server.git
cd zai-mcp-server
# Install dependencies
pip install -r requirements.txt
# Make server executable
chmod +x src/server.py
Quick Start
# Set your API key
export ZAI_API_KEY="your-zai-api-key"
# Run the server
python src/server.py
Configuration
Environment Variables
| Variable | Description | Required | Default |
|---|---|---|---|
ZAI_API_KEY |
Your ZAI API key | Yes | - |
API Configuration
The server uses the following ZAI API configuration:
- Base URL:
https://api.z.ai/api/paas/v4 - Model:
glm-4.7-flash - Max Tokens: 1000
- Temperature: 0.7
Usage
Standalone Testing
# Test initialization
echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}' | python src/server.py
# List available tools
echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}' | python src/server.py
# Search the web
echo '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "search_web", "arguments": {"query": "AI news", "num_results": 3}}}' | python src/server.py
Integration with Claude Desktop
Add to Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"zai": {
"command": "python3",
"args": ["/absolute/path/to/zai-mcp-server/src/server.py"],
"env": {
"ZAI_API_KEY": "your-zai-api-key"
}
}
}
}
Integration with Cursor
Add to Cursor settings file (~/.cursor/mcp_config.json):
{
"mcpServers": {
"zai": {
"command": "python3",
"args": ["/absolute/path/to/zai-mcp-server/src/server.py"],
"env": {
"ZAI_API_KEY": "your-zai-api-key"
}
}
}
}
Integration with Cline (VS Code)
Add to your MCP settings in VS Code:
{
"mcpServers": [
{
"name": "zai",
"command": "python3",
"args": ["/absolute/path/to/zai-mcp-server/src/server.py"],
"env": {
"ZAI_API_KEY": "${env:ZAI_API_KEY}"
}
}
]
}
Integration with Continue
Add to ~/.continue/config.json:
{
"mcpServers": {
"zai": {
"command": "python3",
"args": ["/absolute/path/to/zai-mcp-server/src/server.py"],
"env": {
"ZAI_API_KEY": "your-zai-api-key"
}
}
}
}
Integration with Roo Code
Add to Roo Code's MCP configuration:
{
"mcpServers": {
"zai": {
"command": "python3",
"args": ["/absolute/path/to/zai-mcp-server/src/server.py"],
"env": {
"ZAI_API_KEY": "your-zai-api-key"
}
}
}
}
OpenCode Native Integration
Setup
OpenCode supports MCP servers natively. To configure:
- Create/Update the MCP configuration file:
# Default location: ~/.config/opencode/m
Tools 3
search_webSearch the web for information.fetch_and_summarizeFetch a website URL and summarize its content.search_and_summarizeSearch the web, fetch the top result, and summarize it.Environment Variables
ZAI_API_KEYrequiredYour ZAI API key