Skip to content

Commit 03a7b3d

Browse files
niechenclaudeJoJoJoJoJoJoJoCopilot
authored
🤖 Add Comprehensive AI Agent Friendly CLI Support (#221)
* feat: add comprehensive AI agent friendly CLI support This commit implements comprehensive non-interactive CLI support for AI agents across all major MCPM commands: **Server Management (mcpm new, mcpm edit):** - Non-interactive server creation with --type, --command, --args, --env, --url, --headers - Field-specific server editing with CLI parameters - Environment variable support for automation **Profile Management (mcpm profile edit, mcpm profile inspect):** - Server management via --add-server, --remove-server, --set-servers - Profile renaming with --name parameter - Enhanced inspect with --port, --host, --http, --sse options **Client Management (mcpm client edit):** - Server and profile management for MCP clients - Support for --add-server, --remove-server, --set-servers - Profile operations with --add-profile, --remove-profile, --set-profiles **Infrastructure:** - New non-interactive utilities in src/mcpm/utils/non_interactive.py - Environment variable detection (MCPM_NON_INTERACTIVE, MCPM_FORCE) - Parameter parsing and validation utilities - Server configuration creation and merging **Documentation and Automation:** - Automatic llm.txt generation for AI agents - GitHub Actions workflow for continuous documentation updates - Developer tools for local llm.txt generation - Comprehensive AI agent integration guide **Key Benefits:** - Complete automation support with no interactive prompts - Environment variable configuration for sensitive data - Batch operations and structured error handling - 100% backward compatibility with existing interactive workflows 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * refactor: simplify CLI help text to remove redundant information - Streamlined docstrings for new, edit, profile edit, profile inspect, and client edit - Removed verbose examples that duplicated parameter descriptions - Focused on concise, essential information in help output - Regenerated llm.txt with cleaner documentation (23KB vs 27KB) - Improved user experience with less cluttered help screens 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: resolve linting errors and test failures after AI-agent CLI updates - Fix unused variable in generate_llm_txt.py - Clean up whitespace in docstrings throughout non_interactive.py - Fix edit command to properly exit with return codes using sys.exit() - Update tests to correctly mock non-interactive detection - Fix client edit test to avoid non-interactive mode for external editor test - Update test assertions to match new simplified help text All tests now pass (113 passed, 6 skipped) and linting is clean. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * test: add comprehensive non-interactive tests for AI-agent CLI commands - Add non-interactive test coverage for mcpm edit, profile edit, profile inspect, client edit, and config set commands - Fix exit code handling in commands to properly use sys.exit() for non-interactive mode - Fix remote server environment variable validation in non_interactive.py - Update existing tests to match corrected command behavior - Ensure all AI-agent friendly CLI commands have proper test coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: resolve test failures in edit and client commands - Fix RemoteServerConfig env field access issue in edit command - Update client edit tests to use add_server instead of update_servers - Fix profile test assertions for correct output messages 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: resolve mypy errors and remove duplicate function - Remove duplicate _edit_server_non_interactive function definition - Add Union type annotation to fix mypy type compatibility issues - Import Union from typing module 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: resolve all remaining profile command test failures - Fix mock setups for profile edit tests to match actual implementation - Update profile edit tests to use correct method calls (clear_profile, add_server_to_profile, etc.) - Fix server validation by mocking list_servers correctly - Handle profile name conflict checking in rename tests - Fix subprocess mocking in profile inspect tests - Update assertion expectations to match actual command behavior All tests now passing: 155 passed, 6 skipped 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: add missing mock for client edit test failing in CI - Add GlobalConfigManager mock to test_client_edit_command_client_not_installed - Ensures test has servers available to avoid early exit with code 1 - Fixes CI test failure where no servers were available 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * test: add assertion for remove_server method call in client edit test - Enhanced test_client_edit_non_interactive_remove_server to verify that client_manager.remove_server is called with the correct prefixed server name - Added proper mock setup for MCPM-managed server configuration - Ensures the removal operation is actually triggered as intended - Also includes automatic formatting fixes in test_profile_commands.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * test: add assertion for add_server method call in client edit test - Enhanced test_client_edit_non_interactive_add_server to verify that client_manager.add_server is called with the correct server configuration - Added detailed validation of the server config parameters: - Server name with proper mcpm_ prefix - Command set to "mcpm" - Args set to ["run", "test-server"] - Ensures the add operation is actually triggered as intended - Provides comprehensive verification of non-interactive add server workflow 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Update tests/test_edit.py Co-authored-by: Copilot <[email protected]> * test: add assertion for remove_server in set servers test Add assertion to verify that the old server is removed when using --set-servers in non-interactive mode. This ensures the test properly validates that old servers are removed before adding new ones. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: update GitHub Actions to latest versions and add security permissions - Update actions/setup-python from v4 to v5 - Update peter-evans/create-pull-request from v5 to v7 - Add minimal permissions block (contents: write, pull-requests: write) for improved security 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: pass force parameter to add_server to enable proper server overwrite - Pass force=force parameter to global_config_manager.add_server() call - Ensures existing servers are properly overwritten when --force flag is used - Fixes inconsistency where force check existed but wasn't applied 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Jonathan Wang <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 9e999e9 commit 03a7b3d

19 files changed

+4374
-121
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Generate LLM.txt
2+
3+
on:
4+
# Trigger on releases
5+
release:
6+
types: [published]
7+
8+
# Trigger on pushes to main branch
9+
push:
10+
branches: [main]
11+
paths:
12+
- 'src/mcpm/commands/**'
13+
- 'src/mcpm/cli.py'
14+
- 'scripts/generate_llm_txt.py'
15+
16+
# Allow manual trigger
17+
workflow_dispatch:
18+
19+
jobs:
20+
generate-llm-txt:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
pull-requests: write
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
fetch-depth: 0
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: '3.11'
37+
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install -e .
42+
43+
- name: Generate llm.txt
44+
run: |
45+
python scripts/generate_llm_txt.py
46+
47+
- name: Check for changes
48+
id: check_changes
49+
run: |
50+
if git diff --quiet llm.txt; then
51+
echo "no_changes=true" >> $GITHUB_OUTPUT
52+
else
53+
echo "no_changes=false" >> $GITHUB_OUTPUT
54+
fi
55+
56+
- name: Commit and push changes
57+
if: steps.check_changes.outputs.no_changes == 'false'
58+
run: |
59+
git config --local user.email "[email protected]"
60+
git config --local user.name "GitHub Action"
61+
git add llm.txt
62+
git commit -m "docs: update llm.txt for AI agents [skip ci]"
63+
git push
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Create Pull Request (for releases)
68+
if: github.event_name == 'release' && steps.check_changes.outputs.no_changes == 'false'
69+
uses: peter-evans/create-pull-request@v7
70+
with:
71+
token: ${{ secrets.GITHUB_TOKEN }}
72+
commit-message: "docs: update llm.txt for release ${{ github.event.release.tag_name }}"
73+
title: "📚 Update llm.txt for AI agents (Release ${{ github.event.release.tag_name }})"
74+
body: |
75+
## 🤖 Automated llm.txt Update
76+
77+
This PR automatically updates the llm.txt file for AI agents following the release of version ${{ github.event.release.tag_name }}.
78+
79+
### Changes
80+
- Updated command documentation
81+
- Refreshed examples and usage patterns
82+
- Updated version information
83+
84+
### What is llm.txt?
85+
llm.txt is a comprehensive guide for AI agents to understand how to interact with MCPM programmatically. It includes:
86+
- All CLI commands with parameters and examples
87+
- Environment variables for automation
88+
- Best practices for AI agent integration
89+
- Error handling and troubleshooting
90+
91+
This file is automatically generated from the CLI structure using `scripts/generate_llm_txt.py`.
92+
branch: update-llm-txt-${{ github.event.release.tag_name }}
93+
delete-branch: true

0 commit comments

Comments
 (0)