loading…
Search for a command to run...
loading…
Provides web search, content extraction, and AI summarization capabilities using the GLM-4.7-Flash model. It enables users to perform web searches, fetch websit
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.
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.
search_webSearch 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_summarizeFetch 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_summarizeSearch 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
}
# 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
# Set your API key
export ZAI_API_KEY="your-zai-api-key"
# Run the server
python src/server.py
| Variable | Description | Required | Default |
|---|---|---|---|
ZAI_API_KEY |
Your ZAI API key | Yes | - |
The server uses the following ZAI API configuration:
https://api.z.ai/api/paas/v4glm-4.7-flash# 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
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"
}
}
}
}
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"
}
}
}
}
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}"
}
}
]
}
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"
}
}
}
}
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 supports MCP servers natively. To configure:
Create/Update the MCP configuration file:
# Default location: ~/.config/opencode/mcp_servers.json
mkdir -p ~/.config/opencode
nano ~/.config/opencode/mcp_servers.json
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
}
}
}
Restart OpenCode to load the new MCP server
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
# 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": [...]
})
}
]
}
}
# 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
})
}
]
}
}
# 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
})
}
]
}
}
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!
============================================================
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
aiohttp - Async HTTP clientbeautifulsoup4 - HTML parsingopenai - OpenAI-compatible client for ZAI APIServer won't start
python --versionpip install -r requirements.txtecho $ZAI_API_KEYSearch returns no results
Summarization fails
MCP client can't connect
chmod +x src/server.pyEnable debug logging by setting environment variable:
export ZAI_DEBUG=1
python src/server.py
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"zai-mcp-server": {
"command": "npx",
"args": []
}
}
}