ZAI MCP Server

ZAI MCP Server

Provides web search, content extraction, and AI summarization capabilities using the GLM-4.7-Flash model. It enables users to perform web searches, fetch website data, and generate concise content summaries through integrated tools.

Category
Visit Server

README

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 query
  • num_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 fetch
  • max_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 query
  • result_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:

  1. Create/Update the MCP configuration file:

    # Default location: ~/.config/opencode/mcp_servers.json
    mkdir -p ~/.config/opencode
    nano ~/.config/opencode/mcp_servers.json
    
  2. Add ZAI MCP Server configuration:

    {
      "mcpServers": {
        "zai": {
          "name": "ZAI Web Search & Summarization",
          "description": "Search web and summarize content using GLM-4.7-Flash",
          "command": "python3",
          "args": ["/home/op/zai-mcp-server/src/server.py"],
          "env": {
            "ZAI_API_KEY": "your-zai-api-key"
          },
          "enabled": true
        }
      }
    }
    
  3. Restart OpenCode to load the new MCP server

Usage in OpenCode

Once configured, you can use the MCP server in OpenCode conversations:

User: Search for recent developments in AI and summarize the top result

Assistant: I'll use the ZAI MCP server to search and summarize for you.

[Calls search_and_summarize tool]

The ZAI MCP server found an article about recent AI developments. Here's a summary:
- Main point 1
- Main point 2
- Main point 3

Full article available at: https://example.com/ai-developments

Examples

Example 1: Web Search

# Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search_web",
    "arguments": {
      "query": "machine learning trends 2024",
      "num_results": 5
    }
  }
}

# Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": JSON.stringify({
          "query": "machine learning trends 2024",
          "count": 5,
          "results": [...]
        })
      }
    ]
  }
}

Example 2: Fetch and Summarize

# Request
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "fetch_and_summarize",
    "arguments": {
      "url": "https://www.example.com/article"
    }
  }
}

# Response
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "content": [
      {
        "type": "text",
        "text": JSON.stringify({
          "url": "https://www.example.com/article",
          "title": "Article Title",
          "summary": "Key points:\n• Point 1\n• Point 2\n• Point 3",
          "content_length": 5000
        })
      }
    ]
  }
}

Example 3: Search and Summarize (Combined)

# Request
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "search_and_summarize",
    "arguments": {
      "query": "quantum computing breakthrough",
      "result_index": 1
    }
  }
}

# Response
{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [
      {
        "type": "text",
        "text": JSON.stringify({
          "query": "quantum computing breakthrough",
          "result_index": 1,
          "url": "https://example.com/quantum-news",
          "title": "Major Quantum Computing Breakthrough",
          "summary": "Researchers have achieved a significant milestone...",
          "total_results": 10
        })
      }
    ]
  }
}

Testing

Run the test suite to verify the server is working correctly:

python examples/test_server.py

Expected output:

============================================================
ZAI MCP Server Test Suite
============================================================

Testing initialization...
✓ Initialize: mcp-zai-server v1.0.0

Testing tools list...
✓ Available tools (3):
  - search_web: Search the web for information using DuckDuckGo
  - fetch_and_summarize: Fetch a website URL and summarize its content using GLM-4.7-Flash
  - search_and_summarize: Search the web, fetch top result, and summarize using GLM-4.7-Flash

Testing resources list...
✓ Available resources (1):
  - zai://status: Current status of ZAI MCP server

Testing resource read...
✓ Server status:
  Status: online
  Model: glm-4.7-flash
  API Endpoint: https://api.z.ai/api/paas/v4
  Tools: search_web, fetch_and_summarize, search_and_summarize

============================================================
✓ All tests passed!
============================================================

Development

Project Structure

zai-mcp-server/
├── src/
│   └── server.py          # Main MCP server implementation
├── docs/
│   ├── ARCHITECTURE.md     # Architecture documentation
│   └── API_REFERENCE.md    # Detailed API reference
├── examples/
│   └── test_server.py      # Test suite and examples
├── requirements.txt           # Python dependencies
├── README.md                # This file
└── .env.example             # Environment variables template

Dependencies

  • aiohttp - Async HTTP client
  • beautifulsoup4 - HTML parsing
  • openai - OpenAI-compatible client for ZAI API

Troubleshooting

Common Issues

Server won't start

  • Ensure Python 3.8+ is installed: python --version
  • Check dependencies are installed: pip install -r requirements.txt
  • Verify API key is set: echo $ZAI_API_KEY

Search returns no results

  • DuckDuckGo API may have rate limits
  • Try with a different query
  • Check internet connectivity

Summarization fails

  • Verify API key is valid at https://z.ai/model-api
  • Check API credits/balance
  • Ensure URL is accessible

MCP client can't connect

  • Verify server path in configuration is correct
  • Ensure Python3 is in system PATH
  • Check file permissions: chmod +x src/server.py

Debug Mode

Enable debug logging by setting environment variable:

export ZAI_DEBUG=1
python src/server.py

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

  • Issues: Report bugs and feature requests on GitHub Issues
  • ZAI API Documentation: https://docs.z.ai
  • MCP Specification: https://modelcontextprotocol.io

Acknowledgments

  • ZAI for providing the GLM-4.7-Flash API
  • DuckDuckGo for the search API
  • Model Context Protocol team for the specification

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured