GLM-4.7 MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GLM-4.7 MCP Server review the code in src/api/auth.ts for security issues"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GLM-4.7 MCP Server
Cost-efficient AI delegation for Claude Code
Features • Installation • Usage • Tools • Configuration
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% |
Related MCP server: MCP AI Bridge
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-codeZ.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_hereOr set as environment variable:
export ZAI_API_KEY=your_api_key_here2. 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 doesCode Analysis
Use glm_analyze to review the authentication flow in src/auth/Implementation
Use glm_implement to add user profile editing to the settings pageCost Comparison
Use glm_compare_costs with 50000 input tokens and 20000 output tokensTools
Tool | Description | Access | Best For |
| Quick questions | None | Explanations, brainstorming |
| Summarize text | None | Docs, meeting notes |
| Explain code/concepts | None | Learning, understanding |
| Analyze codebase | Read-only | Architecture, patterns |
| Code review | Read-only | Quality, security, style |
| Find potential bugs | Read-only | Debugging, QA |
| Implementation | Write | Features, refactoring |
| Refactor code | Write | Code cleanup |
| Generate unit tests | Write | TDD, coverage |
| Add documentation | Write | Docstrings, API docs |
| Generate README.md | Write | Project docs |
| Server status | — | Diagnostics |
| Cost comparison | — | Budgeting |
Examples
Code Review
Use glm_review with review_focus="security" on src/api/auth.tsGenerate 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.tsxModel 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 fileDevelopment
Running the Server Directly
source .venv/bin/activate
python server.pyRunning Tests
pip install pytest pytest-asyncio
pytestProject 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 fileContributing
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
Made with ❤️ for cost-effective AI development
Available Tools
13 toolsglm_analyzeA
Analyze codebase using GLM with read access.
Use for: understanding code structure, finding patterns, architecture analysis, dependency mapping.
Has READ-ONLY access: Read, Glob, Grep, LS, Bash (safe commands).
Args: task: Analysis task to perform working_directory: Project directory (defaults to current) model: "haiku" or "sonnet"
Returns: Analysis results
Inputs: task (required), model, working_directory. Returns: result
glm_askA
Quick question to GLM - no tools, fast response.
Use for: explanations, analysis, brainstorming, quick answers. Does NOT have access to files or tools - pure generation.
Cost: ~10x cheaper than Claude Haiku. Use liberally.
Args: question: Your question or prompt model: "haiku" (fastest) or "sonnet" (better quality)
Returns: GLM's response
Inputs: question (required), model. Returns: result
glm_compare_costsA
Compare costs between Claude and GLM.
Args: tokens_input: Input tokens to compare tokens_output: Output tokens to compare
Returns: Cost comparison table
Inputs: tokens_input, tokens_output. Returns: result
glm_documentA
Add or update documentation for a file using GLM.
Use for: adding docstrings, generating README, documenting APIs.
Args: file_path: Path to file to document style: "google", "sphinx", "numpy", "javadoc" working_directory: Project directory model: "haiku" or "sonnet"
Returns: File with added documentation
Inputs: file_path (required), model, style, working_directory. Returns: result
glm_explainA
Explain code or a concept using GLM.
Use for: understanding code, learning concepts, documentation.
Args: code_or_concept: Code snippet or concept to explain context: Additional context (e.g., language, framework) model: "haiku" or "sonnet"
Returns: Explanation
Inputs: code_or_concept (required), model, context. Returns: result
glm_find_bugsA
Find potential bugs in code using GLM.
Use for: bug detection, edge case analysis, error prone patterns.
Args: code_or_file: Inline code or file path to analyze working_directory: Directory context for file paths model: "haiku" or "sonnet"
Returns: List of potential bugs with explanations
Inputs: code_or_file (required), model, working_directory. Returns: result
glm_generate_readmeA
Generate a README.md for a project using GLM.
Use for: creating project documentation, onboarding.
Args: working_directory: Project directory style: "standard", "comprehensive", "minimal" model: "haiku" or "sonnet"
Returns: Generated README.md content
Inputs: working_directory (required), model, style. Returns: result
glm_implementA
GLM agent with write access for implementation tasks.
Use for: writing code, creating files, making changes, refactoring.
Has FULL access including Write and Edit. WARNING: This can modify files.
Args: task: Implementation task to perform working_directory: Project directory (REQUIRED) allowed_tools: Tools to allow (default: full coding set) model: "haiku" or "sonnet"
Returns: Agent's output including changes made
Inputs: task (required), working_directory (required), model, allowed_tools. Returns: result
glm_refactorA
Refactor code using GLM.
Use for: improving code structure, applying patterns, cleanup.
Args: file_path: Path to file to refactor instructions: Refactoring instructions working_directory: Project directory model: "haiku" or "sonnet"
Returns: Refactored code and explanation
Inputs: file_path (required), instructions (required), working_directory (required), model. Returns: result
glm_reviewA
Code review by GLM agent.
Use for: security review, performance analysis, best practices.
Args: code_or_file: Inline code or file path to review review_focus: "general", "security", "performance", "style", "bugs" working_directory: Directory context for file paths model: "haiku" or "sonnet"
Returns: Code review with findings and suggestions
Inputs: code_or_file (required), model, review_focus, working_directory. Returns: result
glm_statusA
Check GLM MCP server status and configuration.
Returns: Status information about the GLM server setup
Inputs: no named parameters. Returns: result
glm_summarizeA
Summarize text using GLM.
Use for: document summaries, meeting notes, code explanations.
Args: text: The text to summarize style: "concise", "detailed", "bullet-points", "executive" model: "haiku" or "sonnet"
Returns: Summarized text
Inputs: text (required), model, style. Returns: result
glm_write_testsA
Generate unit tests for a file using GLM.
Use for: test generation, coverage improvement, TDD support.
Args: file_path: Path to file to test test_framework: "pytest", "jest", "vitest", "unittest" working_directory: Project directory model: "haiku" or "sonnet"
Returns: Generated test file
Inputs: file_path (required), model, test_framework, working_directory. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Most tools have clearly distinct roles (e.g., summarize vs. explain vs. implement), but a few pairs are close: glm_review and glm_find_bugs both analyze code, and glm_explain could be seen as a specialized glm_ask. Overall, the boundaries are clear enough that an agent will usually pick the right tool, with only minor potential for confusion.
All tools share the 'glm_' prefix and use snake_case, and most follow a verb or verb_noun pattern (e.g., glm_summarize, glm_implement, glm_write_tests). The one notable deviation is glm_status, which uses a noun instead of an action, slightly breaking the pattern. Otherwise, the naming is consistent and readable.
With 13 tools, the set is well-scoped for a GLM-powered coding assistant. Each tool serves a distinct function—question answering, summarization, explanation, analysis, review, bug finding, implementation, refactoring, test generation, documentation, README generation, status checking, and cost comparison—and none feel redundant.
The tool surface covers the full development lifecycle: from asking questions and explaining concepts to analyzing, implementing, refactoring, testing, and documenting code. Minor gaps include a dedicated 'fix' tool (though implement/refactor can handle it) and a generic conversation tool (though glm_ask covers it). No critical workflows are missing.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Cloudflare Workers MCP server: ai-model-router
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol (MCP) server that lets you seamlessly use OpenAI's models right from Claude.1319 npm77MIT
- AlicenseBqualityDmaintenanceA secure Model Context Protocol server that enables Claude Code to connect with OpenAI and Google Gemini models, allowing users to query multiple AI providers through a standardized interface.33MIT
- AlicenseNot gradedqualityDmaintenanceAn enhanced Model Context Protocol server that enables Claude to seamlessly collaborate with multiple AI models (Gemini, OpenAI, local models) for code analysis and development tasks, maintaining context across conversations.54Apache 2.0
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides unified access to 400+ AI models from 30+ providers through OpenRouter's API, enabling seamless integration with Claude Code.42Apache 2.0