GLM-4.7 MCP Server
A Model Context Protocol server that routes tasks to Z.ai's GLM-4.7 model, enabling Claude Code to delegate work to a more cost-efficient AI model without sacrificing quality.
README
GLM-4.7 MCP Server
<div align="center">
Cost-efficient AI delegation for Claude Code
Features • Installation • Usage • Tools • Configuration
</div>
Overview
87% cost savings compared to Claude Opus while maintaining comparable quality for coding tasks.
The GLM-4.7 MCP Server is a Model Context Protocol server that routes tasks to Z.ai's GLM-4.7 model. It enables Claude Code to delegate work to a more cost-efficient AI model without sacrificing quality.
Why GLM-4.7?
| Feature | Claude Opus | GLM-4.7 |
|---|---|---|
| Cost per 1M tokens (input) | $15.00 | ~$2.00 |
| SWE-Bench Verified | 72.4% | 73.8% |
| Terminal Bench 2.0 | 38.2 | 41.0 |
| Savings | — | ~87% |
Features
- 13 specialized tools for common development tasks
- Read-only and write-capable agents for safe delegation
- Automatic model selection (haiku for quick tasks, sonnet/opus for complex)
- Seamless Claude Code integration via MCP
- Cost tracking with built-in comparison tools
Installation
Prerequisites
-
Claude Code CLI - Install from claude.ai/download
npm install -g @anthropic-ai/claude-code -
Z.ai API Key - Get your key at z.ai/subscribe
- GLM Coding Plan starts at ~1/7th the cost of Claude tiers
- 3x the usage limits compared to Claude
Install the Server
# Clone the repository
git clone https://github.com/robertcprice/glm-mcp-server.git
cd glm-mcp-server
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -e .
Configuration
1. Set Your API Key
Edit .env in the server directory:
ZAI_API_KEY=your_api_key_here
Or set as environment variable:
export ZAI_API_KEY=your_api_key_here
2. Add to Claude Desktop Config
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"glm": {
"command": "/path/to/glm-mcp-server/.venv/bin/python",
"args": ["/path/to/glm-mcp-server/server.py"],
"env": {
"ZAI_API_KEY": "your_api_key_here"
}
}
}
}
On Windows: %APPDATA%\Claude\claude_desktop_config.json
On Linux: ~/.config/Claude/claude_desktop_config.json
3. Restart Claude Code
Restart Claude Code to load the new MCP server.
Usage
Once configured, the GLM tools are available in Claude Code:
Quick Questions
Use glm_ask to explain what this React hook does
Code Analysis
Use glm_analyze to review the authentication flow in src/auth/
Implementation
Use glm_implement to add user profile editing to the settings page
Cost Comparison
Use glm_compare_costs with 50000 input tokens and 20000 output tokens
Tools
| Tool | Description | Access | Best For |
|---|---|---|---|
glm_ask |
Quick questions | None | Explanations, brainstorming |
glm_summarize |
Summarize text | None | Docs, meeting notes |
glm_explain |
Explain code/concepts | None | Learning, understanding |
glm_analyze |
Analyze codebase | Read-only | Architecture, patterns |
glm_review |
Code review | Read-only | Quality, security, style |
glm_find_bugs |
Find potential bugs | Read-only | Debugging, QA |
glm_implement |
Implementation | Write | Features, refactoring |
glm_refactor |
Refactor code | Write | Code cleanup |
glm_write_tests |
Generate unit tests | Write | TDD, coverage |
glm_document |
Add documentation | Write | Docstrings, API docs |
glm_generate_readme |
Generate README.md | Write | Project docs |
glm_status |
Server status | — | Diagnostics |
glm_compare_costs |
Cost comparison | — | Budgeting |
Examples
Code Review
Use glm_review with review_focus="security" on src/api/auth.ts
Generate Tests
Use glm_write_tests for src/utils/validation.js with test_framework="jest"
Documentation
Use glm_document for src/services/user.py with style="google"
Bug Hunt
Use glm_find_bugs on src/components/payment/checkout.tsx
Model Selection
The server automatically maps Claude model names to GLM models:
| Claude | GLM | Use Case |
|---|---|---|
| haiku | glm-4.5-air | Quick tasks, summaries |
| sonnet | glm-4.7 | Balanced quality/speed |
| opus | glm-4.7 | Highest quality |
You can specify the model parameter in any tool:
Use glm_ask with model="haiku" to quickly summarize this file
Development
Running the Server Directly
source .venv/bin/activate
python server.py
Running Tests
pip install pytest pytest-asyncio
pytest
Project Structure
glm-mcp-server/
├── server.py # Main MCP server implementation
├── pyproject.toml # Project configuration
├── .env # API key (not in git)
├── .venv/ # Virtual environment
└── README.md # This file
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE for details.
Acknowledgments
- Anthropic for Claude Code and the MCP protocol
- Z.ai for the GLM-4.7 model and API
- FastMCP for the excellent MCP framework
Support
- Issues: GitHub Issues
- Z.ai Docs: docs.z.ai
- MCP Docs: modelcontextprotocol.io
<div align="center">
Made with ❤️ for cost-effective AI development
</div>
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.