io.github.ooples/token-optimizer-mcp
效率与工作流by ooples
Intelligent token optimization achieving 95%+ reduction through caching, compression, and 80+ tools
什么是 io.github.ooples/token-optimizer-mcp?
Intelligent token optimization achieving 95%+ reduction through caching, compression, and 80+ tools
README
GitHub Actions CI/CD Documentation
This repository uses GitHub Actions for automated CI/CD with comprehensive quality gates, automated releases, and dependency management.
Table of Contents
- Overview
- Workflows
- Setup Instructions
- Status Checks
- Release Process
- Secrets and Variables
- Troubleshooting
Overview
Our CI/CD pipeline includes:
- Continuous Integration: Automated testing, linting, and quality checks on every PR
- Quality Gates: Bundle size tracking, security audits, license compliance
- Automated Releases: Semantic versioning and npm publishing
- Dependency Management: Automated dependency updates via Dependabot
Workflows
1. CI Workflow (.github/workflows/ci.yml)
Triggers: Pull requests and pushes to master
Jobs:
lint-and-format
- Runs ESLint on TypeScript files
- Checks Prettier formatting
- Validates package.json
- Runtime: ~2-3 minutes
- Node Version: 20
build
- Compiles TypeScript to JavaScript
- Verifies build artifacts (dist/)
- Uploads build artifacts for use in other jobs
- Runtime: ~2-3 minutes
- Node Version: 20
test
- Runs unit tests across multiple Node versions (18, 20, 22)
- Generates code coverage reports
- Uploads coverage to Codecov
- Enforces 80% coverage threshold
- Runtime: ~5-8 minutes per Node version
- Matrix Strategy: Parallel execution across Node versions
performance-benchmarks
- Runs performance benchmark suite
- Compares results against baseline
- Fails if performance regression >10%
- Posts results as PR comment
- Runtime: ~3-5 minutes
- Node Version: 20
integration-test
- Starts MCP server
- Runs integration tests against live server
- Uploads logs on failure
- Runtime: ~3-5 minutes
- Node Version: 20
- Depends On:
buildjob
status-check
- Aggregates all job results
- Final gate before PR can be merged
- Runtime: <1 minute
- Depends On: All other jobs
Total CI Runtime: ~10-15 minutes (with parallelization)
2. Release Workflow (.github/workflows/release.yml)
Triggers: Push to master (after PR merge)
Jobs:
release
- Analyzes commits using conventional commit format
- Determines version bump (major/minor/patch)
- Generates CHANGELOG.md
- Creates Git tag
- Creates GitHub Release
- Runtime: ~3-5 minutes
- Node Version: 20
publish
- Publishes package to npm
- Verifies publication
- Only runs if new release was created
- Runtime: ~2-3 minutes
- Node Version: 20
- Depends On:
releasejob
notify
- Posts release announcement (Discord/Slack if configured)
- Comments on related issues
- Updates release summary
- Runtime: ~1-2 minutes
- Depends On:
release,publishjobs
Total Release Runtime: ~6-10 minutes
3. Quality Gates Workflow (.github/workflows/quality-gates.yml)
Triggers: Pull requests and pushes to master
Jobs:
bundle-size
- Analyzes compiled bundle size
- Compares against baseline
- Fails if size increases >5%
- Posts size comparison as PR comment
- Runtime: ~2-3 minutes
security-audit
- Runs
npm audit - Fails on critical vulnerabilities
- Warns on high vulnerabilities
- Posts audit results as PR comment
- Runtime: ~2-3 minutes
license-compliance
- Checks all dependency licenses
- Warns about copyleft licenses (GPL, AGPL, LGPL)
- Generates license report
- Runtime: ~2-3 minutes
dependency-vulnerabilities
- Runs Snyk scan (if configured)
- Checks for outdated dependencies
- Generates vulnerability report
- Runtime: ~2-3 minutes
code-quality
- Analyzes code complexity
- Counts lines of code
- Identifies TODO/FIXME comments
- Runtime: ~1-2 minutes
Total Quality Gates Runtime: ~9-14 minutes (parallel execution)
4. Commit Lint Workflow (.github/workflows/commitlint.yml)
Triggers: Pull requests
Jobs:
commitlint
- Validates all PR commits follow Conventional Commits format
- Posts format guide as PR comment on failure
- Runtime: ~1-2 minutes
5. Dependabot Configuration (.github/dependabot.yml)
Schedule: Weekly (Monday 9:00 AM UTC)
Features:
- Groups minor/patch updates for dev dependencies
- Groups patch updates for production dependencies
- Separate PRs for major version updates
- Auto-assigns to @ooples
- Labels:
dependencies,automated
Setup Instructions
1. Initial Setup
-
Clone the repository
bashgit clone https://github.com/ooples/token-optimizer-mcp.git cd token-optimizer-mcp -
Install dependencies
bashnpm install -
Install semantic-release and commitlint globally (optional)
bashnpm install -g semantic-release @commitlint/cli
2. Configure GitHub Secrets
Navigate to: Settings > Secrets and variables > Actions > New repository secret
Add the following secrets:
Required Secrets
| Secret Name | Description | How to Get |
|---|---|---|
NPM_TOKEN | npm authentication token | https://www.npmjs.com/settings/YOUR_USERNAME/tokens |
CODECOV_TOKEN | Codecov upload token (optional) | https://codecov.io/ |
Optional Secrets
| Secret Name | Description | Use Case |
|---|---|---|
SNYK_TOKEN | Snyk authentication token | Advanced security scanning |
3. Configure GitHub Variables (Optional)
Navigate to: Settings > Secrets and variables > Actions > Variables tab
| Variable Name | Description | Example |
|---|---|---|
DISCORD_WEBHOOK_URL | Discord webhook for release notifications | https://discord.com/api/webhooks/... |
SLACK_WEBHOOK_URL | Slack webhook for release notifications | https://hooks.slack.com/services/... |
4. Set Up Branch Protection
Follow instructions in BRANCH_PROTECTION.md
5. Initialize Performance Baseline
After first successful CI run:
- Download the benchmark results artifact
- Copy to
.github/performance-baseline.json - Commit and push:
bash
git add .github/performance-baseline.json git commit -m "chore: add performance baseline" git push
6. Initialize Bundle Size Baseline
After first successful build:
- Run:
du -sb dist | cut -f1 > .github/bundle-size-baseline.txt - Commit and push:
bash
git add .github/bundle-size-baseline.txt git commit -m "chore: add bundle size baseline" git push
Status Checks
All PRs must pass the following status checks before merging:
Critical Checks (Must Pass)
- ✅
lint-and-format- Code style and linting - ✅
build- TypeScript compilation - ✅
test (18)- Tests on Node 18 - ✅
test (20)- Tests on Node 20 - ✅
test (22)- Tests on Node 22 - ✅
commitlint- Commit message format
Quality Checks (Must Pass)
- ✅
bundle-size- Bundle size within limits - ✅
security-audit- No critical vulnerabilities - ✅
license-compliance- License compatibility
Optional Checks (Can Warn)
- ⚠️
performance-benchmarks- Performance metrics - ⚠️
integration-test- Integration test suite - ⚠️
code-quality- Code metrics and analysis
Release Process
Automated Release Flow
-
Developer creates PR with conventional commits
- Format:
type(scope): description - Examples:
feat(auth): add OAuth,fix(api): resolve race condition
- Format:
-
CI runs on PR
- All status checks must pass
- Code review required
- Conversations must be resolved
-
PR is merged to master
- Release workflow triggers automatically
- Semantic-release analyzes commits
-
Version determination
fix:commits → Patch version (0.0.X)feat:commits → Minor version (0.X.0)BREAKING CHANGE:→ Major version (X.0.0)
-
Automatic actions
- CHANGELOG.md updated
- Version bumped in package.json
- Git tag created (e.g., v0.2.1)
- GitHub Release created
- npm package published
- Related issues commented
Manual Release (Emergency)
If automated release fails:
# Ensure you're on master with latest changes
git checkout master
git pull
# Create version and tag
npm version patch -m "chore(release): %s" # or minor/major
# Push changes and tags
git push && git push --tags
# Publish to npm
npm publish
# Create GitHub release manually
gh release create v0.2.1 --generate-notes
Secrets and Variables
Getting NPM Token
- Log in to npm: https://www.npmjs.com/
- Click your profile → "Access Tokens"
- Click "Generate New Token" → "Classic Token"
- Select "Automation" type
- Copy token and add to GitHub Secrets as
NPM_TOKEN
Getting Codecov Token (Optional)
- Visit https://codecov.io/
- Sign in with GitHub
- Add your repository
- Copy the upload token
- Add to GitHub Secrets as
CODECOV_TOKEN
Setting Up Notifications
Discord
- Go to your Discord server settings
- Navigate to "Integrations" → "Webhooks"
- Create a new webhook
- Copy the webhook URL
- Add to GitHub Variables as
DISCORD_WEBHOOK_URL
Slack
- Go to https://api.slack.com/apps
- Create a new app or select existing
- Enable "Incoming Webhooks"
- Add webhook to workspace
- Copy the webhook URL
- Add to GitHub Variables as
SLACK_WEBHOOK_URL
Troubleshooting
CI Fails: "Coverage threshold not met"
Solution: Add more unit tests to reach 80% coverage
npm run test:coverage
# Check coverage/index.html for uncovered lines
CI Fails: "Bundle size increased by >5%"
Solution: Optimize bundle or update baseline
# Check what's causing size increase
npm run build
du -h dist/
# If increase is justified, update baseline:
du -sb dist | cut -f1 > .github/bundle-size-baseline.txt
git add .github/bundle-size-baseline.txt
git commit -m "chore: update bundle size baseline"
Release Fails: "No release published"
Cause: No conventional commits since last release
Solution: Ensure commits follow format:
feat:for featuresfix:for bug fixesBREAKING CHANGE:for breaking changes
NPM Publish Fails: "Authentication failed"
Solution: Verify NPM_TOKEN secret
- Check token is still valid: https://www.npmjs.com/settings/YOUR_USERNAME/tokens
- Regenerate token if needed
- Update GitHub secret
Dependabot PRs Failing
Solution: Review and fix issues
# Checkout Dependabot branch
git fetch origin
git checkout dependabot/npm_and_yarn/...
# Fix any breaking changes
npm install
npm test
# Commit fixes
git commit -am "fix: resolve dependency conflicts"
git push
Performance Benchmarks Failing
Solution: Investigate performance regression
- Download benchmark artifacts from failed run
- Compare with baseline
- Profile the code to find bottleneck
- Optimize or update baseline if acceptable
Best Practices
Commit Messages
✅ Good
feat(api): add token refresh endpoint
fix(cache): resolve memory leak in LRU cache
docs(readme): update installation instructions
refactor(core): simplify optimization logic
❌ Bad
Update code
Fix bug
WIP
changes
PR Workflow
- Create feature branch:
git checkout -b feat/my-feature - Make changes with conventional commits
- Push and create PR
- Wait for all checks to pass
- Get code review approval
- Squash and merge (if needed)
Testing Strategy
- Write unit tests for all new features
- Maintain 80%+ coverage
- Add integration tests for critical flows
- Update benchmarks for performance-sensitive code
Dependency Updates
- Review Dependabot PRs weekly
- Test major version updates thoroughly
- Group minor/patch updates when possible
- Keep dependencies up to date for security
Related Documentation
Support
For issues with CI/CD:
- Check GitHub Actions logs
- Review this documentation
- Open an issue: https://github.com/ooples/token-optimizer-mcp/issues
常见问题
io.github.ooples/token-optimizer-mcp 是什么?
Intelligent token optimization achieving 95%+ reduction through caching, compression, and 80+ tools
相关 Skills
技能工坊
by anthropics
覆盖 Skill 从创建到迭代优化全流程:起草能力、补测试提示、跑评测与基准方差分析,并持续改写内容和描述,提升效果与触发准确率。
✎ 技能工坊把技能从创建、迭代到评测串成闭环,方差分析加描述优化,特别适合把触发准确率打磨得更稳。
PPT处理
by anthropics
处理 .pptx 全流程:创建演示文稿、提取和解析幻灯片内容、批量修改现有文件,支持模板套用、合并拆分、备注评论与版式调整。
✎ 涉及PPTX的创建、解析、修改到合并拆分都能一站搞定,连备注、模板和评论也能处理,做演示文稿特别省心。
PDF处理
by anthropics
遇到 PDF 读写、文本表格提取、合并拆分、旋转加水印、表单填写或加解密时直接用它,也能提取图片、生成新 PDF,并把扫描件通过 OCR 变成可搜索文档。
✎ PDF杂活别再来回切工具了,文本表格提取、合并拆分到OCR识别一次搞定,连扫描件也能变可搜索。
相关 MCP Server
文件系统
编辑精选by Anthropic
Filesystem 是 MCP 官方参考服务器,让 LLM 安全读写本地文件系统。
✎ 这个服务器解决了让 Claude 直接操作本地文件的痛点,比如自动整理文档或生成代码文件。适合需要自动化文件处理的开发者,但注意它只是参考实现,生产环境需自行加固安全。
by wonderwhy-er
Desktop Commander 是让 AI 直接执行终端命令、管理文件和进程的 MCP 服务器。
✎ 这工具解决了 AI 无法直接操作本地环境的痛点,适合需要自动化脚本调试或文件批量处理的开发者。它能让你用自然语言指挥终端,但权限控制需谨慎,毕竟让 AI 执行 rm -rf 可不是闹着玩的。
EdgarTools
编辑精选by dgunning
EdgarTools 是无需 API 密钥即可解析 SEC EDGAR 财报的开源 Python 库。
✎ 这个工具解决了金融数据获取的痛点——直接让 AI 读取结构化财报,比如让 Claude 分析苹果的 10-K 文件。适合量化分析师或金融开发者快速构建数据管道。但注意,它依赖 SEC 网站稳定性,高峰期可能延迟。