
zai-mcp-manager
Comprehensive management capabilities for Z.AI MCP servers, including quota tracking, health monitor
Z.AI MCP Manager Skill
Comprehensive management tool for Z.AI MCP servers with quota tracking, health monitoring, and configuration validation
šÆ Overview
The Z.AI MCP Manager skill provides complete management capabilities for Z.AI MCP servers, ensuring optimal usage of the FREE Z.AI Lite Plan (100 searches + 100 readers) while providing advanced monitoring and analytics.
⨠Features
- š Quota Monitoring: Real-time tracking of search and reader usage with intelligent alerts
- š„ Health Checking: Comprehensive connectivity and performance monitoring
- āļø Configuration Validation: Automated setup validation and error detection
- š Usage Analytics: Detailed reports and optimization recommendations
- š ļø Management Tools: Scripts for configuration generation and maintenance
- š Security Best Practices: API key validation and secure configuration
š Quick Start
1. Validate Your Setup
python scripts/config_validator.py
2. Check Health Status
python scripts/health_checker.py
3. Monitor Quota Usage
python scripts/quota_monitor.py
4. Generate Configuration Templates
python scripts/config_template_generator.py
š Skill Structure
zai-mcp-manager/
āāā SKILL.md # Comprehensive skill documentation
āāā scripts/
ā āāā quota_monitor.py # Real-time quota tracking
ā āāā health_checker.py # Connectivity and performance tests
ā āāā config_validator.py # Configuration validation
ā āāā config_template_generator.py # Generate optimized configs
āāā README.md # This file
š ļø Available Scripts
Quota Monitor (quota_monitor.py)
Real-time quota tracking and alerting
from zai_mcp_manager.scripts.quota_monitor import ZAIMCPQuotaMonitor
monitor = ZAIMCPQuotaMonitor()
status = await monitor.check_quota_status()
report = await monitor.generate_quota_report()
Features:
- ā Real-time quota status
- ā Usage alerts at 80% and 95%
- ā Usage analytics and trends
- ā JSON and markdown reports
Health Checker (health_checker.py)
Comprehensive endpoint health monitoring
from zai_mcp_manager.scripts.health_checker import ZAIMCPHealthChecker
checker = ZAIMCPHealthChecker()
health_status = await checker.check_all_endpoints()
Features:
- ā Connectivity testing
- ā Response time monitoring
- ā Performance scoring (0-100)
- ā Error detection and reporting
Configuration Validator (config_validator.py)
Automated configuration validation
from zai_mcp_manager.scripts.config_validator import ZAIMCPConfigurationValidator
validator = ZAIMCPConfigurationValidator()
report = await validator.validate_configuration()
Features:
- ā File existence checks
- ā API key validation
- ā Endpoint verification
- ā Security assessment
- ā Configuration scoring (0-100)
Template Generator (config_template_generator.py)
Generate optimized configuration templates
from zai_mcp_manager.scripts.config_template_generator import generate_all_templates
generated_files = generate_all_templates("./zai_config")
Generated Files:
- ā
.mcp.json- Optimized MCP server configuration - ā
.env.template- Environment variables template - ā
zai_mcp_client.py- Python client code template - ā
zai_integration_guide.md- Mini-Agent integration guide
š Monitoring Dashboard
Create a monitoring dashboard by combining multiple scripts:
import asyncio
from zai_mcp_manager.scripts.quota_monitor import ZAIMCPQuotaMonitor
from zai_mcp_manager.scripts.health_checker import ZAIMCPHealthChecker
from zai_mcp_manager.scripts.config_validator import ZAIMCPConfigurationValidator
async def generate_dashboard():
"""Generate comprehensive monitoring dashboard"""
# Get quota status
monitor = ZAIMCPQuotaMonitor()
quota_status = await monitor.check_quota_status()
# Get health status
checker = ZAIMCPHealthChecker()
health_status = await checker.check_all_endpoints()
# Get configuration status
validator = ZAIMCPConfigurationValidator()
config_status = await validator.validate_configuration()
# Generate combined report
print("=== Z.AI MCP DASHBOARD ===")
print(f"Overall Health: {health_status.overall_status}")
print(f"Config Score: {config_status.overall_score}/100")
print(f"Quota Usage: {quota_status.usage_percentage}%")
print("===========================")
asyncio.run(generate_dashboard())
š Validation Categories
The configuration validator checks:
File Structure
- ā
Required files exist (
.env,.mcp.json) - ā Recommended files present
- ā Proper file permissions
Environment Configuration
- ā ZAI_API_KEY format and validity
- ā Environment variable accessibility
MCP Configuration
- ā Server definitions and endpoints
- ā Authentication headers
- ā Timeout and retry settings
- ā JSON syntax validation
Connectivity
- ā API endpoint accessibility
- ā Authentication verification
- ā Response format validation
Security
- ā API key protection
- ā Secure file permissions
- ā HTTPS enforcement
š Quota Management
Understanding Quotas
The Z.AI Lite Plan includes:
- 100 Web Searches per month
- 100 Web Readers per month
- Reset: Monthly cycle
- Warnings: 80% and 95% usage thresholds
Optimization Strategies
- Batch Operations: Group similar requests
- Caching: Store results for repeated queries
- Smart Filtering: Use specific search terms
- Strategic Timing: Plan usage around renewal
Alert System
- 80% Warning: "Quota approaching limit"
- 95% Critical: "Quota nearly exhausted"
- 100% Blocked: Operations disabled
š§ Integration Examples
With Mini-Agent
The Z.AI MCP Manager integrates seamlessly with your existing Mini-Agent setup:
# Your existing Z.AI tools already work with MCP manager
from mini_agent.tools.zai_web_tool import ZAIWebTool
# Add monitoring
from zai_mcp_manager.scripts.quota_monitor import ZAIMCPQuotaMonitor
tool = ZAIWebTool()
monitor = ZAIMCPQuotaMonitor()
# Check status before operations
quota_status = await monitor.check_quota_status()
if quota_status.status == "critical":
print("ā ļø Quota nearly exhausted")
# Implement fallback strategy
Standalone Usage
Use the MCP manager independently of Mini-Agent:
import asyncio
from zai_mcp_manager.scripts.quota_monitor import ZAIMCPQuotaMonitor
async def standalone_usage():
monitor = ZAIMCPQuotaMonitor()
# Check quota status
status = await monitor.check_quota_status()
print(f"Searches: {status.searches_used}/{status.searches_total}")
print(f"Readers: {status.readers_used}/{status.readers_total}")
# Generate usage report
report = await monitor.generate_quota_report()
print(report)
asyncio.run(standalone_usage())
šØ Troubleshooting
Common Issues
API Key Invalid
Error: Authentication failed - API key invalid
Solution: Verify your ZAI_API_KEY in .env file
Quota Exhausted
Error: Search quota exceeded (100/100)
Solution: Wait for monthly reset or upgrade plan
Connection Timeout
Error: Connection timeout
Solution: Check network connectivity and try again
Debug Commands
# Validate setup
python scripts/config_validator.py
# Test connectivity
python scripts/health_checker.py
# Check quota usage
python scripts/quota_monitor.py
š Best Practices
Configuration
- ā Keep API keys in environment variables only
- ā Use version control for configuration templates
- ā Validate configuration before deployment
Monitoring
- ā Set up automated health checks
- ā Monitor quota usage daily
- ā Configure alerts for quota exhaustion
Security
- ā Never commit API keys to version control
- ā Rotate API keys regularly
- ā Use HTTPS for all communications
Performance
- ā Implement retry logic with exponential backoff
- ā Cache frequently accessed data
- ā Use batch operations when possible
š Additional Resources
- Z.AI Documentation: https://docs.z.ai/
- MCP Protocol: https://modelcontextprotocol.io/
- Mini-Agent Guide: See project documentation
- API Limits: Check your Z.AI account dashboard
š¤ Contributing
This skill is part of the Mini-Agent ecosystem. To improve it:
- Test thoroughly in your environment
- Report issues through Mini-Agent channels
- Share optimization strategies
- Contribute to the documentation
š License
Part of the Mini-Agent project. See project license for details.
šÆ Ready to optimize your Z.AI MCP usage? Start with python scripts/config_validator.py!